forked from departement-loire-atlantique/publik
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-on-debian.sh
executable file
·103 lines (78 loc) · 2.55 KB
/
install-on-debian.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/sh
# Stop installation if something goes wrong (errpr code different from zero)
set -e
if [ ! -f install-on-debian.sh ]; then
echo "Please run this script in the root of the publik installation folder"
exit 1
fi
echo "Upgrade system"
#####################
apt-get update
apt-get dist-upgrade -y
echo "Install Docker"
#####################
# Source : https://docs.docker.com/install/linux/docker-ce/debian/#upgrade-docker-ce
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common
curl -fsSL $1 https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \
$(lsb_release -cs) stable"
apt-get update && apt-get install -y docker-ce
# Enable docker to start some containers at startup
systemctl enable docker
echo "Install docker compose"
##############################
# Source : https://docs.docker.com/compose/install/#install-compose
curl -L $1 https://github.com/docker/compose/releases/download/1.25.0/docker-compose-`uname -s`-`uname -m` \
-o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
echo "Create publik user"
#########################
if getent passwd publik > /dev/null 2>&1; then
echo "User publik already exists"
mkdir -p /home/publik
chown publik:publik /home/publik -R
usermod publik -d /home/publik
usermod publik -s /bin/bash
else
useradd publik -m
usermod publik -s /bin/bash
usermod publik -d /home/publik
echo "Choose publik password :"
passwd publik
fi
# Allow publik to use docker
usermod -a -G docker publik
echo "Add some convenients tools"
#################################
# gettext -> build-essential
# make
# vim
# git
apt-get install -y build-essential gettext vim git
echo "Add publik.bash to bash env of publik user..."
####################################################
env=`cat /home/publik/.bashrc | grep publik.bash | wc -l`
if [ $env -gt 0 ]; then
echo "Already present"
else
echo "" >> /home/publik/.bashrc
echo "source /home/publik/publik/publik.bash" >> /home/publik/.bashrc
echo "OK"
fi
echo "Generate HTTPS base certificates"
#######################################
mkdir -p data/ssl
# Generate certificates if needed
if [ ! -f data/ssl/ticket.key ]; then
openssl rand -out data/ssl/ticket.key 48
fi
if [ ! -f data/ssl/dhparam4.pem ]; then
openssl dhparam -out data/ssl/dhparam4.pem 4096
fi
chown publik:publik data -R