-
Notifications
You must be signed in to change notification settings - Fork 0
/
inst.sh
158 lines (132 loc) · 4.42 KB
/
inst.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/bin/bash
# \t = ################
# echo -e "\n${Cyan}${Color_Off}"
# Reset
Color_Off='\033[0m' # Text Reset
# Regular Colors
Black='\033[0;30m' # Black
Red='\033[0;31m' # Red
Green='\033[0;32m' # Green
Yellow='\033[0;33m' # Yellow
Blue='\033[0;34m' # Blue
Purple='\033[0;35m' # Purple
Cyan='\033[0;36m' # Cyan
White='\033[0;37m' # White
writeText(){
t="########"
t2="################"
taille=`echo $1 | wc -c`
rep1=""
rep2=""
rep3=""
for (( i = 0; i < $taille; i++ )); do
rep1="${rep1}#"
done
for (( i = 0; i < 8; i++ )); do
rep2="${rep2} "
done
for (( i = 0; i < 8*2+$taille-2; i++ )); do
rep3="${rep3} "
done
echo -e "${2}"
echo -e "\n${t}${rep1}${t}"
echo -e "#${rep3}#"
echo -e "${2}#${rep2}$1${rep2}#"
echo -e "#${rep3}#"
echo -e "${2}${t}${rep1}${t}"
echo -e ${Color_Off}
}
pathadd() {
if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
PATH="${PATH:+"$PATH:"}$1"
fi
}
pathadd "/usr/bin/python3"
writeText "Début de l'installation" $Cyan
writeText "Installation des pré-requis" $Cyan
sudo apt-get install python3
sudo apt-get install python3-pip
sudo apt install php7.3
sudo apt-get install php-curl
sudo pip3 install -r requirements.txt
sudo chmod 777 *
mkdir log
writeText "Création du service \"listen\"" $Cyan
SOURCEPATH=$(dirname "$0") # relative
SOURCEPATH=$(cd "$SOURCEPATH"/.. && pwd) # absolutized and normalized
JARDIN_BRUYERE_DIRECTORY=${SOURCEPATH}/Serveur
Directory_Listen=${JARDIN_BRUYERE_DIRECTORY}/listen
Directory_Api=${JARDIN_BRUYERE_DIRECTORY}/api
#==================================================================================================================
# Creation du LISTEN
#==================================================================================================================
ChaineCaracteres="
[Unit]
# After=network.service
Description=Partie listen
[Service]
Type=simple
Environment=PYTHONUNBUFFERED=1
WorkingDirectory=${JARDIN_BRUYERE_DIRECTORY}
ExecStart=${JARDIN_BRUYERE_DIRECTORY}/listen.sh
User=root
StandardOutput=append:${JARDIN_BRUYERE_DIRECTORY}/log/listen_jardin.log
StandardError=append:${JARDIN_BRUYERE_DIRECTORY}/log/listen_jardin_err.log
[Install]
WantedBy=multi-user.target
# WantedBy=default.target
"
sudo echo -e "${ChaineCaracteres}" > /etc/systemd/system/listen.service
#==================================================================================================================
# Creation d'API
#==================================================================================================================
writeText "Création du service \"api\"" $Cyan
ChaineCaracteres="
[Unit]
# After=network.service
Description=Partie API
[Service]
Type=simple
Environment=PYTHONUNBUFFERED=1
WorkingDirectory=${JARDIN_BRUYERE_DIRECTORY}
ExecStart=${JARDIN_BRUYERE_DIRECTORY}/app.sh
User=root
StandardOutput=append:${JARDIN_BRUYERE_DIRECTORY}/log/api_jardin.log
StandardError=append:${JARDIN_BRUYERE_DIRECTORY}/log/api_jardin_err.log
# User=do-user
[Install]
WantedBy=multi-user.target
# WantedBy=default.target
"
sudo echo -e "${ChaineCaracteres}" > /etc/systemd/system/api.service
#==================================================================================================================
# Creation du SITE
#==================================================================================================================
ChaineCaracteres="
[Unit]
# After=network.service
Description=Partie SITE
[Service]
Type=simple
WorkingDirectory=${JARDIN_BRUYERE_DIRECTORY}
ExecStart=${JARDIN_BRUYERE_DIRECTORY}/administration.sh
User=root
StandardOutput=append:${JARDIN_BRUYERE_DIRECTORY}/log/administration_jardin.log
StandardError=append:${JARDIN_BRUYERE_DIRECTORY}/log/administration_jardin_err.log
[Install]
WantedBy=multi-user.target
# WantedBy=default.target
"
sudo echo -e "${ChaineCaracteres}" > /etc/systemd/system/administration.service
sudo systemctl daemon-reload
sudo systemctl restart api.service
sudo systemctl restart listen.service
sudo systemctl restart administration.service
writeText "Création réalisée" $Cyan
writeText "Vérification de l'installation" $Cyan
writeText "Verification de \"api.service\"" $Cyan
sudo systemctl status api.service
writeText "Verification de \"listen.service\"" $Cyan
sudo systemctl status listen.service
writeText "Verification de \"administration.service\"" $Cyan
sudo systemctl status administration.service