1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/yunorunner_ynh.git synced 2024-09-03 20:36:13 +02:00

package upgrade

This commit is contained in:
ericgaspar 2021-01-06 11:55:46 +01:00
parent ffddcc0579
commit 9366dc6517
No known key found for this signature in database
GPG key ID: 574F281483054D44
9 changed files with 97 additions and 139 deletions

View file

@ -15,21 +15,8 @@
upgrade=1 from_commit=04cb5f0ec18def9d50fa861c16d491275843b9e7
backup_restore=1
multi_instance=1
incorrect_path=1
port_already_use=1 (4242)
change_url=1
;;; Levels
Level 1=auto
Level 2=auto
Level 3=auto
# Level 4: No users management
Level 4=na
Level 5=auto
Level 6=auto
Level 7=auto
Level 8=0
Level 9=0
Level 10=0
;;; Options
Email=
Notification=down

View file

@ -14,7 +14,7 @@
"email": "maniackc_dev@crudelis.fr"
},
"requirements": {
"yunohost": ">= 3.1.0"
"yunohost": ">= 3.8.1"
},
"multi_instance": true,
"services": [

View file

@ -1,5 +1,12 @@
#!/bin/bash
#=================================================
# COMMON VARIABLES
#=================================================
# dependencies used by the app
pkg_dependencies="python-virtualenv sqlite3 libssl-dev zlib1g-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev"
#=================================================
# EXPERIMENTAL HELPERS
#=================================================

View file

@ -27,29 +27,29 @@ final_path=$(ynh_app_setting_get $app final_path)
domain=$(ynh_app_setting_get $app domain)
#=================================================
# STANDARD BACKUP STEPS
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_print_info "Backing up the main app directory..."
ynh_backup "$final_path"
ynh_backup --src_path="$final_path"
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_print_info "Backing up nginx configuration..."
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP SYSTEMD
#=================================================
ynh_print_info "Backing up systemd configuration..."
ynh_backup "/etc/systemd/system/$app.service"
ynh_backup --src_path="/etc/systemd/system/$app.service"
#=================================================
# END OF SCRIPT

View file

@ -24,7 +24,7 @@ app=$YNH_APP_INSTANCE_NAME
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Loading installation settings..."
ynh_script_progression --message="Loading installation settings..."
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get $app final_path)
@ -76,7 +76,7 @@ ynh_abort_if_errors
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_print_info "Updating nginx configuration..."
ynh_script_progression --message="Updating NGINX configuration..."
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
@ -113,7 +113,7 @@ fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_print_info "Reloading nginx..."
ynh_script_progression --message="Reloading NGINX..."
ynh_system_reload --service_name=nginx
@ -129,4 +129,4 @@ ynh_maintenance_mode_OFF
# END OF SCRIPT
#=================================================
ynh_print_info "Change of url completed for $app"
ynh_script_progression --message="Change of URL completed for $app"

View file

