|
@@ -1,7 +1,7 @@
|
|
|
#!/bin/bash
|
|
|
|
|
|
#=================================================
|
|
|
-# GENERIC STARTING
|
|
|
+# GENERIC START
|
|
|
#=================================================
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
#=================================================
|
|
@@ -10,25 +10,52 @@ source _common.sh
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
#=================================================
|
|
|
-# MANAGE SCRIPT FAILURE
|
|
|
-#=================================================
|
|
|
-
|
|
|
-# 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
|
|
|
|
|
|
domain=$(ynh_app_setting_get $app domain)
|
|
|
path_url=$(ynh_app_setting_get $app path)
|
|
|
-wifi_ssid=$(ynh_app_setting_get $app wifi_ssid)
|
|
|
-wifi_passphrase=$(ynh_app_setting_get $app wifi_passphrase)
|
|
|
-firmware_nonfree=$(ynh_app_setting_get $app firmware_nonfree)
|
|
|
final_path=$(ynh_app_setting_get $app final_path)
|
|
|
-multissid=$(ynh_app_setting_get $app multissid)
|
|
|
+firmware_nonfree=$(ynh_app_setting_get $app firmware_nonfree)
|
|
|
+packages=$(ynh_app_setting_get $app packages)
|
|
|
+
|
|
|
+#=================================================
|
|
|
+# ENSURE DOWNWARD COMPATIBILITY
|
|
|
+#=================================================
|
|
|
+ynh_print_info "Ensuring downward compatibility..."
|
|
|
+
|
|
|
+# If final_path doesn't exist, create it
|
|
|
+if [ -z $final_path ]; then
|
|
|
+ final_path=/var/www/$app
|
|
|
+ ynh_app_setting_set $app final_path $final_path
|
|
|
+fi
|
|
|
+
|
|
|
+if [ -z $packages ]; then
|
|
|
+ if [[ $firmware_nonfree -eq 1 ]]; then
|
|
|
+ packages=$nonfree_packages
|
|
|
+ else
|
|
|
+ packages=$free_packages
|
|
|
+ fi
|
|
|
+
|
|
|
+ ynh_app_setting_set $app packages $packages
|
|
|
+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
|
|
|
|
|
|
#=================================================
|
|
|
# CHECK THE PATH
|
|
@@ -38,18 +65,94 @@ multissid=$(ynh_app_setting_get $app multissid)
|
|
|
path_url=$(ynh_normalize_url_path $path_url)
|
|
|
|
|
|
#=================================================
|
|
|
+# STANDARD UPGRADE STEPS
|
|
|
+#=================================================
|
|
|
+# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
+#=================================================
|
|
|
+ynh_print_info "Upgrading source files..."
|
|
|
+
|
|
|
+# Download, check integrity, uncompress and patch the source from app.src
|
|
|
+cp -a ../sources/* ${final_path}/
|
|
|
+
|
|
|
+chown -R www-data: ${final_path}/
|
|
|
+chmod -R 0644 ${final_path}/*
|
|
|
+find ${final_path}/ -type d -exec chmod +x {} \;
|
|
|
+
|
|
|
+#=================================================
|
|
|
+# NGINX CONFIGURATION
|
|
|
+#=================================================
|
|
|
+ynh_print_info "Upgrading nginx web server configuration..."
|
|
|
+
|
|
|
+# Create a dedicated nginx config
|
|
|
+ynh_add_nginx_config
|
|
|
+
|
|
|
+#=================================================
|
|
|
+# UPGRADE DEPENDENCIES
|
|
|
+#=================================================
|
|
|
+ynh_print_info "Upgrading dependencies..."
|
|
|
+
|
|
|
+ynh_install_app_dependencies "$pkg_dependencies" "$packages"
|
|
|
+
|
|
|
+#=================================================
|
|
|
+# CREATE DEDICATED USER
|
|
|
+#=================================================
|
|
|
+ynh_print_info "Making sure dedicated system user exists..."
|
|
|
+
|
|
|
+# Create a dedicated user (if not existing)
|
|
|
+ynh_system_user_create $app
|
|
|
+
|
|
|
+#=================================================
|
|
|
+# PHP-FPM CONFIGURATION
|
|
|
+#=================================================
|
|
|
+ynh_print_info "Upgrading php-fpm configuration..."
|
|
|
+
|
|
|
+# Create a dedicated php-fpm config
|
|
|
+ynh_add_fpm_config
|
|
|
+
|
|
|
+#=================================================
|
|
|
# SPECIFIC UPGRADE
|
|
|
#=================================================
|
|
|
+# FIX CONFIGS
|
|
|
+#=================================================
|
|
|
|
|
|
-source ./prerequisites
|
|
|
+### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it.
|
|
|
+ynh_backup_if_checksum_is_different "$final_path/config.php"
|
|
|
+ynh_replace_string "__PATH__" "${path_url}" "$final_path/config.php"
|
|
|
+# Recalculate and store the checksum of the file for the next upgrade.
|
|
|
+ynh_store_file_checksum "$final_path/config.php"
|
|
|
|
|
|
-# Changes
|
|
|
+#=================================================
|
|
|
+# SETUP SYSTEMD
|
|
|
+#=================================================
|
|
|
+ynh_print_info "Upgrading systemd configuration..."
|
|
|
|
|
|
-if [[ -z $(ynh_app_setting_get $app ip6_firewall) ]]; then
|
|
|
- ip6_firewall=$(printf '1|%.0s' $(seq "${multissid}"))
|
|
|
- ip6_firewall=$(echo "${ip6_firewall%?}")
|
|
|
+# Create a dedicated systemd config
|
|
|
+ynh_add_systemd_config
|
|
|
|
|
|
- ynh_app_setting_set "${app}" ip6_firewall "${ip6_firewall}"
|
|
|
-fi
|
|
|
+#=================================================
|
|
|
+# GENERIC FINALIZATION
|
|
|
+#=================================================
|
|
|
+# SECURE FILES AND DIRECTORIES
|
|
|
+#=================================================
|
|
|
+
|
|
|
+# Set permissions on app files
|
|
|
+chown -R www-data: $final_path
|
|
|
+
|
|
|
+#=================================================
|
|
|
+# SETUP SSOWAT
|
|
|
+#=================================================
|
|
|
+ynh_print_info "Upgrading SSOwat configuration..."
|
|
|
+
|
|
|
+#=================================================
|
|
|
+# RELOAD NGINX
|
|
|
+#=================================================
|
|
|
+ynh_print_info "Reloading nginx web server..."
|
|
|
+
|
|
|
+systemctl restart php7.0-fpm
|
|
|
+systemctl reload nginx
|
|
|
+
|
|
|
+#=================================================
|
|
|
+# END OF SCRIPT
|
|
|
+#=================================================
|
|
|
|
|
|
-ynh_systemctl start ynh-hotspot
|
|
|
+ynh_print_info "Upgrade of $app completed"
|