diff --git a/rsconf/package_data/docker/main.sh.jinja b/rsconf/package_data/docker/main.sh.jinja index 82affc33..822ec311 100644 --- a/rsconf/package_data/docker/main.sh.jinja +++ b/rsconf/package_data/docker/main.sh.jinja @@ -1,65 +1,29 @@ #!/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() { @@ -67,8 +31,3 @@ docker_version() { echo "${BASH_REMATCH[1]}" fi } - -docker_version_num() { - declare dotted=$1 - printf '%d%06d%06d' ${dotted//./ } -} diff --git a/tests/pkcli/build1_data/1.out/srv/host/v3.radia.run/docker.sh b/tests/pkcli/build1_data/1.out/srv/host/v3.radia.run/docker.sh index 1c814a79..47e845e0 100644 --- a/tests/pkcli/build1_data/1.out/srv/host/v3.radia.run/docker.sh +++ b/tests/pkcli/build1_data/1.out/srv/host/v3.radia.run/docker.sh @@ -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() { @@ -101,8 +67,3 @@ docker_version() { fi } -docker_version_num() { - declare dotted=$1 - printf '%d%06d%06d' ${dotted//./ } -} -