@ -37,9 +37,6 @@ ynh_print_info "Validating installation parameters..."
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder"
# Normalize the url path syntax
path_url=$(ynh_normalize_url_path $path_url)
# Register (book) web path
ynh_webpath_register $app $domain $path_url
@ -56,7 +53,7 @@ ynh_app_setting_set $app path $path_url
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_print_info "Configuring firewall..."
ynh_script_progression --message="Configuring firewall..."
# Find a free port
port=$(ynh_find_port 4242)
@ -67,23 +64,23 @@ ynh_app_setting_set $app port $port
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_print_info "Installing dependencies..."
ynh_script_progression --message="Installing dependencies..."
ynh_install_app_dependencies python-virtualenv sqlite3 libssl-dev zlib1g-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_print_info "Setting up source files..."
ynh_script_progression --message="Setting up source files..."
ynh_app_setting_set $app final_path $final_path
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src
git clone https://github.com/YunoHost/yunorunner "$final_path"
git clone https://github.com/YunoHost/yunorunner --dest_dir="$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_print_info "Configuring nginx..."
ynh_script_progression --message="Configuring nginx..."
# Create a dedicated nginx config
ynh_add_nginx_config
@ -91,11 +88,10 @@ ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_print_info "Configuring system user..."
ynh_script_progression --message="Configuring system user..."
# Create a system user
ynh_system_user_create $app
ynh_system_user_create --username=$app
#=================================================
# SPECIFIC SETUP
@ -117,14 +113,14 @@ python $final_path/.pythonz/pythonz_install.py
# fi
# Install Python 3.6.6
$final_path/.pythonz/bin/pythonz install 3.6.6
$final_path/.pythonz/bin/pythonz install 3.7.3
#=================================================
# INSTALL YUNORUNNER DEPENDENCIES
#=================================================
pushd $final_path
virtualenv -p $($final_path/.pythonz/bin/pythonz locate 3.6.6) ve3
virtualenv -p $($final_path/.pythonz/bin/pythonz locate 3.7.3) ve3
ve3/bin/pip3 install -r requirements-frozen.txt
#Fix current websocket version error (2019-02-14)
ve3/bin/pip3 uninstall -y websockets
@ -134,7 +130,7 @@ popd
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_print_info "Configuring a systemd service..."
ynh_script_progression --message="Configuring a systemd service..."
# Create a dedicated systemd config
ynh_add_systemd_config
@ -143,7 +139,7 @@ ynh_add_systemd_config
# CHANGE PORT IN YUNORUNNER
#=================================================
ynh_replace_string "__PORT__" "$port" "/etc/systemd/system/$app.service"
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="/etc/systemd/system/$app.service"
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "/etc/systemd/system/$app.service"
systemctl daemon-reload
@ -161,22 +157,7 @@ chown -R $app:root $final_path
# ENABLE SERVICE IN ADMIN PANEL
#=================================================
yunohost service add $app --description "$app daemon for YunoRunner"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_print_info "Configuring SSOwat..."
# Make app public
ynh_app_setting_set $app skipped_uris "/"
#=================================================
# RELOAD NGINX
#=================================================
ynh_print_info "Reloading nginx..."
ynh_system_reload --service_name=nginx
yunohost service add $app --description="$app daemon for YunoRunner"
#=================================================
# START YUNORUNNER
@ -184,8 +165,26 @@ ynh_system_reload --service_name=nginx
ynh_system_reload --service_name=$app --action=start
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring SSOwat..."
# Make app public if necessary or protect it
if [ $is_public -eq 1 ]
then
ynh_permission_update --permission "main" --add "visitors"
fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx..."
ynh_system_reload --service_name=nginx
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Installation of $app completed"
ynh_script_progression --message="Installation of $app completed"

View file

