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

71 lines
1.8 KiB
Text
Raw Normal View History

2015-08-23 17:57:27 +02:00
#!/bin/bash
2015-09-05 17:52:58 +02:00
# Basic variable declaration
BASEDIR="$(dirname "$(pwd)")"
# Common variable declaration
2015-08-23 17:57:27 +02:00
app_id=headphones
app_user=headphones
2015-09-05 17:52:58 +02:00
app_install_dir="/opt/yunohost/${app_id}"
app_data_dir="/home/yunohost.app/${app_id}"
app_logs_dir="/var/log/${app_id}"
## Sources definitions
app_src_init="$BASEDIR/conf/${app_id}.init"
app_src_nginx_conf="$BASEDIR/conf/nginx.conf"
# Retrieve arguments
app_public="$(sudo yunohost app setting ${app_id} public)"
app_method="$(sudo yunohost app setting ${app_id} method)"
app_domain="$(sudo yunohost app setting ${app_id} domain)"
app_path="$(sudo yunohost app setting ${app_id} path)"
app_host="$(sudo yunohost app setting ${app_id} host)"
2015-08-23 17:57:27 +02:00
# Make upgrade if localhost installation
2015-09-05 17:52:58 +02:00
if [[ $app_method == "LOCAL"* ]]; then
2015-08-23 17:57:27 +02:00
2015-09-05 17:52:58 +02:00
# Kill app
2015-08-23 17:57:27 +02:00
sudo service $app_id stop
sudo killall $app_id
2015-09-05 17:52:58 +02:00
# Upgrade to the latest version of app using the fork
2015-08-23 17:57:27 +02:00
cd $app_install_dir && sudo git pull
cd -
# Upgrade dependencies
# Update init file
2015-09-05 17:52:58 +02:00
sudo cp -a $app_src_init /etc/init.d/$app_id
2015-08-23 17:57:27 +02:00
# Set rights
sudo chown -R $app_user $app_install_dir
sudo chmod +x /etc/init.d/$app_id
sudo chmod +x -R $app_install_dir
2015-09-05 17:52:58 +02:00
# Start service
sudo service $app_id start
2015-08-23 17:57:27 +02:00
fi
2015-09-05 17:52:58 +02:00
# Remove trailing "/" for next commands
app_path=${app_path%/}
2015-08-23 17:57:27 +02:00
2015-09-05 17:52:58 +02:00
# Configure Nginx
sudo sed -i "s@PATHTOCHANGE@$app_path@g" $app_src_nginx_conf
sudo sed -i "s@HOSTTOCHANGE@$app_host@g" $app_src_nginx_conf
sudo cp $app_src_nginx_conf /etc/nginx/conf.d/$app_domain.d/$app_id.conf
# If app is public, add url to SSOWat conf as skipped_uris
if [[ $app_public = "Yes" ]];
then
# See install script
sudo yunohost app setting $app_id unprotected_uris -v "/"
# Remove old settings
sudo yunohost app setting $app_id skipped_uris -d
fi
# Reload Nginx and regenerate SSOwat conf
sudo service nginx reload
sudo yunohost app ssowatconf