mirror of
https://github.com/YunoHost-Apps/photonix_ynh.git
synced 2024-09-03 19:56:29 +02:00
180 lines
5.7 KiB
Bash
180 lines
5.7 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# LOAD SETTINGS
|
|
#=================================================
|
|
ynh_script_progression --message="Loading installation settings..." --weight=1
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
load_settings
|
|
|
|
#=================================================
|
|
# CHECK VERSION
|
|
#=================================================
|
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
|
|
|
#=================================================
|
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
|
#=================================================
|
|
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=115
|
|
|
|
# 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
|
|
#=================================================
|
|
# STOP SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Stopping systemd services..." --weight=5
|
|
|
|
stop_services
|
|
|
|
#=================================================
|
|
# CREATE DEDICATED USER
|
|
#=================================================
|
|
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
|
|
|
|
# Create a dedicated user (if not existing)
|
|
ynh_system_user_create --username=$app --home_dir="$data_path"
|
|
|
|
#=================================================
|
|
# UPGRADE DEPENDENCIES
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading dependencies..." --weight=15
|
|
|
|
ynh_install_app_dependencies $pkg_dependencies
|
|
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
then
|
|
ynh_script_progression --message="Upgrading source files..." --weight=5
|
|
|
|
ynh_secure_remove --file="$final_path"
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
ynh_setup_source --dest_dir="$final_path"
|
|
fi
|
|
|
|
set_permissions
|
|
|
|
#=================================================
|
|
# NGINX CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
|
|
|
|
# Create a dedicated NGINX config
|
|
ynh_add_nginx_config
|
|
|
|
#=================================================
|
|
# SPECIFIC UPGRADE
|
|
#=================================================
|
|
# YUNOHOST MULTIMEDIA INTEGRATION
|
|
#=================================================
|
|
ynh_script_progression --message="Adding multimedia directories..." --weight=1
|
|
|
|
# Build YunoHost multimedia directories
|
|
ynh_multimedia_build_main_dir
|
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
then
|
|
#=================================================
|
|
# PATCH FILES
|
|
#=================================================
|
|
ynh_script_progression --message="Patching files..." --weight=70
|
|
|
|
patch_files
|
|
|
|
#=================================================
|
|
# BUILD DJANGO BACKEND
|
|
#=================================================
|
|
ynh_script_progression --message="Configuring Django backend..." --weight=150
|
|
|
|
build_django_backend
|
|
|
|
#=================================================
|
|
# BUILD NODE FRONTEND
|
|
#=================================================
|
|
ynh_script_progression --message="Building Node.js frontend..." --weight=120
|
|
|
|
build_node_frontend
|
|
fi
|
|
|
|
#=================================================
|
|
# UPDATE A CONFIGURATION
|
|
#=================================================
|
|
|
|
add_envfile
|
|
|
|
#=================================================
|
|
# APPLY DB MIGRATIONS
|
|
#=================================================
|
|
ynh_script_progression --message="Applying database migrations..." --weight=5
|
|
|
|
apply_db_migrations
|
|
|
|
#=================================================
|
|
# SETUP SYSTEMD
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading systemd configuration..." --weight=10
|
|
|
|
# Create a dedicated systemd config
|
|
add_systemd_configs
|
|
|
|
#=================================================
|
|
# GENERIC FINALIZATION
|
|
#=================================================
|
|
# SETUP LOGROTATE
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
|
|
|
|
# Use logrotate to manage app-specific logfiles
|
|
set_up_logrotate
|
|
|
|
#=================================================
|
|
# INTEGRATE SERVICES IN YUNOHOST
|
|
#=================================================
|
|
ynh_script_progression --message="Integrating services in YunoHost..." --weight=1
|
|
|
|
integrate_services
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Starting systemd services..." --weight=1
|
|
|
|
start_services
|
|
|
|
#=================================================
|
|
# RELOAD NGINX
|
|
#=================================================
|
|
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|