Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1 from asghaier/civic-1817-ahoy-installer
Browse files Browse the repository at this point in the history
Civic 1817 ahoy installer
  • Loading branch information
asghaier committed Apr 4, 2016
2 parents c615dae + f5fff97 commit 2531a2a
Show file tree
Hide file tree
Showing 5 changed files with 528 additions and 1 deletion.
113 changes: 113 additions & 0 deletions .ahoy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
ahoyapi: v1
version: 0.0.0
commands:

help:
usage: Development environment setup help
cmd: |
echo 'For a full docker development environment setup use the following command:
ahoy setup
For a step by step setup use the following commands in order:
ahoy deps
ahoy virtualbox
ahoy docker
ahoy nfs
ahoy machine'
mac:
usage: Mac setup commands
import: .ahoy/mac.ahoy.yml

debian:
usage: Debian setup commands
import: .ahoy/debian.ahoy.yml

arch:
usage: Arch Linux setup commands
import: .ahoy/arch.ahoy.yml

os:
usage: Checks the Operating System
cmd: |
os=""
if [ "$(uname)" == "Darwin" ]; then
os="mac"
elif [ "$(uname)" == "Linux" ]; then
if [ $(cat /etc/*release|grep -iE '(debian|ubuntu)'|wc -l) -gt 0 ]; then
os="debian"
elif [ $(cat /etc/*release|grep -iE '(arch)'|wc -l) -gt 0 ]; then
os="arch"
fi
fi
echo $os
shell:
usage: Prints the default shell
cmd: |
echo "$(echo $SHELL|rev|cut -d/ -f1|rev)"
rcfile:
usage: Prints the rcfile path of the default shell
cmd: |
echo "$HOME/.$(ahoy shell)rc"
setup:
usage: Setup the development environment
cmd: |
if [ "$(ahoy os)" != "" ]; then
ahoy $(ahoy os) setup {{args}}
else
echo "[Error] This OS is not supported."
exit 1
fi
deps:
usage: Install dependencies
cmd: |
if [ "$(ahoy os)" != "" ]; then
ahoy $(ahoy os) deps {{args}}
else
echo "[Error] This OS is not supported."
exit 1
fi
virtualbox:
usage: Install Virtualbox
cmd: |
if [ "$(ahoy os)" != "" ]; then
ahoy $(ahoy os) virtualbox {{args}}
else
echo "[Error] This OS is not supported."
exit 1
fi
docker:
usage: Install Docker
cmd: |
if [ "$(ahoy os)" != "" ]; then
ahoy $(ahoy os) docker {{args}}
else
echo "[Error] This OS is not supported."
exit 1
fi
nfs:
usage: Install NFS
cmd: |
if [ "$(ahoy os)" != "" ]; then
ahoy $(ahoy os) nfs {{args}}
else
echo "[Error] This OS is not supported."
exit 1
fi
machine:
usage: Create the "default" Docker machine
cmd: |
if [ "$(ahoy os)" != "" ]; then
ahoy $(ahoy os) machine {{args}}
else
echo "[Error] This OS is not supported."
exit 1
fi
114 changes: 114 additions & 0 deletions .ahoy/arch.ahoy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
ahoyapi: v1
version: 0.0.0
commands:

setup:
usage: Setup the Arch Linux development environment
cmd: |
set -e
ahoy arch deps
ahoy arch virtualbox
ahoy arch docker
ahoy arch nfs
ahoy arch machine
deps:
usage: Install dependencies
cmd: |
echo; echo "*** Dependencies Setup ***"; echo
set -e
echo "*** Creating the docker share folder at: $HOME/docker ..."
share="$HOME/docker"
if [ -e "$share" ]; then
echo -n "[Warning] $share exits. Are you sure you want to remove $share ? (Y/n) "
confirm="?"
while [[ $confirm != "y" ]] && [[ $confirm != "n" ]] && [[ $confirm != "" ]]; do
read confirm
confirm=$(echo $confirm|tr '[:upper:]' '[:lower:]')
done
if [[ $confirm == "n" ]]; then
echo "[Continue] $share is untouched. Press Enter to continue the installation or press Ctrl+C / Command+C to abort the installation."
read
else
echo "[Warning] $share will be removed. Press Enter to remove the folder and continue with the installation or press Ctrl+C / Command+C to abort the installation."
read
rm -rf $share
mkdir $share
fi
else
mkdir $share
fi
echo "*** Setting up perl-digest-hmac..."
yaourt -S perl-digest-hmac
virtualbox:
usage: Install Virtualbox
cmd: |
echo; echo "*** Virtualbox Setup ***"; echo
set -e
echo "*** Virtualbox setup..."
yaourt -S virtualbox virtualbox-guest-dkms virtualbox-guest-iso virtualbox-guest-utils virtualbox-host-dkms
echo "*** Virtualbox drivers setup..."
sudo /sbin/rcvboxdrv setup
echo "*** Virtualbox kernel modules loading at system bootup..."
sudo sh -c "echo -e \"vboxnetadp\nvboxnetflt\nvboxpci\nvboxdrv\" > /etc/modules-load.d/virtualbox.conf"
docker:
usage: Install Docker
cmd: |
echo; echo "*** Docker Setup ***"; echo
set -e
echo "*** Docker, docker-compose and docker-machine setup..."
yaourt -S docker docker-compose docker-machine
nfs:
usage: Install NFS
cmd: |
echo; echo "*** NFS Setup ***"; echo
set -e
echo "*** Docker-machine-nfs setup..."
sudo wget -q https://raw.githubusercontent.com/asghaier/docker-machine-nfs/civic-1817-fixing-linux-bugs/docker-machine-nfs.sh -O /usr/local/bin/docker-machine-nfs && sudo chmod 755 /usr/local/bin/docker-machine-nfs
echo "*** NTP and NFS-utils setup..."
yaourt -S ntp nfs-utils
echo "*** Starting and enabling bootup services for NTP daemon and NFS server..."
sudo systemctl start ntpd.service
sudo systemctl enable ntpd.service
sudo systemctl start nfs-server.service
sudo systemctl enable nfs-server.service
machine:
usage: Create the "default" Docker machine
cmd: |
echo; echo "*** Default Docker Machine Setup ***"; echo
set -e
MACHINE_NAME=default
echo "*** Creating the default docker machine using the virtualbox driver..."
docker-machine create --driver virtualbox $MACHINE_NAME
echo "*** Setting up docker machine nfs for the default machine..."
docker-machine-nfs $MACHINE_NAME --nfs-config="(rw,sync,all_squash,anonuid=$(id -u),anongid=$(id -g),no_subtree_check)" --shared-folder=$HOME/docker --force
echo "*** Environment variables setup and sourcing for the default machine..."
DEFAULT_SOURCE="$HOME/.default.docker-machine"
docker-machine env $MACHINE_NAME | grep -v "^#" > $DEFAULT_SOURCE
source $DEFAULT_SOURCE
if [ $(grep -E '(AHOY_CMD_PROXY="DOCKER"|AHOY_CMD_PROXY=DOCKER)' $(ahoy rcfile)|wc -l) -eq 0 ]; then
echo "export AHOY_CMD_PROXY=\"DOCKER\"" >> $(ahoy rcfile)
fi
if [ $(grep "source $DEFAULT_SOURCE" $(ahoy rcfile)|wc -l) -eq 0 ]; then
echo "source $DEFAULT_SOURCE" >> $(ahoy rcfile)
fi
echo
echo "[DONE] Please open a new shell to ensure all new environment settings are sourced"
128 changes: 128 additions & 0 deletions .ahoy/debian.ahoy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
ahoyapi: v1
version: 0.0.0
commands:

setup:
usage: Setup the Arch Linux development environment
cmd: |
set -e
ahoy debian deps
ahoy debian virtualbox
ahoy debian docker
ahoy debian nfs
ahoy debian machine
deps:
usage: Install dependencies
cmd: |
echo; echo "*** Dependencies Setup ***"; echo
set -e
echo "*** Creating the docker share folder at: $HOME/docker ..."
share="$HOME/docker"
if [ -e "$share" ]; then
echo -n "[Warning] $share exits. Are you sure you want to remove $share ? (Y/n) "
confirm="?"
while [[ $confirm != "y" ]] && [[ $confirm != "n" ]] && [[ $confirm != "" ]]; do
read confirm
confirm=$(echo $confirm|tr '[:upper:]' '[:lower:]')
done
if [[ $confirm == "n" ]]; then
echo "[Continue] $share is untouched. Press Enter to continue the installation or press Ctrl+C / Command+C to abort the installation."
read
else
echo "[Warning] $share will be removed. Press Enter to remove the folder and continue with the installation or press Ctrl+C / Command+C to abort the installation."
read
rm -rf $share
mkdir $share
fi
else
mkdir $share
fi
echo "*** Installing Perl digest hmac..."
sudo apt-get install libdigest-hmac-perl -y
virtualbox:
usage: Install Virtualbox
cmd: |
echo; echo "*** Virtualbox Setup ***"; echo
set -e
echo "*** Adding virtualbox to apt sources..."
echo "deb http://download.virtualbox.org/virtualbox/debian $(lsb_release --codename -s) contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list > /dev/null && wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add - && sudo apt-get update
echo "*** Virtualbox setup..."
sudo apt-get install virtualbox-5.0
docker:
usage: Install Docker
cmd: |
echo; echo "*** Docker Setup ***"; echo
set -e
MACHINE_MD5_LINUX_64=5558e5d7d003d337eacdc534c505dc5d
COMPOSE_MD5_LINUX_64=cb7f2d7f1a45bcff83cfd4669b1dcf53
DOCKER_MD5_LINUX_64=4583697764e695dd6d7f68d2834b5443
echo "*** Adding docker to apt sources..."
sudo apt-get install apt-transport-https ca-certificates && sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D && echo "deb https://apt.dockerproject.org/repo ubuntu-${OS[$codename]} main" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null && sudo apt-get update
echo "*** Remove legacy lxc-docker if it exists..."
sudo apt-get purge lxc-docker
echo "*** Install linux-image-extra..."
sudo apt-get install linux-image-extra-$(uname -r)
if [ $(cat /etc/*release|grep -i 'ubuntu'|wc -l) -gt 0 ]; then
echo "*** Install apparmor on Ubunu..."
sudo apt-get install apparmor
fi
echo "*** Installing docker-engine..."
echo $DOCKER_MD5_LINUX_64 /usr/bin/docker | md5sum -c - || sudo apt-get install docker-engine && echo $DOCKER_MD5_LINUX_64 /usr/bin/docker | md5sum -c -
echo "*** Installing docker-machine..."
echo $MACHINE_MD5_LINUX_64 /usr/local/bin/docker-machine | md5sum -c - || 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 && echo $MACHINE_MD5_LINUX_64 /usr/local/bin/docker-machine | md5sum -c -
echo "*** Installing docker-compose..."
echo $COMPOSE_MD5_LINUX_64 /usr/local/bin/docker-compose | md5sum -c - || 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 && echo $COMPOSE_MD5_LINUX_64 /usr/local/bin/docker-compose | md5sum -c -
nfs:
usage: Install NFS
cmd: |
echo; echo "*** NFS Setup ***"; echo
set -e
# 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
echo "*** Installing docker-machine-nfs (custom version)..."
sudo wget -q https://raw.githubusercontent.com/asghaier/docker-machine-nfs/civic-1817-fixing-linux-bugs/docker-machine-nfs.sh -O /usr/local/bin/docker-machine-nfs && sudo chmod 755 /usr/local/bin/docker-machine-nfs
machine:
usage: Create the "default" Docker machine
cmd: |
echo; echo "*** Default Docker Machine Setup ***"; echo
set -e
MACHINE_NAME=default
echo "*** Creating a default docker-machine..."
docker-machine create --driver virtualbox $MACHINE_NAME
echo "*** 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=$HOME/docker --force
echo "*** Environment variables setup and sourcing for the default machine..."
DEFAULT_SOURCE="$HOME/.default.docker-machine"
docker-machine env $MACHINE_NAME | grep -v "^#" > $DEFAULT_SOURCE
source $DEFAULT_SOURCE
if [ $(grep -E '(AHOY_CMD_PROXY="DOCKER"|AHOY_CMD_PROXY=DOCKER)' $(ahoy rcfile)|wc -l) -eq 0 ]; then
echo "export AHOY_CMD_PROXY=\"DOCKER\"" >> $(ahoy rcfile)
fi
if [ $(grep "source $DEFAULT_SOURCE" $(ahoy rcfile)|wc -l) -eq 0 ]; then
echo "source $DEFAULT_SOURCE" >> $(ahoy rcfile)
fi
echo
echo "[DONE] Please open a new shell to ensure all new environment settings are sourced"
Loading

0 comments on commit 2531a2a

Please sign in to comment.