-
Notifications
You must be signed in to change notification settings - Fork 24
/
install_app.sh
executable file
·71 lines (54 loc) · 2.18 KB
/
install_app.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
#!/usr/bin/env bash
. config/settings.ini || exit 1
# Création des fichiers de configuration
cd config
echo "Création du fichier de configuration ..."
if [ ! -f config.py ]; then
cp config.py.sample config.py || exit 1
echo "préparation du fichier config.py..."
sed -i "s/SQLALCHEMY_DATABASE_URI = .*$/SQLALCHEMY_DATABASE_URI = \"postgresql:\/\/$user_pg:$user_pg_pass@$db_host:$pg_port\/$db_name\"/" config.py || exit 1
url_application="${url_application//\//\\/}"
# on enleve le / final
if [ "${url_application: -1}" = '/' ]
then
url_application="${url_application::-1}"
fi
sed -i "s/URL_APPLICATION =.*$/URL_APPLICATION ='$url_application'/g" config.py || exit 1
fi
cd ..
# Installation de l'environement python
echo "Installation du virtual env..."
python3 -m venv venv || exit 1
source venv/bin/activate
pip install --upgrade pip || exit 1
if [ "${mode}" = "dev" ]; then
pip install -r requirements-dev.txt || exit 1
else
pip install -r requirements.txt || exit 1
fi
deactivate
# rendre la commande nvm disponible
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# Installation de l'environement javascript
cd app/static
nvm install || exit 1
nvm use || exit 1
npm ci || exit 1
cd ../..
#Lancement de l'application
export USERSHUB_DIR=$(readlink -e "${0%/*}")
# Configuration systemd
envsubst '${USER}' < tmpfiles-usershub.conf | sudo tee /etc/tmpfiles.d/usershub.conf || exit 1
sudo systemd-tmpfiles --create /etc/tmpfiles.d/usershub.conf || exit 1
envsubst '${USER} ${USERSHUB_DIR}' < usershub.service | sudo tee /etc/systemd/system/usershub.service || exit 1
sudo systemctl daemon-reload || exit 1
# Configuration logrotate
envsubst '${USER}' < log_rotate | sudo tee /etc/logrotate.d/usershub
# Configuration apache
sudo cp usershub_apache.conf /etc/apache2/conf-available/usershub.conf || exit 1
sudo a2enmod proxy || exit 1
sudo a2enmod proxy_http || exit 1
# you may need a restart if proxy & proxy_http was not already enabled
echo "Vous pouvez maintenant démarrer UsersHub avec la commande : sudo systemctl start usershub"