From c59cde61fe5d4c84603e8215ac9bb6783c43c4ba Mon Sep 17 00:00:00 2001 From: Ahmed Sghaier Date: Wed, 30 Mar 2016 20:31:09 +0100 Subject: [PATCH 1/4] ahoy installer template --- .ahoy.yml | 83 +++++++++++++++++++++++++++++++++++++++++++++ .ahoy/arch.ahoy.yml | 46 +++++++++++++++++++++++++ README.md | 59 +++++++++++++++++++++++++++++++- 3 files changed, 187 insertions(+), 1 deletion(-) create mode 100644 .ahoy.yml create mode 100644 .ahoy/arch.ahoy.yml diff --git a/.ahoy.yml b/.ahoy.yml new file mode 100644 index 0000000..1147e7f --- /dev/null +++ b/.ahoy.yml @@ -0,0 +1,83 @@ +ahoyapi: v1 +version: 0.0.0 +commands: + help: + usage: Mac setup commands + import: .ahoy/arch.ahoy.yml + mac: + usage: Mac setup commands + import: .ahoy/arch.ahoy.yml + debian: + usage: Debian setup commands + import: .ahoy/arch.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 + 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 + 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 + 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 + 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 diff --git a/.ahoy/arch.ahoy.yml b/.ahoy/arch.ahoy.yml new file mode 100644 index 0000000..9c38c8b --- /dev/null +++ b/.ahoy/arch.ahoy.yml @@ -0,0 +1,46 @@ +ahoyapi: v1 +version: 0.0.0 +commands: + setup: + usage: Setup the Arch Linux development environment + cmd: | + ahoy arch virtualbox + ahoy arch docker + ahoy arch nfs + ahoy arch deps + ahoy arch machine + virtualbox: + usage: Install Virtualbox + cmd: | + yaourt -S virtualbox virtualbox-guest-dkms virtualbox-guest-iso virtualbox-guest-utils virtualbox-host-dkms + sudo /sbin/rcvboxdrv setup + sudo sh -c "echo -e \"vboxnetadp\nvboxnetflt\nvboxpci\nvboxdrv\" > /etc/modules-load.d/virtualbox.conf" + docker: + usage: Install Docker + cmd: | + yaourt -S docker docker-compose docker-machine + nfs: + usage: Install NFS + cmd: | + 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 + yaourt -S ntp nfs-utils + sudo systemctl start ntpd.service + sudo systemctl enable ntpd.service + sudo systemctl start nfs-server.service + sudo systemctl enable nfs-server.service + deps: + usage: Install dependencies + cmd: | + yaourt -S perl-digest-hmac + machine: + usage: Create the "default" Docker machine + cmd: | + MACHINE_NAME=default + SHARE_FOLDER=$HOME/docker + RC_FILE=$HOME/.zshrc + docker-machine create --driver virtualbox $MACHINE_NAME + 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" + docker-machine env $MACHINE_NAME | grep -v "^#" > $DEFAULT_SOURCE + source $DEFAULT_SOURCE + echo "source $DEFAULT_SOURCE" >> $RC_FILE diff --git a/README.md b/README.md index 9d6dcf2..f4262dd 100644 --- a/README.md +++ b/README.md @@ -1 +1,58 @@ -# universal-docker-installer \ No newline at end of file +# Using the Universal Docker Installer + +## Installing dependencies +Before starting to use this universal docker installer, first install the dependencies in the following section. + +## Usage +First things first, cd into the root directory of the universal docker installer. + +For a full development environment installation, it is possible to execute the following single command: +``` +ahoy setup +``` +This will auto detect your operating system and proceed to full docker development environment setup. +Currently only Mac OSX, Debian based Linux distributions (Only Ubuntu is currently tested) and Arch Linux distribution are supported. + +# Installer dependencies + +## AHOY setup + +### OSX +Using Homebrew: +``` +brew tap devinci-code/tap +brew install ahoy +``` + +### Linux +Download and unzip the latest release and move the appropriate binary for your plaform into someplace in your $PATH and rename it `ahoy` + +Example: +``` +sudo wget -q https://github.com/devinci-code/ahoy/releases/download/1.1.0/ahoy-`uname -s`-amd64 -O /usr/local/bin/ahoy && sudo chown $USER /usr/local/bin/ahoy && chmod +x /usr/local/bin/ahoy +``` + +### More details on shell completion and usage +https://github.com/devinci-code/ahoy + +# Troubleshooting + +## List the available commands +If you want to list the available installer commands to execute a single command or for debugging reasons you can type: +``` +ahoy +``` + +## Step by step setup +To show the help of the automated setup and know more details about the order of steps required for the development environment setup you can execute the following command: +``` +ahoy help +``` + +## Consulting the script for the setup steps +The installer uses a main file ".ahoy.yml" which detects the operating system and invokes the appropriate commands for that specific operating system. + +The specific operating system scripts are located at ".ahoy" directory. +As an example, to consult the commands required for installing docker on Ubuntu, check the file "debian.ahoy.yml" as Ubuntu is a Debian based Linux distribution (currently the commands are only tested on Ubuntu and not even Debian itself). + +Mac OSX and Arch Linux are also supported. From aac1a358740001abd1e9c6eafcd696412ecdb38c Mon Sep 17 00:00:00 2001 From: Ahmed Sghaier Date: Thu, 31 Mar 2016 23:04:01 +0100 Subject: [PATCH 2/4] Added support for Debian/Ubuntu and Mac OSX and improved setup steps --- .ahoy.yml | 56 ++++++++++++++++++------ .ahoy/arch.ahoy.yml | 57 +++++++++++++++++++++---- .ahoy/debian.ahoy.yml | 99 +++++++++++++++++++++++++++++++++++++++++++ .ahoy/mac.ahoy.yml | 89 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 279 insertions(+), 22 deletions(-) create mode 100644 .ahoy/debian.ahoy.yml create mode 100644 .ahoy/mac.ahoy.yml diff --git a/.ahoy.yml b/.ahoy.yml index 1147e7f..4ea0586 100644 --- a/.ahoy.yml +++ b/.ahoy.yml @@ -1,18 +1,32 @@ ahoyapi: v1 version: 0.0.0 commands: + help: - usage: Mac setup commands - import: .ahoy/arch.ahoy.yml + 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/arch.ahoy.yml + import: .ahoy/mac.ahoy.yml + debian: usage: Debian setup commands - import: .ahoy/arch.ahoy.yml + import: .ahoy/debian.ahoy.yml + arch: usage: Arch Linux setup commands import: .ahoy/arch.ahoy.yml + os: usage: Checks the Operating System cmd: | @@ -27,6 +41,17 @@ commands: 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: | @@ -36,6 +61,17 @@ commands: 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: | @@ -45,6 +81,7 @@ commands: echo "[Error] This OS is not supported." exit 1 fi + docker: usage: Install Docker cmd: | @@ -54,6 +91,7 @@ commands: echo "[Error] This OS is not supported." exit 1 fi + nfs: usage: Install NFS cmd: | @@ -63,15 +101,7 @@ commands: 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 + machine: usage: Create the "default" Docker machine cmd: | diff --git a/.ahoy/arch.ahoy.yml b/.ahoy/arch.ahoy.yml index 9c38c8b..0f11629 100644 --- a/.ahoy/arch.ahoy.yml +++ b/.ahoy/arch.ahoy.yml @@ -1,46 +1,85 @@ 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 deps ahoy arch machine + + deps: + usage: Install dependencies + cmd: | + echo; echo "*** Dependencies Setup ***"; echo + set -e + + 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/arch-linux-support/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 - deps: - usage: Install dependencies - cmd: | - yaourt -S perl-digest-hmac + machine: usage: Create the "default" Docker machine cmd: | + echo; echo "*** Default Docker Machine Setup ***"; echo + set -e + MACHINE_NAME=default - SHARE_FOLDER=$HOME/docker - RC_FILE=$HOME/.zshrc + + echo "*** Creating the default docker machine using the virtualbox driver..." docker-machine create --driver virtualbox $MACHINE_NAME - 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 + + 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 - echo "source $DEFAULT_SOURCE" >> $RC_FILE + echo "source $DEFAULT_SOURCE" >> $(ahoy rcfile) diff --git a/.ahoy/debian.ahoy.yml b/.ahoy/debian.ahoy.yml new file mode 100644 index 0000000..06ec89c --- /dev/null +++ b/.ahoy/debian.ahoy.yml @@ -0,0 +1,99 @@ +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 "*** 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/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 + + 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 + echo "source $DEFAULT_SOURCE" >> $(ahoy rcfile) diff --git a/.ahoy/mac.ahoy.yml b/.ahoy/mac.ahoy.yml new file mode 100644 index 0000000..a53994f --- /dev/null +++ b/.ahoy/mac.ahoy.yml @@ -0,0 +1,89 @@ +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 + + # Assume homebrew is a requirement for now + if [ ! "$(which brew)" ]; then + echo "[Error] It looks like homebrew isn't installed. Please install that first." + exit 1 + fi + + echo "*** 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 + + virtualbox: + usage: Install Virtualbox + cmd: | + echo; echo "*** Virtualbox Setup ***"; echo + set -e + + echo "Installing the latest virtualbox" + brew update + + docker: + usage: Install Docker + cmd: | + echo; echo "*** Docker Setup ***"; echo + set -e + + echo "*** Installing docker-engine..." + brew install docker + + echo "*** Installing docker-machine..." + brew install docker-machine + + echo "*** Installing docker-machine..." + brew install docker-machine + + nfs: + usage: Install NFS + cmd: | + echo; echo "*** NFS Setup ***"; echo + set -e + + echo "*** 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 + + 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 + + echo "*** Starting docker-machine $MACHINE_NAME..." + docker-machine start $MACHINE_NAME + + 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 + echo "source $DEFAULT_SOURCE" >> $(ahoy rcfile) From 07ca1c747577793489b39151dd7d8857fb833707 Mon Sep 17 00:00:00 2001 From: Willie Seabrook Date: Mon, 4 Apr 2016 20:16:19 +0100 Subject: [PATCH 3/4] Mac fixes --- .ahoy/arch.ahoy.yml | 9 ++++++++- .ahoy/debian.ahoy.yml | 19 +++++++++++++------ .ahoy/mac.ahoy.yml | 28 ++++++++++++++++------------ 3 files changed, 37 insertions(+), 19 deletions(-) diff --git a/.ahoy/arch.ahoy.yml b/.ahoy/arch.ahoy.yml index 0f11629..090047a 100644 --- a/.ahoy/arch.ahoy.yml +++ b/.ahoy/arch.ahoy.yml @@ -82,4 +82,11 @@ commands: DEFAULT_SOURCE="$HOME/.default.docker-machine" docker-machine env $MACHINE_NAME | grep -v "^#" > $DEFAULT_SOURCE source $DEFAULT_SOURCE - echo "source $DEFAULT_SOURCE" >> $(ahoy rcfile) + 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" diff --git a/.ahoy/debian.ahoy.yml b/.ahoy/debian.ahoy.yml index 06ec89c..e3f591f 100644 --- a/.ahoy/debian.ahoy.yml +++ b/.ahoy/debian.ahoy.yml @@ -7,11 +7,11 @@ commands: cmd: | set -e - ahoy arch deps - ahoy arch virtualbox - ahoy arch docker - ahoy arch nfs - ahoy arch machine + ahoy debian deps + ahoy debian virtualbox + ahoy debian docker + ahoy debian nfs + ahoy debian machine deps: usage: Install dependencies @@ -96,4 +96,11 @@ commands: DEFAULT_SOURCE="$HOME/.default.docker-machine" docker-machine env $MACHINE_NAME | grep -v "^#" > $DEFAULT_SOURCE source $DEFAULT_SOURCE - echo "source $DEFAULT_SOURCE" >> $(ahoy rcfile) + 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" diff --git a/.ahoy/mac.ahoy.yml b/.ahoy/mac.ahoy.yml index a53994f..7267dd3 100644 --- a/.ahoy/mac.ahoy.yml +++ b/.ahoy/mac.ahoy.yml @@ -7,11 +7,11 @@ commands: cmd: | set -e - ahoy arch deps - ahoy arch virtualbox - ahoy arch docker - ahoy arch nfs - ahoy arch machine + ahoy mac deps + ahoy mac virtualbox + ahoy mac docker + ahoy mac nfs + ahoy mac machine deps: usage: Install dependencies @@ -53,8 +53,8 @@ commands: echo "*** Installing docker-machine..." brew install docker-machine - echo "*** Installing docker-machine..." - brew install docker-machine + echo "*** Installing docker-compose..." + brew install docker-compose nfs: usage: Install NFS @@ -77,13 +77,17 @@ commands: docker-machine create --driver virtualbox $MACHINE_NAME echo "*** Setting up the default docker-machine with NFS..." - docker-machine-nfs $MACHINE_NAME - - echo "*** Starting docker-machine $MACHINE_NAME..." - docker-machine start $MACHINE_NAME + docker-machine-nfs $MACHINE_NAME --shared-folder=$HOME/docker 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 - echo "source $DEFAULT_SOURCE" >> $(ahoy rcfile) + 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" From f5fff9715ecd30a6066529ecd22ede02042843c5 Mon Sep 17 00:00:00 2001 From: Ahmed Sghaier Date: Mon, 4 Apr 2016 21:38:49 +0100 Subject: [PATCH 4/4] Creating docker share folder in the users home directory and a fix for docker-machine-nfs on linux --- .ahoy/arch.ahoy.yml | 24 +++++++++++++++++++++++- .ahoy/debian.ahoy.yml | 24 +++++++++++++++++++++++- .ahoy/mac.ahoy.yml | 22 ++++++++++++++++++++++ 3 files changed, 68 insertions(+), 2 deletions(-) diff --git a/.ahoy/arch.ahoy.yml b/.ahoy/arch.ahoy.yml index 090047a..d448c89 100644 --- a/.ahoy/arch.ahoy.yml +++ b/.ahoy/arch.ahoy.yml @@ -19,6 +19,28 @@ commands: 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 @@ -53,7 +75,7 @@ commands: set -e echo "*** Docker-machine-nfs setup..." - 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 + 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 diff --git a/.ahoy/debian.ahoy.yml b/.ahoy/debian.ahoy.yml index e3f591f..2f37da1 100644 --- a/.ahoy/debian.ahoy.yml +++ b/.ahoy/debian.ahoy.yml @@ -19,6 +19,28 @@ commands: 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 @@ -76,7 +98,7 @@ commands: # 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/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 + 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 diff --git a/.ahoy/mac.ahoy.yml b/.ahoy/mac.ahoy.yml index 7267dd3..3cfe35f 100644 --- a/.ahoy/mac.ahoy.yml +++ b/.ahoy/mac.ahoy.yml @@ -19,6 +19,28 @@ commands: 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 + # Assume homebrew is a requirement for now if [ ! "$(which brew)" ]; then echo "[Error] It looks like homebrew isn't installed. Please install that first."