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

Arch linux support #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all 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
75 changes: 54 additions & 21 deletions install.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ MACHINE_MD5_LINUX_64=5558e5d7d003d337eacdc534c505dc5d
COMPOSE_MD5_LINUX_64=cb7f2d7f1a45bcff83cfd4669b1dcf53
DOCKER_MD5_LINUX_64=4583697764e695dd6d7f68d2834b5443

# Make a pseudo hashmap for legibility and because bash 3.x is the default on
# Make a pseudo hashmap for legibility and because bash 3.x is the default on
# OSX and it doesn't support bash hash arrays.
distro=0
release=1
codename=2
arch=3
kernal=4
OS=([$distro]="" [$release]="" [$codename]="" [$arch]="")
OS=([$distro]="" [$release]="" [$codename]="" [$arch]="")


show_help () {
Expand Down Expand Up @@ -50,15 +50,15 @@ OSX
Linux (Defaults)
===============
- Installs virtualbox via package manager when possible
- Installs docker-engine via package manager when possible
- Installs docker-engine via package manager when possible
- Installs docker-machine binary via curl. See https://docs.docker.com/machine/install-machine/
- Installs docker-compose via curl.


Ubuntu
-------
- Installs virtualbox (if not exists) through apt-get by adding virtualbox to apt sources.
- Installs docker-engine through apt-get by adding docker to apt sources.
- Installs docker-engine through apt-get by adding docker to apt sources.

ArchLinux
---------
Expand All @@ -67,18 +67,17 @@ ArchLinux
EOF
}


