Skip to content

Commit 208c470

Browse files
committed
[CE-49] Adapt setup script to multiple linux distros
Linux distribution is extracted from /etc/os-release file where a line ID= "distro" gives the mnemonic of the distribution The main change in the script is to define installation procedure with the proper packet manager (yum,zypper,cnf,apt-get..). The procedure will install Docker, python-pip and eventually docker-compose To test, a make setup was done followed by make start and the cello web interface was verified as available through a browser . All tests are conducted on VMs running on virtualBox Testing has been done on the following distributions: Opensuse (openSUSE Leap 42.2) Fedora (Fedora 25-1.3 server edition) Debian (debian 8.8.0) Ubuntu (ubuntu 16.04.2 server) Mint (linuxmint-18.1-cinnamon) Issue: CE-49 Change-Id: I9bcc7dd0f2814efda46aa7881dfd5d39871e9493 Signed-off-by: Daniel Vielvoye <dvielvoye@gmail.com>
1 parent 67f6a3e commit 208c470

File tree

1 file changed

+62
-3
lines changed

1 file changed

+62
-3
lines changed

scripts/setup.sh

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,72 @@
33
# It should be triggered at the upper directory, and safe to repeat.
44

55
source scripts/header.sh
6+
# collect ID from /etc/os-release as distribution name
7+
# tested on debian,ubuntu,mint , centos,fedora ,opensuse
8+
function get_distribution {
9+
distribution="Unknown"
10+
while read -r line
11+
do
12+
element=$(echo $line | cut -f1 -d=)
13+
if [ "$element" = "ID" ]
14+
then
15+
distribution=$(echo $line | cut -f2 -d=)
16+
fi
17+
done < "/etc/os-release"
18+
echo "${distribution//\"}"
19+
}
620

721
USER=`whoami`
8-
22+
DISTRO=$(get_distribution)
923
DB_DIR=/opt/${PROJECT}/mongo
1024

11-
sudo apt-get update && sudo apt-get install -y -m curl docker-engine python-pip
12-
25+
case $DISTRO in
26+
ubuntu)
27+
sudo apt-get update && sudo apt-get install -y curl docker-engine python-pip
28+
;;
29+
linuxmint)
30+
sudo apt-get install apt-transport-https ca-certificates -y
31+
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
32+
sudo echo deb https://apt.dockerproject.org/repo ubuntu-xenial main >> /etc/apt/sources.list.d/docker.list
33+
sudo apt-get update
34+
sudo apt-get purge lxc-docker
35+
sudo apt-get install python-pip
36+
sudo apt-get install linux-image-extra-$(uname -r) -y
37+
sudo apt-get install docker-engine cgroup-lite apparmor -y
38+
sudo service docker start
39+
;;
40+
debian)
41+
sudo apt-get install apt-transport-https ca-certificates -y
42+
sudo sh -c "echo deb https://apt.dockerproject.org/repo debian-jessie main > /etc/apt/sources.list.d/docker.list"
43+
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
44+
sudo apt-get update
45+
sudo apt-cache policy docker-engine
46+
sudo apt-get install docker-engine curl python-pip -y
47+
sudo service docker start
48+
;;
49+
centos)
50+
sudo yum install -y epel-release yum-utils
51+
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
52+
sudo yum makecache fast
53+
sudo yum update && sudo yum install -y docker-ce python-pip
54+
sudo systemctl enable docker
55+
sudo systemctl start docker
56+
;;
57+
fedora)
58+
sudo dnf -y update
59+
sudo dnf -y install docker python-pip --allowerasing
60+
sudo systemctl enable docker
61+
sudo systemctl start docker
62+
;;
63+
opensuse)
64+
sudo zypper refresh
65+
sudo zypper install docker docker-compose python-pip
66+
sudo systemctl restart docker
67+
;;
68+
*)
69+
echo "Linux distribution not identified !!! skipping docker & pip installation"
70+
;;
71+
esac
1372
sudo pip install --upgrade pip
1473

1574
sudo pip install --upgrade tox

0 commit comments

Comments
 (0)