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

69 lines
2.4 KiB
Text
Raw Normal View History

2015-03-16 21:10:39 +01:00
#!/bin/bash
2015-03-26 13:07:01 +01:00
app=lutim
2015-03-16 21:10:39 +01:00
# Retrieve arguments
2015-03-26 13:07:01 +01:00
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-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-16 21:10:39 +01:00
# Copy files to right place
2015-03-26 13:07:01 +01:00
final_path=/var/www/$app
# Décompresse la source
tar -x -f ../sources/lutim.tar.gz
sudo cp -a lutim/. "$final_path"
sudo cp -a ../sources/ajouts/. "$final_path"
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-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-03-26 13:07:01 +01:00
# Set right permissions
sudo chown -R www-data: $final_path
# Restart lutim
sudo /etc/init.d/lutim restart
2015-03-16 21:10:39 +01:00
# Reload Nginx and regenerate SSOwat conf
sudo service nginx reload
sudo yunohost app ssowatconf