From 795f1f86d850e2464c05f4e79cb1473ea9c9340b Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 14 Oct 2022 09:56:49 +0200 Subject: [PATCH] Update --- check_process | 6 +++--- conf/app.src | 5 +++-- conf/nginx.conf | 1 - manifest.json | 6 +++--- scripts/backup | 1 + scripts/install | 52 ++++++++++++++++++++++++------------------------- scripts/remove | 4 ++-- scripts/restore | 21 ++++++++++---------- scripts/upgrade | 10 +++++++++- 9 files changed, 57 insertions(+), 49 deletions(-) diff --git a/check_process b/check_process index 5307796..801237e 100644 --- a/check_process +++ b/check_process @@ -1,9 +1,9 @@ ;; Test complet ; Manifest - domain="sub.domain.tld" (DOMAIN) - path="/" (PATH) + domain="sub.domain.tld" + path="/" backend="domain.tld" - is_public=1 (true|false) + is_public=1 ; Checks pkg_linter=1 setup_sub_dir=0 diff --git a/conf/app.src b/conf/app.src index 3333aba..6efb2c5 100755 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,6 @@ -SOURCE_URL=https://gitlab.com/soapbox-pub/soapbox-fe/-/jobs/1396593082/artifacts/download -SOURCE_SUM=7349194c32136d0876987eef1e8d235b87a17e58b68c769e3f18ac97be4564c3 +SOURCE_URL=https://gitlab.com/soapbox-pub/soapbox-fe/-/jobs/3170505527/artifacts/download +SOURCE_SUM=991b0bb6ec52b486c249a222ad664fa738197d67b9ebb9114cb3309e18f96331 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=zip SOURCE_EXTRACT=true +3170505529 \ No newline at end of file diff --git a/conf/nginx.conf b/conf/nginx.conf index 06a5032..9390d5c 100755 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -37,7 +37,6 @@ location / { # doesn't work with some browsers # return 308 $scheme://__DOMAIN__$request_uri; } - } diff --git a/manifest.json b/manifest.json index bf244e2..12b177f 100755 --- a/manifest.json +++ b/manifest.json @@ -3,8 +3,8 @@ "id": "soapbox", "packaging_format": 1, "description": { - "en": "Alternative frontend for pleroma", - "fr": "Alternative frontend for pleroma" + "en": "Alternative frontend for Pleroma", + "fr": "Frontend alternatif pour Pleroma" }, "version": "1.3.0~ynh1", "url": "https://soapbox.pub/", @@ -19,7 +19,7 @@ "name": "" }, "requirements": { - "yunohost": ">= 4.3.0" + "yunohost": ">= 11.0.9" }, "multi_instance": false, "services": [ diff --git a/scripts/backup b/scripts/backup index b2b4f25..3f6b6db 100755 --- a/scripts/backup +++ b/scripts/backup @@ -22,6 +22,7 @@ ynh_abort_if_errors ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME + final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) diff --git a/scripts/install b/scripts/install index a1163b9..7e6ea38 100755 --- a/scripts/install +++ b/scripts/install @@ -20,11 +20,11 @@ ynh_abort_if_errors #================================================= domain=$YNH_APP_ARG_DOMAIN -backend=$YNH_APP_ARG_BACKEND -app=$YNH_APP_INSTANCE_NAME -is_public=$YNH_APP_ARG_IS_PUBLIC -final_path=/var/www/$app path_url=/ +backend=$YNH_APP_ARG_BACKEND +is_public=$YNH_APP_ARG_IS_PUBLIC + +app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS @@ -45,16 +45,29 @@ ynh_script_progression --message="Storing installation settings..." ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=backend --value=$backend ynh_app_setting_set --app=$app --key=path --value=$path_url -ynh_app_setting_set --app=$app --key=final_path --value=$final_path #================================================= # STANDARD MODIFICATIONS +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." --weight=1 + +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # SETUP SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --time --weight=1 +ynh_script_progression --message="Setting up source files..." --weight=1 +ynh_app_setting_set --app=$app --key=final_path --value=$final_path +# Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path/static" + +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= @@ -62,46 +75,31 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=2 # Create a dedicated NGINX config ynh_add_nginx_config + ynh_replace_string --match_string="example.com" --replace_string="$backend" --target_file="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." - -ynh_system_user_create --username=$app --home_dir="$final_path" - -#================================================= -# SPECIFIC SETUP -#================================================= -# MODIFY CONFIG FILE -#================================================= - -mkdir -p "$final_path" - -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" - #================================================= # GENERIC FINALIZATION #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring permissions..." +ynh_script_progression --message="Configuring permissions..." --weight=1 # Make app public if necessary if [ $is_public -eq 1 ] then + # Everyone can access the app. + # The "main" permission is automatically created before the install script. ynh_permission_update --permission="main" --add="visitors" fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/remove b/scripts/remove index 077f2fe..045d255 100755 --- a/scripts/remove +++ b/scripts/remove @@ -24,7 +24,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory..." +ynh_script_progression --message="Removing app main directory..." --weight=1 # Remove the app directory securely ynh_secure_remove --file="$final_path" @@ -42,7 +42,7 @@ ynh_remove_nginx_config #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Removing the dedicated system user..." +ynh_script_progression --message="Removing the dedicated system user..." --weight=1 # Delete a system user ynh_system_user_delete --username=$app diff --git a/scripts/restore b/scripts/restore index c8cfc6b..334d3b1 100755 --- a/scripts/restore +++ b/scripts/restore @@ -31,19 +31,11 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) #================================================= ynh_script_progression --message="Validating restoration parameters..." --weight=2 -ynh_webpath_available --domain=$domain --path_url=$path_url \ - || ynh_die --message="Path not available: ${domain}${path_url}" test ! -d $final_path \ || ynh_die --message="There is already a directory: $final_path " #================================================= # STANDARD RESTORATION STEPS -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - #================================================= # RECREATE THE DEDICATED USER #================================================= @@ -54,7 +46,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." +ynh_script_progression --message="Restoring the app main directory..." --weight=1 ynh_restore_file --origin_path="$final_path" @@ -63,12 +55,21 @@ chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1 + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" + #================================================= # GENERIC FINALIZATION #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_script_progression --message="Reloading NGINX web server" +ynh_script_progression --message="Reloading NGINX web server" --weight=1 + + ynh_systemd_action --service_name=nginx --action=reload #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index c59df62..950563c 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -72,9 +72,10 @@ ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= + if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading source files..." + ynh_script_progression --message="Upgrading source files..." --weight=4 # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path/static" --keep="static/instance" @@ -84,6 +85,13 @@ chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload + #================================================= # END OF SCRIPT #=================================================