1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/yourls_ynh.git synced 2024-09-03 20:35:59 +02:00
yourls_ynh/scripts/upgrade

87 lines
2.5 KiB
Text
Raw Normal View History

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_app_setting_get $app path)
admin=$(ynh_app_setting_get $app admin)
final_path=$(ynh_app_setting_get $app final_path)
db_name=$(ynh_app_setting_get $app db_name)
if [ -z $db_name ]; then # If db_name doesn't exist, create it
db_name=$(ynh_sanitize_dbid $app)
ynh_app_setting_set $app db_name $db_name
fi
#=================================================
# CHECK THE PATH
#=================================================
# Normalize the URL path syntax
path_url=$(ynh_normalize_url_path $path_url)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
sudo mv ${final_path} ${final_path}.old
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path"
sudo cp -a ${final_path}.old/index.php ${final_path}
sudo cp -a ${final_path}.old/user/plugins/yunohost_auth ${final_path}/user/plugins
sudo cp -a ${final_path}.old/.htaccess ${final_path}
sudo cp -a ${final_path}.old/user/config.php ${final_path}/user
sudo chown -R www-data: $final_path
# delete temp directory
sudo rm -Rf ${final_path}.old
#=================================================
# NGINX CONFIGURATION
#=================================================
# Create a dedicated nginx config
# Modify Nginx configuration file and copy it to Nginx conf directory
sed -i "s@LOCATIONTOCHANGE@$path_url@g" ../conf/nginx.conf*
sed -i "s@PATHTOCHANGE@${path_url%/}@g" ../conf/nginx.conf*
sed -i "s@DOMAINTOCHANGE@$domain@g" ../conf/nginx.conf*
sed -i "s@ALIASTOCHANGE@$final_path@g" ../conf/nginx.conf*
nginxconf=/etc/nginx/conf.d/$domain.d/$app.conf
sudo cp ../conf/nginx.conf $nginxconf
sudo chown root: $nginxconf
sudo chmod 600 $nginxconf
#=================================================
# SETUP SSOWAT
#=================================================
ynh_app_setting_set $app unprotected_uris "/"
#=================================================
# RELOAD NGINX
#=================================================
sudo systemctl reload nginx