This repository has been archived by the owner on Oct 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
provision.sh
executable file
·66 lines (61 loc) · 2.38 KB
/
provision.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env bash
if [ "$#" -ne 2 ]; then
echo "provision.sh takes exactly two parameters:"
echo " provision.sh [kohaenv] [kohapath]"
fi
export KOHAENV=$1
export KOHAPATH=$2
echo -e "\n Provisioning for $KOHAENV env, KOHAENV=$KOHAENV, KOHAPATH=$KOHAPATH\n"
if [[ `uname -s` == 'Linux' && "$LSENV" != 'prod' ]]; then
echo -e "\n1) Installing Docker\n"
VERSION="17.09.0~ce-0~ubuntu"
INSTALLED=`dpkg -l | grep docker-engine | awk '{print $3}'`
if [ $VERSION = "$INSTALLED" ] ; then
echo "docker version $VERSION already installed";
else
echo "Installing docker version $VERSION ...";
sudo apt-get purge --assume-yes --quiet docker-engine docker-ce docker.io >/dev/null 2>&1 || true
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list
sudo apt-get update
sudo apt-get -y -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold \
install linux-image-extra-$(uname -r) linux-image-extra-virtual make git docker-ce=$VERSION
sudo echo 'DOCKER_OPTS="--storage-driver=aufs"' > /etc/default/docker
sudo service docker restart
echo "docker installed."
fi
echo -e "\n2) Installing Docker-compose\n"
COMPOSEVERSION=1.18.0-rc2
INSTALLED=`docker-compose -v | cut -d',' -f1 | cut -d' ' -f3`
if [ $COMPOSEVERSION = "$INSTALLED" ] ; then
echo "docker-compose version $COMPOSEVERSION already installed"
else
sudo bash -c "curl -s -L https://github.com/docker/compose/releases/download/$COMPOSEVERSION/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose"
sudo chmod +x /usr/local/bin/docker-compose
fi
else
echo "Cannot provision for OSX; please install docker & docker-compose yourself"
fi
echo -e "\n3) Provisioning system with docker-compose\n"
cd "$KOHAPATH/docker-compose"
source docker-compose.env
if [ "$KOHAPATH" = "/vagrant" ]; then
export MOUNTPATH="/mnt"
else
export MOUNTPATH=$KOHAPATH
fi
CMD="sudo KOHAPATH=${KOHAPATH} GITREF=${GITREF} KOHA_RELEASE=${KOHA_RELEASE} docker-compose -f common.yml"
case "$KOHAENV" in
'dev')
$CMD -f dev.yml build koha_dev
$CMD -f dev.yml up -d
;;
'patched')
$CMD -f patched.yml build koha_patched
$CMD -f patched.yml up -d
;;
'build'|*)
$CMD -f build.yml build koha_build
$CMD -f build.yml up -d
;;
esac