Skip to content

Commit

Permalink
Fix #518: Use redhat-docker intaller (#522)
Browse files Browse the repository at this point in the history
Installers are now split apart (setup vs install). rsconf does setup so only need install radiasoft/download@85490d1
  • Loading branch information
e-carlin authored Nov 18, 2024
1 parent c35dfae commit 0615475
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 96 deletions.
57 changes: 8 additions & 49 deletions rsconf/package_data/docker/main.sh.jinja
Original file line number Diff line number Diff line change
@@ -1,74 +1,33 @@
#!/bin/bash
_docker_pkg=docker-ce

docker_install() {
if [[ -e /var/lib/docker ]]; then
# This will happen on dev systems only, but a good check nonetheless
install_err '/var/lib/docker exists. You need to:
systemctl stop docker
systemctl disable docker
rm -rf /var/lib/docker/*
umount /var/lib/docker
rmdir /var/lib/docker
perl -pi -e "s{^/var/lib/docker.*}{}" /etc/fstab
lvremove -f /dev/mapper/docker-vps
Then re-run rsconf. This should only happen in development environments.
'
fi
if rsconf_fedora_release_if 26; then
# https://docs.docker.com/engine/installation/linux/docker-ce/fedora/#set-up-the-repository
dnf -y install dnf-plugins-core
dnf config-manager \
--add-repo \
https://download.docker.com/linux/fedora/"$_docker_pkg".repo
else
yum-config-manager \
--add-repo https://download.docker.com/linux/centos/"$_docker_pkg".repo
yum makecache fast
# yum-plugin-ovl required for overlay2 on centos7
# https://github.com/docker-library/official-images/issues/1291
rsconf_yum_install yum-plugin-ovl
fi
rsconf_yum_install "$_docker_pkg"
{% if rsconf_db.channel == "dev" %}
# Give vagrant user access in dev mode only
usermod -aG docker vagrant
{% endif %}
}

docker_main() {
declare d={{ docker.data_d }}/volumes
if [[ -e $d ]] && type docker >& /dev/null; then
if docker_need_update; then
if docker_up_to_date; then
install_info "$d: exists, docker already installed"
else
# Need to specify cli explicitly or it won't update
install_yum update "$_docker_pkg" "$_docker_pkg"-cli
else
install_info "$d: exists, docker already installed"
fi
else
docker_install
rsconf_radia_run_as_user root redhat-docker-install
fi
if docker_need_update; then
if ! docker_up_to_date; then
install_err "Installed docker=$(docker_version) is < min_software_version={{ docker.min_software_version }} after install."
fi
}

docker_need_update() {
local v=$(docker_version)
docker_up_to_date() {
declare v=$(docker_version)
if [[ ! $v ]]; then
install_err "docker --version did not output a valid version number"
fi
(( $(docker_version_num "$v" ) < $(docker_version_num '{{ docker.min_software_version }}') ))
printf "%s\n%s\n" '{{ docker.min_software_version }}' "$v" | sort --version-sort --check &> /dev/null
}

docker_version() {
if [[ $(docker --version) =~ ([0-9]+\.[0-9]+\.[0-9]+) ]]; then
echo "${BASH_REMATCH[1]}"
fi
}

docker_version_num() {
declare dotted=$1
printf '%d%06d%06d' ${dotted//./ }
}
55 changes: 8 additions & 47 deletions tests/pkcli/build1_data/1.out/srv/host/v3.radia.run/docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,63 +36,29 @@ rsconf_install_directory '/srv/docker/db_bkp'
#!/bin/bash
_docker_pkg=docker-ce

docker_install() {
if [[ -e /var/lib/docker ]]; then
# This will happen on dev systems only, but a good check nonetheless
install_err '/var/lib/docker exists. You need to:
systemctl stop docker
systemctl disable docker
rm -rf /var/lib/docker/*
umount /var/lib/docker
rmdir /var/lib/docker
perl -pi -e "s{^/var/lib/docker.*}{}" /etc/fstab
lvremove -f /dev/mapper/docker-vps
Then re-run rsconf. This should only happen in development environments.
'
fi
if rsconf_fedora_release_if 26; then
# https://docs.docker.com/engine/installation/linux/docker-ce/fedora/#set-up-the-repository
dnf -y install dnf-plugins-core
dnf config-manager \
--add-repo \
https://download.docker.com/linux/fedora/"$_docker_pkg".repo
else
yum-config-manager \
--add-repo https://download.docker.com/linux/centos/"$_docker_pkg".repo
yum makecache fast
# yum-plugin-ovl required for overlay2 on centos7
# https://github.com/docker-library/official-images/issues/1291
rsconf_yum_install yum-plugin-ovl
fi
rsconf_yum_install "$_docker_pkg"
# Give vagrant user access in dev mode only
usermod -aG docker vagrant
}

docker_main() {
declare d=/srv/docker/volumes
if [[ -e $d ]] && type docker >& /dev/null; then
if docker_need_update; then
if docker_up_to_date; then
install_info "$d: exists, docker already installed"
else
# Need to specify cli explicitly or it won't update
install_yum update "$_docker_pkg" "$_docker_pkg"-cli
else
install_info "$d: exists, docker already installed"
fi
else
docker_install
rsconf_radia_run_as_user root redhat-docker-install
fi
if docker_need_update; then
if ! docker_up_to_date; then
install_err "Installed docker=$(docker_version) is < min_software_version=1.0.0 after install."
fi
}

docker_need_update() {
local v=$(docker_version)
docker_up_to_date() {
declare v=$(docker_version)
if [[ ! $v ]]; then
install_err "docker --version did not output a valid version number"
fi
(( $(docker_version_num "$v" ) < $(docker_version_num '1.0.0') ))
printf "%s\n%s\n" '1.0.0' "$v" | sort --version-sort --check &> /dev/null
}

docker_version() {
Expand All @@ -101,8 +67,3 @@ docker_version() {
fi
}

docker_version_num() {
declare dotted=$1
printf '%d%06d%06d' ${dotted//./ }
}

0 comments on commit 0615475

Please sign in to comment.