Skip to content
This repository has been archived by the owner on Dec 1, 2018. It is now read-only.

Rhel distributions #149

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Changes from 3 commits
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
90 changes: 74 additions & 16 deletions bin/dsh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Copy link
Owner

Choose a reason for hiding this comment

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

I don't like that we have two very similar constants.

Maybe do DRUDE_SUBNET="192.168.10.1, and append /24 to it in install_subnet_ubuntu.

Copy link
Contributor

Choose a reason for hiding this comment

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

192.168.10.1 is not subnet. It is a Drude Gateway IP

DRUDE_DEFAULT_DNS="8.8.8.8"
DRUDE_VBOX_DNS="10.0.2.3"

Expand Down Expand Up @@ -869,7 +870,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)
Expand Down Expand Up @@ -912,22 +913,79 @@ 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 <<EOF
up ip addr add $DRUDE_SUBNET dev lo label lo:drude
down ip addr del $DRUDE_SUBNET dev lo label lo:drude
EOF
sudo sed -i '/iface lo inet loopback/r /tmp/drude.ip.addr' /etc/network/interfaces
rm -f /tmp/drude.ip.addr
sudo ifdown lo && sudo ifup lo
fi
}

install_subnet_rhel ()
{
# Make sure we don't do this twice
interface="/etc/sysconfig/network-scripts/ifcfg-lo:drude"
# Make sure we don't do this twice.
if [ ! -f $interface ]; then
sudo touch $interface
sudo chmod 0777 $interface
sudo cat > $interface << EOF
DEVICE=lo:drude
NAME=lo:drude
NM_CONTROLLED=yes
TYPE=Loopback
IPADDR=$DRUDE_SUBNET_RHEL
NETMASK=255.255.255.0
ONBOOT=yes
PEERDNS=yes
DNS=$DRUDE_IP
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")"
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+"
_confirm "Are you sure you want to continue?"
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..."
Expand All @@ -949,17 +1007,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 <<EOF
up ip addr add $DRUDE_SUBNET dev lo label lo:drude
down ip addr del $DRUDE_SUBNET dev lo label lo:drude
EOF
sudo sed -i '/iface lo inet loopback/r /tmp/drude.ip.addr' /etc/network/interfaces
rm -f /tmp/drude.ip.addr
sudo ifdown lo && sudo ifup lo
if_failed "Docker subnet configuration failed failed."
if is_redhat; then
Copy link
Owner

Choose a reason for hiding this comment

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

We should have is_debian as well and rename ubuntu functions to debian.
Updated checks respectively and if we get a Linux that is not a Debian or RHEL family then break with an error.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's not rename functions right now @lmakarov

Copy link
Owner

Choose a reason for hiding this comment

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

OK, agreed.

install_subnet_rhel
else
install_subnet_ubuntu
fi
if_failed "Docker subnet configuration failed failed."
Copy link
Owner

Choose a reason for hiding this comment

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

failed failed



echo-green "Creating Drude HTTP/HTTPS reverse proxy..."
install_proxy_service
Expand All @@ -973,9 +1027,13 @@ EOF
install_sshagent_service
if_failed "Drude ssh-agent service setup failed."

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
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 systemctl restart NetworkManager.service
Copy link
Owner

Choose a reason for hiding this comment

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

Looking at the lo:drude interface configuration above, it looks like Drude's DNS will be used on that interface. Is this enough to have *.drude resolvable on a RHEL host?

fi

echo-green "To run docker without sudo please re-login or run 'newgrp docker' now."
}
Expand Down