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

update: ynh_print_info and backup_before_upgrade

This commit is contained in:
Kayou 2019-02-21 14:08:27 +01:00 committed by GitHub
parent c0e3a0b086
commit 7fea3f3225
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,21 +9,10 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
ynh_clean_check_starting
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
@ -42,6 +31,7 @@ hashed_password=$(ynh_app_setting_get $app hashed_password)
#=================================================
# FIX OLD THINGS
#=================================================
ynh_print_info "Ensuring downward compatibility..."
if [ "$is_public" = "Yes" ]; then
ynh_app_setting_set $app is_public 1 # Fixe is_public en booléen
@ -90,9 +80,26 @@ This password is: $password" > mail_to_send
ynh_app_setting_set $app hashed_password $hashed_password
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_print_info "Backing up the app before upgrading (may take a while)..."
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_print_info "Upgrading source files..."
ynh_install_app_dependencies build-essential libssl-dev zlib1g-dev libpng-dev libpq-dev memcached postgresql cpanminus
@ -101,15 +108,25 @@ ynh_setup_source "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_print_info "Upgrading nginx web server configuration..."
# Create a dedicated nginx config
ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_print_info "Making sure dedicated system user exists..."
# Create a dedicated user (if not existing)
ynh_system_user_create $app
#=================================================
# SPECIFIC UPGRADE
#=================================================
# SETUP LSTU
#=================================================
ynh_print_info "Upgrading lstu configuration..."
ynh_backup_if_checksum_is_different "$final_path/lstu.conf"
cp ../conf/lstu.conf.template "${final_path}/lstu.conf"
@ -140,6 +157,7 @@ chown -R www-data $final_path
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_print_info "Upgrading systemd configuration..."
# Create a dedicated systemd config
ynh_add_systemd_config
@ -155,9 +173,10 @@ popd
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_print_info "Upgrading logrotate configuration..."
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
@ -174,6 +193,7 @@ ynh_systemd_action -n $app -a reload -l "Reloaded Shortened URLs service." -p "s
#=================================================
# SETUP SSOWAT
#=================================================
ynh_print_info "Upgrading SSOwat configuration..."
# Make app public or private
ynh_app_setting_set $app unprotected_uris "/"
@ -187,6 +207,13 @@ fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_print_info "Reloading nginx web server..."
systemctl reload nginx
yunohost app ssowatconf
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Upgrade of $app completed"