diff --git a/README.md b/README.md index 2a5c898..ff5983f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,6 @@ > *This package allows you to install Funkwhale quickly and simply on a YunoHost server. If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* - ## Overview A modern, convivial and free music server on YunoHost diff --git a/check_process b/check_process index cf0baa7..b0e4657 100644 --- a/check_process +++ b/check_process @@ -22,32 +22,10 @@ incorrect_path=0 port_already_use=0 change_url=0 -;;; Levels - ;;; Options Email=cda@rootkey.co.uk Notification=all ;;; Upgrade options - ; commit=80a5044d13a6782063fee2d7fb7a01832a6aa767 - name=Upgrade from 0.16.3 -manifest_arg=domain=DOMAIN&path=/&admin=USER&is_public=1 - ; commit=806bcb0f320d8e3e28711a9ae1d2b175b95c65ce - name=Upgrade from 0.17.0~ynh2 -manifest_arg=domain=DOMAIN&path=/&admin=USER&is_public=1 - ; commit=99bae16efca321ce50ba9a98c62996169195e0ba - name=Upgrade from 0.18.3 -manifest_arg=domain=DOMAIN&path=/&admin=USER&is_public=1 ; commit=4d4bf0981e2d3a00eaae6b19bd54344fe55d6530 - name=Upgrade from 0.19.1 -manifest_arg=domain=DOMAIN&path=/&admin=USER&is_public=1 - ; commit=4d4bf0981e2d3a00eaae6b19bd54344fe55d6530 - name=Upgrade from 0.20.1 -manifest_arg=domain=DOMAIN&path=/&admin=USER&is_public=1 - ; commit=18dd9d6a59ad1f0d03dc634b20e805b5c4f6c6e9 - name=Upgrade from 0.21 -manifest_arg=domain=DOMAIN&path=/&admin=USER&is_public=1 - ; commit=5fe8d545994eed02707ed0133a68db919bd5d3bb - name=Upgrade from 0.21.1 -manifest_arg=domain=DOMAIN&path=/&admin=USER&is_public=1 - ; commit=65d4541750648436b5dc9dd2e7ba63a0bd8d1af1 - name=Upgrade from 1.0 + name=Upgrade to 0.19.1 and fix channels-redis bug + manifest_arg=domain=DOMAIN&path=/&admin=USER&is_public=1 diff --git a/scripts/backup b/scripts/backup index d8a772f..3c0c590 100644 --- a/scripts/backup +++ b/scripts/backup @@ -32,11 +32,13 @@ domain=$(ynh_app_setting_get --app="$app" --key=domain) db_name=$(ynh_app_setting_get --app="$app" --key=db_name) #================================================= -# 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 --message="Backing up the main app directory..." backup_core_only=$(ynh_app_setting_get --app="$app" --key=backup_core_only) # If backup_core_only have any value in the settings.yml file, do not backup the data directory @@ -51,7 +53,6 @@ fi #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_print_info --message="Backing up nginx web server configuration..." ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/nginx/conf.d/$domain.conf" @@ -68,7 +69,6 @@ ynh_psql_dump_db --database="$db_name" > db.sql #================================================= # BACKUP SYSTEMD #================================================= -ynh_print_info --message="Backing up systemd configuration..." ynh_backup --src_path="/etc/systemd/system/$app-beat.service" ynh_backup --src_path="/etc/systemd/system/$app-server.service" diff --git a/scripts/install b/scripts/install index c0a1315..66a3806 100644 --- a/scripts/install +++ b/scripts/install @@ -33,7 +33,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_print_info --message="Validating installation parameters..." +ynh_script_progression --message="Validating installation parameters..." final_path="/var/www/$app" test ! -e "$final_path" || ynh_die --message="This path already contains a folder" @@ -44,7 +44,7 @@ ynh_webpath_register --app="$app" --domain="$domain" --path_url="$path_url" #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_print_info --message="Storing installation settings..." +ynh_script_progression --message="Storing installation settings..." ynh_app_setting_set --app="$app" --key=domain --value="$domain" ynh_app_setting_set --app="$app" --key=path --value="$path_url" @@ -56,7 +56,7 @@ ynh_app_setting_set --app="$app" --key=admin --value="$admin" #================================================= # FIND AND OPEN A PORT #================================================= -ynh_print_info --message="Configuring firewall..." +ynh_script_progression --message="Configuring firewall..." # Find a free port port=$(ynh_find_port --port=5000) @@ -66,14 +66,14 @@ ynh_app_setting_set --app="$app" --key=port --value="$port" #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_print_info --message="Installing dependencies..." +ynh_script_progression --message="Installing dependencies..." ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE A POSTGRESQL DATABASE #================================================= -ynh_print_info --message="Creating a PostgreSQL database..." +ynh_script_progression --message="Creating a PostgreSQL database..." ynh_psql_test_if_first_run @@ -89,7 +89,7 @@ ynh_psql_setup_db --db_name="$db_name" --db_user="$db_user" --db_pwd="$db_pwd" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_print_info --message="Setting up source files..." +ynh_script_progression --message="Setting up source files..." ynh_app_setting_set --app="$app" --key=final_path --value="$final_path" # Download, check integrity, uncompress and patch the source from app.src @@ -104,7 +104,7 @@ ynh_setup_source --dest_dir="$final_path/code" --source_id="app-frontend" #================================================= # NGINX CONFIGURATION #================================================= -ynh_print_info --message="Configuring nginx web server..." +ynh_script_progression --message="Configuring nginx web server..." # Create a dedicated nginx config ynh_add_nginx_config @@ -112,7 +112,7 @@ ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= -ynh_print_info --message="Configuring system user..." +ynh_script_progression --message="Configuring system user..." # Create a system user ynh_system_user_create --username="$app" --home_dir="$final_path" @@ -179,7 +179,7 @@ admin_mail=$(ynh_user_get_info --username="$admin" --key="mail") #================================================= # SETUP SYSTEMD #================================================= -ynh_print_info --message="Configuring a systemd service..." +ynh_script_progression --message="Configuring a systemd service..." cp ../conf/funkwhale.target "/etc/systemd/system/$app.target" ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="/etc/systemd/system/$app.target" @@ -212,14 +212,14 @@ chown -R "$app": "/var/log/$app" # ADVERTISE SERVICE IN ADMIN PANEL #================================================= -yunohost service add "$app-server" --log "/var/log/$app/server.log" -yunohost service add "$app-worker" --log "/var/log/$app/worker.log" -yunohost service add "$app-beat" --log "/var/log/$app/beat.log" +yunohost service add "$app-server" --log="/var/log/$app/server.log" +yunohost service add "$app-worker" --log="/var/log/$app/worker.log" +yunohost service add "$app-beat" --log="/var/log/$app/beat.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_print_info --message="Starting a systemd service..." +ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --action="start" --service_name="${app}-beat" ynh_systemd_action --action="start" --service_name="${app}-server" @@ -228,7 +228,7 @@ ynh_systemd_action --action="start" --service_name="${app}-worker" #================================================= # SETUP FAIL2BAN #================================================= -ynh_print_info --message="Configuring fail2ban..." +ynh_script_progression --message="Configuring Fail2Ban..." # Create a dedicated fail2ban config ynh_add_fail2ban_config --logpath="/var/log/nginx/$domain-access.log" --failregex=".* \"POST /api/v1/token/ HTTP/1.1\" 400 68.*$" --max_retry=5 @@ -236,7 +236,7 @@ ynh_add_fail2ban_config --logpath="/var/log/nginx/$domain-access.log" --failrege #================================================= # SETUP SSOWAT #================================================= -ynh_print_info --message="Configuring SSOwat..." +ynh_script_progression --message="Configuring SSOwat..." # Make app public if necessary if [ "$is_public" -eq 1 ] @@ -248,7 +248,7 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_print_info --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -256,4 +256,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_print_info --message="Installation of $app completed" +ynh_script_progression --message="Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index 8cd36d7..0567cde 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -32,26 +32,26 @@ redis_db=$(ynh_app_setting_get --app="$app" --key=redis_db) # Remove a service from the admin panel, added by `yunohost service add` if yunohost service status "$app-server" >/dev/null 2>&1 then - ynh_print_info --message="Remove $app-server service" + ynh_script_progression --message="Remove $app-server service" yunohost service remove "$app-server" fi if yunohost service status "$app-worker" >/dev/null 2>&1 then - ynh_print_info --message="Remove $app-worker service" + ynh_script_progression --message="Remove $app-worker service" yunohost service remove "$app-worker" fi if yunohost service status "$app-beat" >/dev/null 2>&1 then - ynh_print_info --message="Remove $app-beat service" + ynh_script_progression --message="Remove $app-beat service" yunohost service remove "$app-beat" fi #================================================= # STOP AND REMOVE SERVICE #================================================= -ynh_print_info --message="Stopping and removing the systemd service" +ynh_script_progression --message="Stopping and removing the systemd service" ynh_systemd_action --action="stop" --service_name="${app}-beat" ynh_systemd_action --action="stop" --service_name="${app}-server" @@ -67,7 +67,7 @@ ynh_secure_remove --file="/etc/systemd/system/$app.target" #================================================= # REMOVE THE POSTGRESQL DATABASE #================================================= -ynh_print_info --message="Removing the PostgreSQL database" +ynh_script_progression --message="Removing the PostgreSQL database" # Remove a database if it exists, along with the associated user ynh_psql_remove_db --db_name="$db_name" --db_user="$db_user" @@ -75,7 +75,7 @@ ynh_psql_remove_db --db_name="$db_name" --db_user="$db_user" #================================================= # REMOVE THE REDIS DATABASE #================================================= -ynh_print_info --message="Removing the Redis database" +ynh_script_progression --message="Removing the Redis database" # Remove a database if it exists, along with the associated user ynh_redis_remove_db "$redis_db" @@ -83,7 +83,7 @@ ynh_redis_remove_db "$redis_db" #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_print_info --message="Removing dependencies" +ynh_script_progression --message="Removing dependencies" # Remove metapackage and its dependencies ynh_remove_app_dependencies @@ -91,7 +91,7 @@ ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_print_info --message="Removing app main directory" +ynh_script_progression --message="Removing app main directory" # Remove the app directory securely ynh_secure_remove --file="$final_path" @@ -101,25 +101,15 @@ ynh_secure_remove --file="/var/log/$app" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_print_info --message="Removing nginx web server configuration" +ynh_script_progression --message="Removing NGINX web server configuration" # Remove the dedicated nginx config ynh_remove_nginx_config -#================================================= -# CLOSE A PORT -#================================================= - -if yunohost firewall list | grep -q "\- $port$" -then - ynh_print_info --message="Closing port $port" - ynh_exec_warn_less yunohost firewall disallow TCP $port -fi - #================================================= # REMOVE FAIL2BAN CONFIGURATION #================================================= -ynh_print_info --message="Removing fail2ban configuration..." +ynh_script_progression --message="Removing Fail2Ban configuration..." ynh_remove_fail2ban_config @@ -128,7 +118,7 @@ ynh_remove_fail2ban_config #================================================= # REMOVE DEDICATED USER #================================================= -ynh_print_info --message="Removing the dedicated system user" +ynh_script_progression --message="Removing the dedicated system user" # Delete a system user ynh_system_user_delete --username="$app" @@ -137,4 +127,4 @@ ynh_system_user_delete --username="$app" # END OF SCRIPT #================================================= -ynh_print_info --message="Removal of $app completed" +ynh_script_progression --message="Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index b6d7507..7802232 100644 --- a/scripts/restore +++ b/scripts/restore @@ -23,7 +23,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading settings..." +ynh_script_progression --message="Loading settings..." app=$YNH_APP_INSTANCE_NAME @@ -37,7 +37,7 @@ db_pwd=$(ynh_app_setting_get --app="$app" --key=psqlpwd) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_print_info --message="Validating restoration parameters..." +ynh_script_progression --message="Validating restoration parameters..." ynh_webpath_available --domain="$domain" --path_url="$path_url" \ || ynh_die --message="Path not available: ${domain}${path_url}" @@ -56,7 +56,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_print_info --message="Restoring the app main directory..." +ynh_script_progression --message="Restoring the app main directory..." backup_core_only=$(ynh_app_setting_get --app="$app" --key=backup_core_only) @@ -86,7 +86,7 @@ fi #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_print_info --message="Recreating the dedicated system user..." +ynh_script_progression --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) ynh_system_user_create --username="$app" --home_dir="$final_path" @@ -107,7 +107,7 @@ chown -R "$app": "/var/log/$app" #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_print_info --message="Reinstalling dependencies..." +ynh_script_progression --message="Reinstalling dependencies..." # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies @@ -115,7 +115,7 @@ ynh_install_app_dependencies $pkg_dependencies #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= -ynh_print_info --message="Restoring the PostgreSQL database..." +ynh_script_progression --message="Restoring the PostgreSQL database..." ynh_psql_test_if_first_run ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" --db_pwd="$db_pwd" @@ -124,7 +124,7 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name" #================================================= # RESTORE SYSTEMD #================================================= -ynh_print_info --message="Restoring the systemd configuration..." +ynh_script_progression --message="Restoring the systemd configuration..." ynh_restore_file --origin_path="/etc/systemd/system/$app-beat.service" ynh_restore_file --origin_path="/etc/systemd/system/$app-server.service" @@ -139,14 +139,14 @@ systemctl enable "$app-worker.service" --quiet # ADVERTISE SERVICE IN ADMIN PANEL #================================================= -yunohost service add "$app-server" --log "/var/log/$app/server.log" -yunohost service add "$app-worker" --log "/var/log/$app/worker.log" -yunohost service add "$app-beat" --log "/var/log/$app/beat.log" +yunohost service add "$app-server" --log="/var/log/$app/server.log" +yunohost service add "$app-worker" --log="/var/log/$app/worker.log" +yunohost service add "$app-beat" --log="/var/log/$app/beat.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_print_info --message="Starting a systemd service..." +ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --action="start" --service_name="${app}-beat" ynh_systemd_action --action="start" --service_name="${app}-server" @@ -157,7 +157,7 @@ ynh_systemd_action --action="start" --service_name="${app}-worker" #================================================= # RELOAD NGINX #================================================= -ynh_print_info --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -165,4 +165,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_print_info --message="Restoration completed for $app" +ynh_script_progression --message="Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index c51acb9..890fe04 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -30,7 +30,7 @@ code_migration=$(ynh_app_setting_get --app="$app" --key=code_migration) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_print_info --message="Ensuring downward compatibility..." +ynh_script_progression --message="Ensuring downward compatibility..." # If redis_db doesn't exist, create it if [ -z "$redis_db" ]; then @@ -55,7 +55,7 @@ fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_print_info --message="Backing up the app before upgrading (may take a while)..." +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." # Inform the backup/restore process that it should not save the data directory ynh_app_setting_set --app="$app" --key=backup_core_only --value=1 @@ -74,35 +74,18 @@ ynh_abort_if_errors # CHECK THE PATH #================================================= -# Normalize the URL path syntax -path_url=$(ynh_normalize_url_path "$path_url") - -#================================================= -# CHECK THE PATH -#================================================= - # see 0.20.0: https://docs.funkwhale.audio/changelog.html#automatically-load-env-file loadfile="$final_path/code/load_env" if [ -e "$loadfile" ] ; then ynh_secure_remove --file="$loadfile" fi -#================================================= -# CLOSE A PORT -#================================================= - -if yunohost firewall list | grep -q "\- $port$" -then - echo "Close port $port" - yunohost firewall disallow TCP $port 2>&1 -fi - #================================================= # STANDARD UPGRADE STEPS #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_print_info --message="Stopping a systemd service..." +ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --action="stop" --service_name="${app}-beat" ynh_systemd_action --action="stop" --service_name="${app}-server" @@ -111,7 +94,7 @@ ynh_systemd_action --action="stop" --service_name="${app}-worker" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_print_info --message="Upgrading source files..." +ynh_script_progression --message="Upgrading source files..." ynh_app_setting_set --app="$app" --key=final_path --value="$final_path" # Download, check integrity, uncompress and patch the source from app.src @@ -126,22 +109,22 @@ ynh_setup_source --dest_dir="$final_path/code" --source_id="app-frontend" #================================================= # NGINX CONFIGURATION #================================================= -ynh_print_info --message="Upgrading nginx web server configuration..." +ynh_script_progression --message="Upgrading NGINX web server configuration..." -# Create a dedicated nginx config +# Create a dedicated NGINX config ynh_add_nginx_config #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_print_info --message="Upgrading dependencies..." +ynh_script_progression --message="Upgrading dependencies..." ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE DEDICATED USER #================================================= -ynh_print_info --message="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 --username="$app" --home_dir="$final_path" @@ -234,7 +217,7 @@ ynh_store_file_checksum --file="$configfile" #================================================= # SETUP SYSTEMD #================================================= -ynh_print_info --message="Upgrading systemd configuration..." +ynh_script_progression --message="Upgrading systemd configuration..." cp ../conf/funkwhale.target "/etc/systemd/system/$app.target" ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="/etc/systemd/system/$app.target" @@ -249,7 +232,7 @@ ynh_add_systemd_config --service="$app-beat" --template="funkwhale-beat.servic #================================================= # UPGRADE FAIL2BAN #================================================= -ynh_print_info --message="Reconfiguring fail2ban..." +ynh_script_progression --message="Reconfiguring Fail2Ban..." ynh_add_fail2ban_config --logpath="/var/log/nginx/$domain-access.log" --failregex=".* \"POST /api/v1/token/ HTTP/1.1\" 400 68.*$" --max_retry=5 @@ -267,14 +250,14 @@ chown -R "$app": "/var/log/$app" # ADVERTISE SERVICE IN ADMIN PANEL #================================================= -yunohost service add "$app-server" --log "/var/log/$app/server.log" -yunohost service add "$app-worker" --log "/var/log/$app/worker.log" -yunohost service add "$app-beat" --log "/var/log/$app/beat.log" +yunohost service add "$app-server" --log="/var/log/$app/server.log" +yunohost service add "$app-worker" --log="/var/log/$app/worker.log" +yunohost service add "$app-beat" --log="/var/log/$app/beat.log" #================================================= # SETUP SSOWAT #================================================= -ynh_print_info --message="Upgrading SSOwat configuration..." +ynh_script_progression --message="Upgrading SSOwat configuration..." # Make app public if necessary if [ "$is_public" -eq 1 ] @@ -286,7 +269,7 @@ fi #================================================= # START SYSTEMD SERVICE #================================================= -ynh_print_info --message="Starting a systemd service..." +ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --action="start" --service_name="${app}-beat" ynh_systemd_action --action="start" --service_name="${app}-server" @@ -295,7 +278,7 @@ ynh_systemd_action --action="start" --service_name="${app}-worker" #================================================= # RELOAD NGINX #================================================= -ynh_print_info --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -309,4 +292,4 @@ ynh_app_setting_set --app="$app" --key=code_migration --value=2 # END OF SCRIPT #================================================= -ynh_print_info --message="Upgrade of $app completed" +ynh_script_progression --message="Upgrade of $app completed"