get_os() {

if [ ! "$(which uname)" ]; then
echo "WINDOWS NOT SUPPORTED YET"
exit 1
fi

UNAME=$(uname)

# We're on OSX
if [ $UNAME == "Darwin" ]; then
if [ $UNAME == "Darwin" ]; then
OS[$distro]="OSX"
OS[$release]="$(sw_vers -productVersion || false)"
# Not worth mapping OSX codenames I think and there isn't an easy cli command
Expand All @@ -95,17 +94,17 @@ get_os() {
OS[$codename]="$(lsb_release --codename -s || false)"
OS[$arch]="$(uname -m)"
OS[$kernal]="$(uname -r)"

else
echo "This OS isn't supported yet"
exit 1
fi
}

get_rc_file() {
if [ $SHELL == "/bin/zsh" ]; then
if [ $SHELL == "/bin/zsh" ] || [ $SHELL == "/usr/bin/zsh" ]; then
RC_FILE="$HOME/.zshrc"
elif [ $SHELL == "/bin/bash" ]; then
elif [ $SHELL == "/bin/bash" ] || [ $SHELL == "/bin/bash" ]; then
RC_FILE="$HOME/.bashrc"
else
"Error: Sorry, we don't support the $SHELL shell."
Expand All @@ -116,16 +115,14 @@ checksum() {
echo $1 $2 | md5sum -c -
}



cmd() {
if [ $VERBOSE ]; then
echo "COMMAND==> ${@:2}"
fi
printf "> $1 .. "
OUTPUT=`eval ${@:2}`
result=$?

if [ $result -eq 0 ]; then
echo "success"
if [ $VERBOSE ]; then
Expand All @@ -146,7 +143,7 @@ install_docker_engine() {

# Use a specific shared folder instead of just /Users or /home so that nfs mounts don't conflict.
# This is most important when running other vitualbox instances setup with nfs.
if [ -d "$SHARE_FOLDER" ]; then
if [ -d "$SHARE_FOLDER" ]; then
echo "Error: The share folder, '$SHARE_FOLDER' already exists. Please backup your data and remove the folder if you want to start over."
exit 1
else
Expand All @@ -160,7 +157,7 @@ install_docker_engine() {
exit 1
fi
cmd "Updating Homebrew" brew update

if [ -z "$(brew cask update)" ]; then
echo "Error: It looks like homebrew cask isn't installed. As of Dec 2015, it should come with homebrew. Try 'brew update'"
fi
Expand All @@ -172,8 +169,8 @@ install_docker_engine() {
cmd "Installing docker-machine-nfs" '
curl -s https://raw.githubusercontent.com/adlogix/docker-machine-nfs/master/docker-machine-nfs.sh |
sudo tee /usr/local/bin/docker-machine-nfs > /dev/null && sudo chmod +x /usr/local/bin/docker-machine-nfs'


cmd "Creating a default docker-machine" docker-machine create --driver virtualbox $MACHINE_NAME
cmd "Setting up the default docker-machine with NFS" docker-machine-nfs $MACHINE_NAME
cmd "Starting docker-machine '$MACHINE_NAME'" docker-machine start $MACHINE_NAME
Expand All @@ -194,24 +191,60 @@ install_docker_engine() {
if [[ ${OS[$release]} == "12"* || ${OS[$release]} == "14"* ]]; then
cmd "Install apparmor on Ubunu 12.04 or 14.04" sudo apt-get install apparmor
fi

cmd "Installing docker-engine" 'checksum $DOCKER_MD5_LINUX_64 /usr/bin/docker || sudo apt-get install docker-engine && checksum $DOCKER_MD5_LINUX_64 /usr/bin/docker'
cmd "Installing docker-machine" 'checksum $MACHINE_MD5_LINUX_64 /usr/local/bin/docker-machine || sudo wget -q https://github.com/docker/machine/releases/download/v0.6.0/docker-machine-`uname -s`-`uname -m` -O /usr/local/bin/docker-machine && sudo chmod 755 /usr/local/bin/docker-machine && checksum $MACHINE_MD5_LINUX_64 /usr/local/bin/docker-machine'
cmd "Installing docker-compose" 'checksum $COMPOSE_MD5_LINUX_64 /usr/local/bin/docker-compose || sudo wget -q https://github.com/docker/compose/releases/download/1.6.0/docker-compose-`uname -s`-`uname -m` -O /usr/local/bin/docker-compose && sudo chmod 755 /usr/local/bin/docker-compose && checksum $COMPOSE_MD5_LINUX_64 /usr/local/bin/docker-compose'
# Note that we needed to modify the docker-machine-nfs script to work with linux. So load the custom version.
# See https://github.com/adlogix/docker-machine-nfs/pull/51
cmd "Installing docker-machine-nfs (custom version)" '
sudo wget -q https://raw.githubusercontent.com/devinci-code/docker-machine-nfs/dev-50-support-linux/docker-machine-nfs.sh -O /usr/local/bin/docker-machine-nfs && sudo chmod 755 /usr/local/bin/docker-machine-nfs'


cmd "Installing Perl digest hmac" sudo apt-get install libdigest-hmac-perl -y

cmd "Creating a default docker-machine" docker-machine create --driver virtualbox $MACHINE_NAME
cmd "Setting up the default docker-machine with NFS" docker-machine-nfs $MACHINE_NAME --nfs-config='\(rw,sync,no_root_squash,no_subtree_check\)' --shared-folder=$SHARE_DIR --force
cmd "Setting up the default docker-machine with NFS" 'docker-machine-nfs $MACHINE_NAME --nfs-config="(rw,sync,all_squash,anonuid=$(id -u),anongid=$(id -g),no_subtree_check)"' --shared-folder=$SHARE_FOLDER --force
cmd "Starting docker-machine '$MACHINE_NAME'" docker-machine start $MACHINE_NAME
cmd "Adding machine environment variables to $RC_FILE" 'docker-machine env $MACHINE_NAME | grep export >> $RC_FILE'
cmd "Sourcing variables in '$RC_FILE'" source $RC_FILE

cmd "Testing share folder" 'touch $SHARE_DIR/test-file && docker-machine ssh default ls $SHARE_DIR/test-file'
fi
if [ ${OS[$distro]} == "Arch" ]; then
if [ `pacman -Q yaourt 2> /dev/null|wc -l` -lt 1 ]
then
echo "Error: Yaourt is required to install docker-machine. Aborting installation."
exit 1
fi

if [ `pacman -Q virtualbox docker docker-machine 2> /dev/null|wc -l` -gt 0 ]
then
echo "Error: Existing Virtualbox and/or Docker installation detected. Reinstalling Virtualbox, docker and docker-machine."
fi
cmd " Installing virtualbox" yaourt -S virtualbox virtualbox-guest-dkms virtualbox-guest-iso virtualbox-guest-modules virtualbox-guest-utils virtualbox-host-dkms virtualbox-host-modules
cmd "Setting up Virtualbox modules" sudo /sbin/rcvboxdrv setup
cmd "Enabling Virtualbox modules on system startup: /etc/modules-load.d/virtualbox.conf" 'sudo sh -c "echo -e \"vboxnetadp\nvboxnetflt\nvboxpci\nvboxdrv\" > /etc/modules-load.d/virtualbox.conf"'

cmd "Installing docker" yaourt -S docker docker-compose docker-machine

# Note that we needed to modify the docker-machine-nfs script to work with linux. So load the custom version.
# See https://github.com/adlogix/docker-machine-nfs/pull/51
cmd "Installing docker-machine-nfs (custom version)" 'sudo wget -q https://raw.githubusercontent.com/asghaier/docker-machine-nfs/arch-linux-support/docker-machine-nfs.sh -O /usr/local/bin/docker-machine-nfs && sudo chmod 755 /usr/local/bin/docker-machine-nfs'
cmd "Installing NTP and NFS services" yaourt -S ntp nfs-utils
cmd "Starting NTP service" sudo systemctl start ntpd.service
cmd "Enabling NTP service on system startup" sudo systemctl enable ntpd.service
cmd "Starting NFS service" sudo systemctl start nfs-server.service
cmd "Enabling NFS service on system startup" sudo systemctl enable nfs-server.service

cmd "Installing Perl digest hmac" yaourt -S perl-digest-hmac

cmd "Creating a default docker-machine" docker-machine create --driver virtualbox $MACHINE_NAME
cmd "Setting up the default docker-machine with NFS" 'docker-machine-nfs $MACHINE_NAME --nfs-config="(rw,sync,all_squash,anonuid=$(id -u),anongid=$(id -g),no_subtree_check)" --shared-folder=$SHARE_FOLDER --force'
DEFAULT_SOURCE="$HOME/.default.docker-machine"
cmd "Adding machine environment variables to $DEFAULT_SOURCE" 'docker-machine env $MACHINE_NAME | grep -v "^#" > $DEFAULT_SOURCE'
cmd "Sourcing variables in $DEFAULT_SOURCE" source $DEFAULT_SOURCE
cmd "Sourcing $DEFAULT_SOURCE in $RC_FILE" 'echo "source $DEFAULT_SOURCE" >> $RC_FILE'
fi
}

## MAIN ##
Expand Down