1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/rss-bridge_ynh.git synced 2024-09-03 20:25:51 +02:00
rss-bridge_ynh/scripts/upgrade

99 lines
3 KiB
Text
Raw Normal View History

2017-04-26 19:01:53 +02:00
#!/bin/bash
# Exit on command errors and treat unset variables as an error
set -eu
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
# Set app specific variables
app=$YNH_APP_INSTANCE_NAME
# Check destination directory
DESTDIR="/var/www/$app"
[[ ! -d $DESTDIR ]] && ynh_die \
"The destination directory '$DESTDIR' does not exist.\
The app is not correctly installed, you should remove it first."
# Retrieve arguments
domain=$(ynh_app_setting_get "$app" domain)
path_url=$(ynh_app_setting_get "$app" path_url)
path_url=$(ynh_normalize_url_path $path_url)
final_path=$(ynh_app_setting_get "$app" final_path)
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_backup_before_upgrade # Backup the current version of the app
2017-04-26 19:01:53 +02:00
ynh_clean_setup () {
ynh_restore_upgradebackup # restore it if the upgrade fails
2017-04-26 19:01:53 +02:00
}
ynh_abort_if_errors # Active trap to stop script execution if an error occurs
2017-04-26 19:01:53 +02:00
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
# Create tmp directory and fetch app inside
TMPDIR=$(ynh_mkdir_tmp)
extract_sources "$TMPDIR"
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_system_user_create $app # Create dedicated user if not existing
#=================================================
# SPECIFIC SETUP
#=================================================
2017-08-04 23:22:29 +02:00
# Remove last version (we don't keep whitelist)
ynh_secure_remove "$final_path"
2017-04-26 19:01:53 +02:00
# Install files and set permissions
sudo mv "$TMPDIR" "$final_path"
# Set rights on directory
sudo chown -R root: $final_path
sudo chown -R $app: $final_path/cache
sudo chmod 755 $final_path
# Enable every bridge
for i in $final_path/bridges/*.php ; do
echo $(basename $i) | sed "s|Bridge.php$||g" | sudo tee -a $final_path/whitelist.txt
done
#=================================================
# NGINX CONFIGURATION
#=================================================
2019-06-09 19:21:27 +02:00
# Create a dedicated nginx config
ynh_add_nginx_config
2017-04-26 19:01:53 +02:00
# Copy and set php-fpm configuration
phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf"
ynh_replace_string "{POOLNAME}" "${app}" "$PKGDIR/conf/php-fpm.conf"
ynh_replace_string "{DESTDIR}" "${final_path}" "$PKGDIR/conf/php-fpm.conf"
ynh_replace_string "{USER}" "${app}" "$PKGDIR/conf/php-fpm.conf"
sudo cp $PKGDIR/conf/php-fpm.conf "$phpfpm_conf"
# Set SSOwat rules
ynh_app_setting_set "$app" skipped_uris "/"
#=================================================
# RELOAD NGINX
#=================================================
sudo systemctl restart php5-fpm
sudo systemctl reload nginx