1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/lutim_ynh.git synced 2024-09-03 19:36:24 +02:00
lutim_ynh/scripts/upgrade

75 lines
2.7 KiB
Text
Raw Normal View History

2015-03-16 21:10:39 +01:00
#!/bin/bash
2015-11-18 00:28:42 +01:00
# Récupère les infos de l'application.
2015-03-26 13:07:01 +01:00
app=lutim
domain=$(sudo yunohost app setting $app domain)
path=$(sudo yunohost app setting $app path)
is_public=$(sudo yunohost app setting $app is_public)
port=$(sudo yunohost app setting $app port)
always_encrypt=$(sudo yunohost app setting $app always_encrypt)
2015-11-18 00:28:42 +01:00
final_path=$(sudo yunohost app setting $app final_path)
2015-03-16 21:10:39 +01:00
2015-03-27 23:26:10 +01:00
# Vérifie l'absence du / en fin de path
pathRslash=$(echo "$path" | sed 's@/$@@')
# Modifie le domaine pour qu'il passe dans une regex
domain_regex=$(echo "$domain" | sed 's@-@.@g')
2015-03-26 13:07:01 +01:00
# Décompresse la source
tar -x -f ../sources/lutim.tar.gz
2015-11-18 00:28:42 +01:00
# Copie les fichiers sources
2015-03-26 13:07:01 +01:00
sudo cp -a lutim/. "$final_path"
2015-11-18 00:28:42 +01:00
# Copie les fichiers additionnels ou modifiés.
2015-03-26 13:07:01 +01:00
sudo cp -a ../sources/ajouts/. "$final_path"
2015-11-18 00:28:42 +01:00
# Et copie le fichier de config nginx
2015-03-26 13:07:01 +01:00
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
2015-03-16 21:10:39 +01:00
2015-03-26 13:07:01 +01:00
# Change variables in nginx configuration
sudo sed -i "s@__PATH__@$path@g" /etc/nginx/conf.d/$domain.d/$app.conf
sudo sed -i "s@__PORT__@$port@g" /etc/nginx/conf.d/$domain.d/$app.conf
## Copie et configuration du fichier de conf.
sudo cp ../conf/lutim.conf.template "$final_path/lutim.conf"
sudo sed -i "s@__DOMAIN__@$domain@g" "$final_path/lutim.conf"
sudo sed -i "s@__PATH__@$path@g" "$final_path/lutim.conf"
sudo sed -i "s@__PORT__@$port@g" "$final_path/lutim.conf"
if [ "always_encrypt" = "No" ]; then
always_encrypt=0
else
always_encrypt=1
fi
sudo sed -i "s@__ENCRYPT__@$always_encrypt@g" "$final_path/lutim.conf"
2015-03-16 21:10:39 +01:00
2015-03-26 13:07:01 +01:00
# Mise en place des scripts init
sudo cp ../conf/lutim.init /etc/init.d/lutim
sudo sed -i "s@__FINALPATH__@$final_path@g" /etc/init.d/lutim
sudo cp ../conf/lutim.default /etc/default/lutim
sudo chmod +x /etc/init.d/lutim
sudo chown root:root /etc/init.d/lutim /etc/default/lutim
sudo sed -i "s@__FINALPATH__@$final_path/@g" /etc/default/lutim
2015-03-16 21:10:39 +01:00
2015-03-26 13:07:01 +01:00
## Mise en place des crons
sudo cp ../conf/cron_lutim /etc/cron.d/$app
sudo sed -i "s@__FINALPATH__@$final_path/@g" /etc/cron.d/$app
2015-03-16 21:10:39 +01:00
2015-08-19 21:33:40 +02:00
# Mise à jour de lutim via carton
cd $final_path
sudo carton install 2>&1 | sudo tee -a "/var/log/$app/setup_carton.log"
2015-03-26 13:07:01 +01:00
# Make app public or private
sudo yunohost app setting $app skipped_uris -v "/"
2015-03-16 21:10:39 +01:00
if [ "$is_public" = "No" ];
2015-03-26 13:07:01 +01:00
then # Si l'app est privée, seul le visionnage des images reste public
2015-03-27 23:26:10 +01:00
sudo yunohost app setting $app protected_regex -v "$domain_regex$pathRslash/stats$","$domain_regex$pathRslash/manifest.webapp$","$domain_regex$pathRslash/$","$domain_regex$pathRslash/d/.*$","$domain_regex$pathRslash/m/.*$"
2015-03-16 21:10:39 +01:00
fi
2015-11-18 00:28:42 +01:00
# Configure les droits d'accès au fichiers
2015-03-26 13:07:01 +01:00
sudo chown -R www-data: $final_path
# Restart lutim
sudo /etc/init.d/lutim restart
2015-11-18 00:28:42 +01:00
# Recharge la configuration Nginx
2015-03-16 21:10:39 +01:00
sudo service nginx reload
2015-11-18 00:28:42 +01:00
# Régénère la configuration de SSOwat
2015-03-16 21:10:39 +01:00
sudo yunohost app ssowatconf