mirror of
https://github.com/YunoHost-Apps/yunorunner_ynh.git
synced 2024-09-03 20:36:13 +02:00
Apply example_ynh to upgrade
This commit is contained in:
parent
427b54c949
commit
cd9e0d02d2
1 changed files with 34 additions and 13 deletions
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC STARTING
|
# GENERIC START
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Loading installation settings..."
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
@ -29,6 +30,7 @@ upgrade_type=$(ynh_check_app_version_changed)
|
||||||
#=================================================
|
#=================================================
|
||||||
# ENSURE DOWNWARD COMPATIBILITY
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Ensuring downward compatibility..."
|
||||||
|
|
||||||
# If port doesn't exist, create it
|
# If port doesn't exist, create it
|
||||||
if [ -z "$port" ]; then
|
if [ -z "$port" ]; then
|
||||||
|
@ -39,6 +41,7 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# 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
|
# Backup the current version of the app
|
||||||
ynh_backup_before_upgrade
|
ynh_backup_before_upgrade
|
||||||
|
@ -53,7 +56,8 @@ ynh_abort_if_errors
|
||||||
# CHECK THE PATH
|
# CHECK THE PATH
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
path_url=$(ynh_normalize_url_path $path_url) # Vérifie et corrige la syntaxe du path.
|
# Normalize the URL path syntax
|
||||||
|
path_url=$(ynh_normalize_url_path $path_url)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ACTIVATE MAINTENANCE MODE
|
# ACTIVATE MAINTENANCE MODE
|
||||||
|
@ -66,29 +70,38 @@ ynh_maintenance_mode_ON
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Upgrading source files..."
|
||||||
|
|
||||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
then
|
then
|
||||||
ynh_setup_source "$final_path" # Télécharge la source, décompresse et copie dans $final_path
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
|
ynh_setup_source "$final_path"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# UPGRADE DEPENDENCIES
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_install_app_dependencies python-virtualenv sqlite3 zlib1g-dev
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Upgrading nginx configuration..."
|
||||||
|
|
||||||
|
# Create a dedicated nginx config
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# UPGRADE DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info "Upgrading dependencies..."
|
||||||
|
|
||||||
|
ynh_install_app_dependencies python-virtualenv sqlite3 zlib1g-dev
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Making sure dedicated system user exists..."
|
||||||
|
|
||||||
|
# Create a dedicated user (if not existing)
|
||||||
|
ynh_system_user_create $app
|
||||||
|
|
||||||
ynh_system_user_create $app # Create the dedicated user, if not exist
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC UPGRADE
|
# SPECIFIC UPGRADE
|
||||||
|
@ -108,17 +121,18 @@ ynh_store_file_checksum "/etc/systemd/system/$app.service"
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALISATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
#=================================================
|
# SECURE FILES AND DIRECTORIES
|
||||||
# SECURING FILES AND DIRECTORIES
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
# Set permissions on app files
|
||||||
chown -R $app:root $final_path
|
chown -R $app:root $final_path
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Upgrading SSOwat configuration..."
|
||||||
|
|
||||||
# Make app public
|
# Make app public
|
||||||
ynh_app_setting_set $app skipped_uris "/"
|
ynh_app_setting_set $app skipped_uris "/"
|
||||||
|
@ -126,6 +140,7 @@ ynh_app_setting_set $app skipped_uris "/"
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Reloading nginx..."
|
||||||
|
|
||||||
ynh_system_reload --service_name=nginx
|
ynh_system_reload --service_name=nginx
|
||||||
|
|
||||||
|
@ -141,3 +156,9 @@ ynh_system_reload --service_name=$app --action=restart
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_maintenance_mode_OFF
|
ynh_maintenance_mode_OFF
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_print_info "Upgrade of $app completed"
|
||||||
|
|
Loading…
Reference in a new issue