From 0a20fe7e755c4cb928c7b032bd166b7bb6ec2753 Mon Sep 17 00:00:00 2001 From: "Damir Gadiev [FFW]" Date: Wed, 6 Jul 2016 15:39:45 +0300 Subject: [PATCH 1/5] Add RHEL compatibility --- bin/dsh | 101 +++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 82 insertions(+), 19 deletions(-) diff --git a/bin/dsh b/bin/dsh index 0468950..d560f39 100755 --- a/bin/dsh +++ b/bin/dsh @@ -869,7 +869,7 @@ install_prerequisites () bash <(echo "$presetup_script") read -p "Press enter after the installation in another console window is done..." elif is_linux ; then - install_ubuntu + install_linux else # mac local presetup_script presetup_script=$(curl -fsS https://raw.githubusercontent.com/blinkreaction/boot2docker-vagrant/$B2D_BRANCH/scripts/presetup-mac.sh) @@ -912,15 +912,67 @@ install_sshagent_service () "blinkreaction/ssh-agent:${DRUDE_ITAG}" >/dev/null 2>&1 } +install_subnet_ubuntu () +{ + # Make sure we don't do this twice + if ! grep -q $DRUDE_SUBNET /etc/network/interfaces; then + cat > /tmp/drude.ip.addr < $interface << EOF +DEVICE=lo:drude +NAME=lo:drude +NM_CONTROLLED=yes +TYPE=Loopback +IPADDR=192.168.10.1 +NETMASK=255.255.255.0 +ONBOOT=yes +PEERDNS=yes +DNS=192.168.10.10 +EOF + sudo chmod 0655 $interface + sudo ifdown lo:drude && sudo ifup lo:drude + fi +} + +is_redhat() +{ + if [[ -r /etc/redhat-release || -r /etc/gentoo-release || -r /etc/gentoo-release ]]; then + return 0 + else + return 1 + fi +} + # Install Docker and setup Drude on Ubuntu 14.04+ -install_ubuntu () +install_linux () { - if [ -r /etc/lsb-release ]; then - lsb_dist="$(. /etc/lsb-release && echo "$DISTRIB_ID")" - lsb_release="$(. /etc/lsb-release && echo "$DISTRIB_RELEASE")" + if [ -r /etc/os-release ]; then + lsb_dist="$(. /etc/os-release && echo "$DISTRIB_ID")" + lsb_release="$(. /etc/os-release && echo "$DISTRIB_RELEASE")" + fi + + if [ -r /etc/redhat-release ]; then + lsb_dist="$(. /etc/os-release && echo "$DISTRIB_ID")" + lsb_release="$(. /etc/os-release && echo "$DISTRIB_RELEASE")" fi - if [[ $lsb_dist != 'Ubuntu' || $(ver_to_int $lsb_release) < $(ver_to_int '14.04') ]]; then + if [[ $lsb_dist == 'Ubuntu' && $(ver_to_int $lsb_release) < $(ver_to_int '14.04') ]]; then echo-red "dsh: prerequisites installation is currently supported only on Ubuntu 14.04+" if is_tty; then echo-yellow "You can continue at your own risk, if you know your Linux distribution is compatible with Ubuntu 14.04+" @@ -928,6 +980,16 @@ install_ubuntu () else exit 1 fi + else + if is_redhat; then + echo-red "dsh: prerequisites installation for RHEL Family is tested on Fedora (22, 23), RHEL (6.8, 7.2), CentOS(7)" + if is_tty; then + echo-yellow "You can continue at your own risk, if you know your Linux distribution is compatible with previously declared distributions" + _confirm "Are you sure you want to continue?" + else + exit 1 + fi + fi fi echo-green "Installing Docker..." @@ -949,17 +1011,13 @@ install_ubuntu () if_failed "Docker Compose installation/upgrade has failed." echo-green "Adding a subnet for Drude..." - # Make sure we don't do this twice - if ! grep -q $DRUDE_SUBNET /etc/network/interfaces; then - cat > /tmp/drude.ip.addr < Date: Wed, 6 Jul 2016 15:43:22 +0300 Subject: [PATCH 2/5] Minor updates to RHEL support changes --- bin/dsh | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/bin/dsh b/bin/dsh index d560f39..b8ada1c 100755 --- a/bin/dsh +++ b/bin/dsh @@ -26,6 +26,7 @@ DRUDE_COMMANDS_PATH=".drude/commands" # Network settings DRUDE_IP="192.168.10.10" DRUDE_SUBNET="192.168.10.1/24" +DRUDE_SUBNET_RHEL="192.168.10.1" DRUDE_DEFAULT_DNS="8.8.8.8" DRUDE_VBOX_DNS="10.0.2.3" @@ -939,11 +940,11 @@ DEVICE=lo:drude NAME=lo:drude NM_CONTROLLED=yes TYPE=Loopback -IPADDR=192.168.10.1 +IPADDR=$DRUDE_SUBNET_RHEL NETMASK=255.255.255.0 ONBOOT=yes PEERDNS=yes -DNS=192.168.10.10 +DNS=$DRUDE_IP EOF sudo chmod 0655 $interface sudo ifdown lo:drude && sudo ifup lo:drude @@ -962,14 +963,9 @@ is_redhat() # Install Docker and setup Drude on Ubuntu 14.04+ install_linux () { - if [ -r /etc/os-release ]; then - lsb_dist="$(. /etc/os-release && echo "$DISTRIB_ID")" - lsb_release="$(. /etc/os-release && echo "$DISTRIB_RELEASE")" - fi - - if [ -r /etc/redhat-release ]; then - lsb_dist="$(. /etc/os-release && echo "$DISTRIB_ID")" - lsb_release="$(. /etc/os-release && echo "$DISTRIB_RELEASE")" + if [ -r /etc/lsb-release ]; then + lsb_dist="$(. /etc/lsb-release && echo "$DISTRIB_ID")" + lsb_release="$(. /etc/lsb-release && echo "$DISTRIB_RELEASE")" fi if [[ $lsb_dist == 'Ubuntu' && $(ver_to_int $lsb_release) < $(ver_to_int '14.04') ]]; then From 9c99bd7d11b04ef3e6f4682ecae5c5f3b0965221 Mon Sep 17 00:00:00 2001 From: "Damir Gadiev [FFW]" Date: Wed, 6 Jul 2016 15:50:23 +0300 Subject: [PATCH 3/5] Add typo fix and update network manager restart --- bin/dsh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/bin/dsh b/bin/dsh index b8ada1c..ab5fc5c 100755 --- a/bin/dsh +++ b/bin/dsh @@ -1027,14 +1027,13 @@ install_linux () install_sshagent_service if_failed "Drude ssh-agent service setup failed." - if ! is_redhat; then { + if ! is_redhat; then echo-green "Configuring host DNS resolver for .drude domain..." echo -e "\n# .drude domain resolution\nnameserver $DRUDE_IP" | sudo tee -a /etc/resolvconf/resolv.conf.d/head sudo resolvconf -u - } - else { - sudo service restart NetworkManager.service - } + else + sudo systemctl restart NetworkManager.service + fi echo-green "To run docker without sudo please re-login or run 'newgrp docker' now." } From 6be6c209f9ecafffa766beab610b70331d31eb63 Mon Sep 17 00:00:00 2001 From: "Damir Gadiev [FFW]" Date: Wed, 31 Aug 2016 19:09:55 +0300 Subject: [PATCH 4/5] Fix rhel dns relolving --- bin/dsh | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/bin/dsh b/bin/dsh index cab5984..6906d9c 100755 --- a/bin/dsh +++ b/bin/dsh @@ -913,7 +913,7 @@ install_sshagent_service () "blinkreaction/ssh-agent:${DRUDE_ITAG}" >/dev/null 2>&1 } -install_subnet_ubuntu () +install_subnet_debian () { # Make sure we don't do this twice if ! grep -q $DRUDE_SUBNET /etc/network/interfaces; then @@ -951,6 +951,21 @@ EOF fi } +create_rhel_network_dispatcher_script () +{ + dispatcher="/etc/NetworkManager/dispatcher.d/lo:drude-up" + # Make sure this is not done twice + if [ ! -f $dispatcher ]; then + sudo touch $dispatcher + #sudo chmod 0777 $dispatcher + sudo echo lorem | sudo tee -a $dispatcher +#grep -q -F $DRUDE_SUBNET_RHEL /etc/resolv.conf || sudo echo "nameserver $DRUDE_SUBNET_RHEL" | sudo tee -a /etc/resolv.conf +EOF + sudo chmod 0655 $dispatcher + sudo systemctl restart NetworkManager.service + fi +} + is_redhat() { if [[ -r /etc/redhat-release || -r /etc/gentoo-release || -r /etc/gentoo-release ]]; then @@ -1010,9 +1025,9 @@ install_linux () if is_redhat; then install_subnet_rhel else - install_subnet_ubuntu + install_subnet_debian fi - if_failed "Docker subnet configuration failed failed." + if_failed "Docker subnet configuration failed." echo-green "Creating Drude HTTP/HTTPS reverse proxy..." @@ -1028,11 +1043,13 @@ install_linux () if_failed "Drude ssh-agent service setup failed." if ! is_redhat; then - echo-green "Configuring host DNS resolver for .drude domain..." - echo -e "\n# .drude domain resolution\nnameserver $DRUDE_IP" | sudo tee -a /etc/resolvconf/resolv.conf.d/head - sudo resolvconf -u + echo-green "Configuring host DNS resolver for .drude domain..." + echo -e "\n# .drude domain resolution\nnameserver $DRUDE_IP" | sudo tee -a /etc/resolvconf/resolv.conf.d/head + sudo resolvconf -u else - sudo systemctl restart NetworkManager.service + echo-green "Configuring host DNS resolver for .drude domain..." + create_rhel_network_dispatcher_script + if_failed "DNS resolver configuration failed." fi echo-green "To run docker without sudo please re-login or run 'newgrp docker' now." From 6426bcd10e89a3a19cda95eccd2c09e15e86a4ce Mon Sep 17 00:00:00 2001 From: "Damir Gadiev [FFW]" Date: Wed, 31 Aug 2016 19:22:38 +0300 Subject: [PATCH 5/5] Correct saving of dispatcher and interface files --- bin/dsh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/bin/dsh b/bin/dsh index 6906d9c..47cca11 100755 --- a/bin/dsh +++ b/bin/dsh @@ -935,7 +935,7 @@ install_subnet_rhel () if [ ! -f $interface ]; then sudo touch $interface sudo chmod 0777 $interface - sudo cat > $interface << EOF + cat > /tmp/drude.lo.interface << EOF DEVICE=lo:drude NAME=lo:drude NM_CONTROLLED=yes @@ -943,10 +943,10 @@ TYPE=Loopback IPADDR=$DRUDE_SUBNET_RHEL NETMASK=255.255.255.0 ONBOOT=yes -PEERDNS=yes -DNS=$DRUDE_IP EOF + sudo cp /tmp/drude.lo.interface $interface sudo chmod 0655 $interface + rm -r /tmp/drude.lo.interface sudo ifdown lo:drude && sudo ifup lo:drude fi } @@ -957,11 +957,13 @@ create_rhel_network_dispatcher_script () # Make sure this is not done twice if [ ! -f $dispatcher ]; then sudo touch $dispatcher - #sudo chmod 0777 $dispatcher - sudo echo lorem | sudo tee -a $dispatcher -#grep -q -F $DRUDE_SUBNET_RHEL /etc/resolv.conf || sudo echo "nameserver $DRUDE_SUBNET_RHEL" | sudo tee -a /etc/resolv.conf + sudo chmod 0777 $dispatcher + cat > /tmp/drude.dispatcher << EOF +grep -q -F $DRUDE_SUBNET_RHEL /etc/resolv.conf || echo "nameserver $DRUDE_SUBNET_RHEL" | tee -a /etc/resolv.conf EOF + sudo cp /tmp/drude.dispatcher $dispatcher sudo chmod 0655 $dispatcher + rm -r /tmp/drude.dispatcher sudo systemctl restart NetworkManager.service fi }