Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #518: Use redhat-docker intaller #522

Merged
merged 7 commits into from
Nov 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gratuitous but came across this use of sort and thought it was nice.

}

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//./ }
}
Loading