@ -12,13 +12,13 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Loading installation settings..."
ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
port=$(ynh_app_setting_get $app port)
final_path=$(ynh_app_setting_get $app final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# STANDARD REMOVE
@ -26,26 +26,24 @@ final_path=$(ynh_app_setting_get $app final_path)
# REMOVE SERVICE FROM ADMIN PANEL
#=================================================
# Remove a service from the admin panel, added by `yunohost service add`
if yunohost service status | grep -q $app
if ynh_exec_warn_less yunohost service status $app >/dev/null
then
ynh_print_info "Removing $app service"
ynh_script_progression --message="Removing $app service integration..."
yunohost service remove $app
fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_print_info "Stopping and removing the service"
ynh_script_progression --message="Stopping and removing the service..."
# Remove the dedicated systemd config
ynh_remove_systemd_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_print_info "Removing dependencies"
ynh_script_progression --message="Removing dependencies..."
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
@ -53,7 +51,7 @@ ynh_remove_app_dependencies
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_print_info "Removing app main directory"
ynh_script_progression --message="Removing app main directory..."
# Remove the app directory securely
ynh_secure_remove "$final_path"
@ -61,33 +59,23 @@ ynh_secure_remove "$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_print_info "Removing nginx configuration"
ynh_script_progression --message="Removing NGINX configuration..."
# Remove the dedicated nginx config
ynh_remove_nginx_config
#=================================================
# CLOSE A PORT
#=================================================
if yunohost firewall list | grep -q "\- $port$"
then
ynh_print_info "Closing port $port"
ynh_exec_warn_less yunohost firewall disallow TCP $port
fi
#=================================================
# GENERIC FINALISATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_print_info "Removing the dedicated system user"
ynh_script_progression --message="Removing the dedicated system user..."
# Delete a system user
ynh_system_user_delete $app
ynh_system_user_delete --username=$app
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Removal of $app completed"
ynh_script_progression --message="Removal of $app completed"

View file

@ -19,7 +19,7 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Loading settings..."
ynh_script_progression --message="Loading settings..."
app=$YNH_APP_INSTANCE_NAME
@ -30,7 +30,7 @@ final_path=$(ynh_app_setting_get $app final_path)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_print_info "Validating restoration parameters..."
ynh_script_progression --message="Validating restoration parameters..."
ynh_webpath_available $domain $path_url \
|| ynh_die "Path not available: ${domain}${path_url}"
@ -54,14 +54,14 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_print_info "Restore the app main directory..."
ynh_script_progression --message="Restore the app main directory..."
ynh_restore_file "$final_path"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_print_info "Recreate the dedicated systen user..."
ynh_script_progression --message="Recreate the dedicated systen user..."
# Create the dedicated user (if not existing)
ynh_system_user_create $app
@ -78,32 +78,31 @@ chown -R $app:root $final_path
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_print_info "Reinstall dependencies..."
ynh_script_progression --message="Reinstall dependencies..."
# Define and install dependencies
ynh_install_app_dependencies python-virtualenv sqlite3 libssl-dev zlib1g-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_print_info "Restoring the systemd configuration..."
ynh_script_progression --message="Restoring the systemd configuration..."
ynh_restore_file "/etc/systemd/system/$app.service"
systemctl enable $app.service
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
# ENABLE SERVICE IN ADMIN PANEL
#=================================================
yunohost service add $app --description "$app daemon for YunoRunner"
yunohost service add $app --description="$app daemon for YunoRunner"
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX
#=================================================
ynh_print_info "Reloading nginx"
ynh_script_progression --message="Reloading NGINX"
ynh_system_reload --service_name=nginx
@ -123,4 +122,4 @@ ynh_maintenance_mode_OFF
# END OF SCRIPT
#=================================================
ynh_print_info "Restoration completed for $app"
ynh_script_progression --message="Restoration completed for $app"

View file

@ -12,14 +12,14 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Loading installation settings..."
ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_app_setting_get $app path)
final_path=$(ynh_app_setting_get $app final_path)
port=$(ynh_app_setting_get $app port)
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================
# CHECK VERSION
@ -30,28 +30,18 @@ upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_print_info "Ensuring downward compatibility..."
ynh_script_progression --message="Ensuring downward compatibility..."
# If port doesn't exist, create it
if [ -z "$port" ]; then
port=4242
ynh_app_setting_set $app port $port
fi
#=================================================
# CLOSE A PORT
#=================================================
if yunohost firewall list | grep -q "\- $port$"
then
ynh_print_info "Closing port $port"
ynh_exec_warn_less yunohost firewall disallow TCP $port
ynh_app_setting_set --app=$app --key=port --value=$port
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_print_info "Backing up the app before upgrading... (may take a while)"
ynh_script_progression --message="Backing up the app before upgrading... (may take a while)"
# Backup the current version of the app
ynh_backup_before_upgrade
@ -62,13 +52,6 @@ ynh_clean_setup () {
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# CHECK THE PATH
#=================================================
# Normalize the URL path syntax
path_url=$(ynh_normalize_url_path $path_url)
#=================================================
# ACTIVATE MAINTENANCE MODE
#=================================================
@ -80,17 +63,17 @@ ynh_maintenance_mode_ON
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_print_info "Upgrading source files..."
ynh_script_progression --message="Upgrading source files..."
pushd "$final_path"
git fetch
git reset --hard origin/master
git fetch
git reset --hard origin/master
popd
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_print_info "Upgrading nginx configuration..."
ynh_script_progression --message="Upgrading NGINX configuration..."
# Create a dedicated nginx config
ynh_add_nginx_config
@ -98,19 +81,17 @@ ynh_add_nginx_config
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_print_info "Upgrading dependencies..."
ynh_install_app_dependencies python-virtualenv sqlite3 zlib1g-dev
ynh_script_progression --message="Upgrading dependencies..."
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_print_info "Making sure dedicated system user exists..."
ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing)
ynh_system_user_create $app
ynh_system_user_create --username=$app
#=================================================
# SPECIFIC UPGRADE
@ -125,7 +106,7 @@ echo -e "\e[93m\e[1m[WARN]\e[0m Please have a look to the diff of your systemd c
# CHANGE PORT IN YUNORUNNER
#=================================================
ynh_replace_string "__PORT__" "$port" "/etc/systemd/system/$app.service"
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="/etc/systemd/system/$app.service"
ynh_store_file_checksum "/etc/systemd/system/$app.service"
systemctl daemon-reload
@ -149,17 +130,15 @@ popd
chown -R $app:root $final_path
#=================================================
# SETUP SSOWAT
# ENABLE SERVICE IN ADMIN PANEL
#=================================================
ynh_print_info "Upgrading SSOwat configuration..."
# Make app public
ynh_app_setting_set $app skipped_uris "/"
yunohost service add $app --description="$app daemon for YunoRunner"
#=================================================
# RELOAD NGINX
#=================================================
ynh_print_info "Reloading nginx..."
ynh_script_progression --message="Reloading NGINX..."
ynh_system_reload --service_name=nginx
@ -169,7 +148,6 @@ ynh_system_reload --service_name=nginx
ynh_system_reload --service_name=$app --action=restart
#=================================================
# DEACTIVE MAINTENANCE MODE
#=================================================
@ -180,4 +158,4 @@ ynh_maintenance_mode_OFF
# END OF SCRIPT
#=================================================
ynh_print_info "Upgrade of $app completed"
ynh_script_progression --message="Upgrade of $app completed"