From 27c618b2a3477391f6d3473a5d01f95bd95ea942 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Mon, 14 Mar 2022 19:54:17 +0100 Subject: [PATCH 01/20] fix config file parameters --- scripts/upgrade | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 7bce7c0..b3ee936 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -175,13 +175,13 @@ ynh_script_progression --message="Updating a configuration file..." --weight=1 ### The file will automatically be backed-up if it's found to be manually modified (because ### ynh_add_config keeps track of the file's checksum) -ynh_add_config --template="some_config_file" --destination="$final_path/some_config_file" +ynh_add_config --template="config.yaml" --destination="$final_path/config.yaml" # FIXME: this should be handled by the core in the future # You may need to use chmod 600 instead of 400, # for example if the app is expected to be able to modify its own config -chmod 400 "$final_path/some_config_file" -chown $app:$app "$final_path/some_config_file" +chmod 400 "$final_path/config.yaml" +chown $app:$app "$final_path/config.yaml" ### For more complex cases where you want to replace stuff using regexes, ### you shoud rely on ynh_replace_string (which is basically a wrapper for sed) From b55b0030570b5cf67f2df23b64cce548abf51505 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Mon, 14 Mar 2022 19:54:59 +0100 Subject: [PATCH 02/20] remove useless backup/restore --- scripts/backup | 4 ---- scripts/restore | 5 ----- 2 files changed, 9 deletions(-) diff --git a/scripts/backup b/scripts/backup index 24982fd..69643c2 100755 --- a/scripts/backup +++ b/scripts/backup @@ -79,10 +79,6 @@ ynh_backup --src_path="/etc/systemd/system/$app.service" # BACKUP VARIOUS FILES #================================================= -ynh_backup --src_path="/etc/cron.d/$app" - -ynh_backup --src_path="/etc/$app/" - #================================================= # BACKUP THE POSTGRESQL DATABASE #================================================= diff --git a/scripts/restore b/scripts/restore index ed8cc03..69e2a0f 100755 --- a/scripts/restore +++ b/scripts/restore @@ -122,11 +122,6 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name" #================================================= # RESTORE VARIOUS FILES #================================================= -ynh_script_progression --message="Restoring various files..." --weight=1 - -ynh_restore_file --origin_path="/etc/cron.d/$app" - -ynh_restore_file --origin_path="/etc/$app/" #================================================= # RESTORE SYSTEMD From 932fad3a152d92a2771707c2f2894a52139ac666 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Mon, 14 Mar 2022 19:55:47 +0100 Subject: [PATCH 03/20] fix datadir remove --- scripts/remove | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/remove b/scripts/remove index 2cbe271..ff61138 100755 --- a/scripts/remove +++ b/scripts/remove @@ -21,6 +21,7 @@ port=$(ynh_app_setting_get --app=$app --key=port) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name final_path=$(ynh_app_setting_get --app=$app --key=final_path) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # STANDARD REMOVE @@ -67,6 +68,14 @@ ynh_script_progression --message="Removing app main directory..." --weight=1 # Remove the app directory securely ynh_secure_remove --file="$final_path" +#================================================= +# REMOVE APP DATA DIR +#================================================= +ynh_script_progression --message="Removing app data directory..." --weight=1 + +# Remove the app directory securely +ynh_secure_remove --file="$datadir" + #================================================= # REMOVE NGINX CONFIGURATION #================================================= @@ -100,12 +109,6 @@ fi #================================================= ynh_script_progression --message="Removing various files..." --weight=1 -# Remove a cron file -ynh_secure_remove --file="/etc/cron.d/$app" - -# Remove a directory securely -ynh_secure_remove --file="/etc/$app" - # Remove the log files ynh_secure_remove --file="/var/log/$app" From 5d6f34d50cd98c67715cd2ba78d9c915960d6304 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Mon, 14 Mar 2022 19:56:05 +0100 Subject: [PATCH 04/20] some cleaning --- scripts/install | 43 ++----------------------------------------- 1 file changed, 2 insertions(+), 41 deletions(-) diff --git a/scripts/install b/scripts/install index acc60f6..88297fa 100755 --- a/scripts/install +++ b/scripts/install @@ -78,7 +78,7 @@ ynh_app_setting_set --app=$app --key=email --value=$email ynh_app_setting_set --app=$app --key=password --value=$password ynh_app_setting_set --app=$app --key=registration --value=$registration ynh_app_setting_set --app=$app --key=registration_approval --value=$registration_approval -ynh_app_setting_set --app=$app --key=registration_reason --value=$registration_reaso +ynh_app_setting_set --app=$app --key=registration_reason --value=$registration_reason #================================================= # STANDARD MODIFICATIONS @@ -89,21 +89,11 @@ ynh_script_progression --message="Finding an available port..." --weight=1 ### Use these lines if you have to open a port for the application ### `ynh_find_port` will find the first available port starting from the given port. -### If you're not using these lines: -### - Remove the section "CLOSE A PORT" in the remove script # Find an available port port=$(ynh_find_port --port=8095) ynh_app_setting_set --app=$app --key=port --value=$port -# Optional: Expose this port publicly -# (N.B.: you only need to do this if the app actually needs to expose the port publicly. -# If you do this and the app doesn't actually need you are CREATING SECURITY HOLES IN THE SERVER !) - -# Open the port -# ynh_script_progression --message="Configuring firewall..." --weight=1 -# ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port - #================================================= # INSTALL DEPENDENCIES #================================================= @@ -111,11 +101,6 @@ ynh_script_progression --message="Installing dependencies..." --weight=5 ### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package. ### Those deb packages will be installed as dependencies of this package. -### If you're not using this helper: -### - Remove the section "REMOVE DEPENDENCIES" in the remove script -### - Remove the variable "pkg_dependencies" in _common.sh -### - As well as the section "REINSTALL DEPENDENCIES" in the restore script -### - And the section "UPGRADE DEPENDENCIES" in the upgrade script ynh_install_app_dependencies $pkg_dependencies @@ -187,9 +172,6 @@ ynh_script_progression --message="Creating a data directory..." --weight=1 ### Use these lines if you need to create a directory to store "persistent files" for the application. ### Usually this directory is used to store uploaded files or any file that won't be updated during ### an upgrade and that won't be deleted during app removal -### If you're not using these lines: -### - Remove the section "BACKUP THE DATA DIR" in the backup script -### - As well as the section "RESTORE THE DATA DIRECTORY" in the restore script datadir=/home/yunohost.app/$app ynh_app_setting_set --app=$app --key=datadir --value=$datadir @@ -247,12 +229,6 @@ ynh_script_progression --message="Configuring a systemd service..." --weight=1 ### It can be used for apps that use sysvinit (with adaptation) or systemd. ### Have a look at the app to be sure this app needs a systemd script. ### `ynh_systemd_config` will use the file conf/systemd.service -### If you're not using these lines: -### - You can remove those files in conf/. -### - Remove the section "BACKUP SYSTEMD" in the backup script -### - Remove also the section "STOP AND REMOVE SERVICE" in the remove script -### - As well as the section "RESTORE SYSTEMD" in the restore script -### - And the section "SETUP SYSTEMD" in the upgrade script # Create a dedicated systemd config ynh_add_systemd_config @@ -287,11 +263,6 @@ ynh_script_progression --message="Configuring log rotation..." --weight=1 ### `ynh_use_logrotate` is used to configure a logrotate configuration for the logs of this app. ### Use this helper only if there is effectively a log file for this app. -### If you're not using this helper: -### - Remove the section "BACKUP LOGROTATE" in the backup script -### - Remove also the section "REMOVE LOGROTATE CONFIGURATION" in the remove script -### - As well as the section "RESTORE THE LOGROTATE CONFIGURATION" in the restore script -### - And the section "SETUP LOGROTATE" in the upgrade script # Use logrotate to manage application logfile(s) ynh_use_logrotate @@ -304,11 +275,6 @@ ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 ### `yunohost service add` integrates a service in YunoHost. It then gets ### displayed in the admin interface and through the others `yunohost service` commands. ### (N.B.: this line only makes sense if the app adds a service to the system!) -### If you're not using these lines: -### - You can remove these files in conf/. -### - Remove the section "REMOVE SERVICE INTEGRATION IN YUNOHOST" in the remove script -### - As well as the section "INTEGRATE SERVICE IN YUNOHOST" in the restore script -### - And the section "INTEGRATE SERVICE IN YUNOHOST" in the upgrade script yunohost service add $app --description="Gotosocial server" --log="/var/log/$app/$app.log" @@ -331,7 +297,7 @@ yunohost service add $app --description="Gotosocial server" --log="/var/log/$app #================================================= # CREATE ADMIN USER #================================================= -ynh_script_progression --message="Creating admin user..." --weight=1 +ynh_script_progression --message="Creating gotosocial admin user..." --weight=1 "$final_path"/gotosocial --config-path "$final_path/config.yaml" admin account create --username "$admin" --email "$email" --password "$password" @@ -346,11 +312,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1 ### `ynh_systemd_action` is used to start a systemd service for an app. ### Only needed if you have configure a systemd service -### If you're not using these lines: -### - Remove the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the backup script -### - As well as the section "START SYSTEMD SERVICE" in the restore script -### - As well as the section"STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the upgrade script -### - And the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the change_url script # Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" From 00d05c146ef3f3fa80a23a257e6d0dd2416e3e4d Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Mon, 14 Mar 2022 20:09:36 +0100 Subject: [PATCH 05/20] removed all --weight according to the example --- scripts/backup | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/backup b/scripts/backup index 69643c2..709730a 100755 --- a/scripts/backup +++ b/scripts/backup @@ -24,7 +24,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading installation settings..." --weight=1 +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -36,7 +36,7 @@ datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= -ynh_print_info --message="Declaring files to be backed up..." --weight=1 +ynh_print_info --message="Declaring files to be backed up..." ### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs ### to be backuped and not an actual copy of any file. The actual backup that @@ -82,7 +82,7 @@ ynh_backup --src_path="/etc/systemd/system/$app.service" #================================================= # BACKUP THE POSTGRESQL DATABASE #================================================= -ynh_print_info --message="Backing up the PostgreSQL database..." --weight=5 +ynh_print_info --message="Backing up the PostgreSQL database..." ynh_psql_dump_db --database="$db_name" > db.sql @@ -90,4 +90,4 @@ ynh_psql_dump_db --database="$db_name" > db.sql # END OF SCRIPT #================================================= -ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --weight=1 +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." From 6d9e8a67047ad487ccfe544ebb68c9b4a21ad4d0 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Mon, 14 Mar 2022 20:26:08 +0100 Subject: [PATCH 06/20] remove useless var --- scripts/upgrade | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index b3ee936..2997453 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -20,7 +20,6 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) admin=$(ynh_app_setting_get --app=$app --key=admin) final_path=$(ynh_app_setting_get --app=$app --key=final_path) -language=$(ynh_app_setting_get --app=$app --key=language) db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= From 2f709bfb4aaceb92619e2f8e9e83fc2901f8f202 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Mon, 14 Mar 2022 20:35:57 +0100 Subject: [PATCH 07/20] args for ynh_script_progression seems to bug the script --- scripts/upgrade | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 2997453..d344f67 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -37,7 +37,7 @@ 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=1 +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 @@ -53,14 +53,14 @@ ynh_abort_if_errors #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=1 +ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 +ynh_script_progression --message="Ensuring downward compatibility..." # # N.B. : the followings setting migrations snippets are provided as *EXAMPLES* @@ -116,7 +116,7 @@ fi #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 +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" @@ -127,7 +127,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path" if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading source files..." --weight=1 + ynh_script_progression --message="Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" @@ -146,7 +146,7 @@ chown -R $app:www-data "$final_path" #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 +ynh_script_progression --message="Upgrading NGINX web server configuration..." # Create a dedicated NGINX config ynh_add_nginx_config @@ -154,7 +154,7 @@ ynh_add_nginx_config #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=5 +ynh_script_progression --message="Upgrading dependencies..." ynh_install_app_dependencies $pkg_dependencies @@ -167,7 +167,7 @@ ynh_install_app_dependencies $pkg_dependencies #================================================= # UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Updating a configuration file..." --weight=1 +ynh_script_progression --message="Updating a configuration file..." ### Same as during install ### @@ -192,7 +192,7 @@ chown $app:$app "$final_path/config.yaml" #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 +ynh_script_progression --message="Upgrading systemd configuration..." # Create a dedicated systemd config ynh_add_systemd_config @@ -202,7 +202,7 @@ ynh_add_systemd_config #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 +ynh_script_progression --message="Upgrading logrotate configuration..." # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append @@ -210,21 +210,21 @@ ynh_use_logrotate --non-append #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 +ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add $app --description="Gotosocial server" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -232,4 +232,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression --message="Upgrade of $app completed" From 60228b992cac6d8da6f6204ab04a46ab2641ea6f Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Mon, 14 Mar 2022 22:03:14 +0100 Subject: [PATCH 08/20] setting up tests --- check_process | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/check_process b/check_process index fefa192..81a521e 100644 --- a/check_process +++ b/check_process @@ -5,26 +5,24 @@ ;; Test complet ; Manifest - domain="domain.tld" - path="/path" - admin="john" - language="fr" - is_public=1 + domain="goto.domain.tld" + admin="xana" + email="user@example.com" password="1Strong-Password" port="666" ; Checks pkg_linter=1 - setup_sub_dir=1 + setup_sub_dir=0 setup_root=1 setup_nourl=0 - setup_private=1 + setup_private=0 setup_public=1 upgrade=1 - upgrade=1 from_commit=CommitHash + upgrade=0 from_commit=CommitHash backup_restore=1 - multi_instance=1 + multi_instance=0 port_already_use=0 - change_url=1 + change_url=0 ;;; Options Email= Notification=none From 88cc844a9047d7ba03d8daedabfae49047007b14 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Mon, 14 Mar 2022 22:05:29 +0100 Subject: [PATCH 09/20] removed unused argument --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index 81a521e..1461e47 100644 --- a/check_process +++ b/check_process @@ -29,4 +29,4 @@ Notification=none ;;; Upgrade options ; commit=CommitHash name=Name and date of the commit. - manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666& + manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&password=pass&port=666& From ec090ba95b98425d95a738fd162f9dc43346ecb2 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Mon, 14 Mar 2022 22:51:06 +0100 Subject: [PATCH 10/20] fix missing db_pwd variable --- scripts/restore | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/restore b/scripts/restore index 69e2a0f..b9f4bd6 100755 --- a/scripts/restore +++ b/scripts/restore @@ -33,6 +33,7 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name +db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= From 5e9a5d25f760d03478179bedce39b730a0892454 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Mon, 14 Mar 2022 23:06:30 +0100 Subject: [PATCH 11/20] fix getting the source files depending on the architecture --- scripts/upgrade | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index d344f67..16a7505 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -129,8 +129,10 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." + architecture=$YNH_ARCH + # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" + ynh_setup_source --dest_dir="$final_path" --source_id=$architecture fi # FIXME: this should be managed by the core in the future From e05521ad61b07ce7265806b0bed193a1f27366a0 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Mon, 14 Mar 2022 23:21:15 +0100 Subject: [PATCH 12/20] fix load settings --- scripts/upgrade | 71 +++++++++---------------------------------------- 1 file changed, 12 insertions(+), 59 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 16a7505..00700ee 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -16,11 +16,20 @@ ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) -admin=$(ynh_app_setting_get --app=$app --key=admin) final_path=$(ynh_app_setting_get --app=$app --key=final_path) + +domain=$(ynh_app_setting_get --app=$app --key=domain) +port=$(ynh_app_setting_get --app=$app --key=port) + db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_user=$(ynh_app_setting_get --app=$app --key=db_user) +db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) + +registration=$(ynh_app_setting_get --app=$app --key=registration) +registration_approval=$(ynh_app_setting_get --app=$app --key=registration_approval) +registration_reason=$(ynh_app_setting_get --app=$app --key=registration_reason) + +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # CHECK VERSION @@ -57,62 +66,6 @@ ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" -#================================================= -# ENSURE DOWNWARD COMPATIBILITY -#================================================= -ynh_script_progression --message="Ensuring downward compatibility..." - -# -# N.B. : the followings setting migrations snippets are provided as *EXAMPLES* -# of what you may want to do in some cases (e.g. a setting was not defined on -# some legacy installs and you therefore want to initiaze stuff during upgrade) -# - -# If db_name doesn't exist, create it -#if [ -z "$db_name" ]; then -# db_name=$(ynh_sanitize_dbid --db_name=$app) -# ynh_app_setting_set --app=$app --key=db_name --value=$db_name -#fi - -# If final_path doesn't exist, create it -#if [ -z "$final_path" ]; then -# final_path=/var/www/$app -# ynh_app_setting_set --app=$app --key=final_path --value=$final_path -#fi - -### If nobody installed your app before 4.1, -### then you may safely remove these lines - -# Cleaning legacy permissions -if ynh_legacy_permissions_exists; then - ynh_legacy_permissions_delete_all - - ynh_app_setting_delete --app=$app --key=is_public -fi - -if ! ynh_permission_exists --permission="admin"; then - # Create the required permissions - ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin -fi - -# Create a permission if needed -if ! ynh_permission_exists --permission="api"; then - ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --show_tile="false" --protected="true" -fi - -#Switch variables name -psql_db=$(ynh_app_setting_get --app=$app --key=psql_db) - -if [ -n "$psql_db" ] -then - db_name=$(ynh_app_setting_get --app=$app --key=psql_db) - db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) - ynh_app_setting_set --app=$app --key=db_name --value=$db_name - ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd - ynh_app_setting_delete --app=$app --key=psql_db - ynh_app_setting_delete --app=$app --key=psqlpwd -fi - #================================================= # CREATE DEDICATED USER #================================================= From 8e8891c23e390dbd2473d60310e5e3c94d633f66 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Tue, 15 Mar 2022 02:14:16 +0100 Subject: [PATCH 13/20] reorganize settings arguments --- conf/config.yaml | 2 +- scripts/backup | 3 +++ scripts/install | 11 ++++++++--- scripts/restore | 12 ++++++++++-- scripts/upgrade | 5 +++-- 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/conf/config.yaml b/conf/config.yaml index e802a61..8de7d54 100644 --- a/conf/config.yaml +++ b/conf/config.yaml @@ -167,7 +167,7 @@ web-asset-base-dir: "./web/assets/" # Bool. Do we want people to be able to just submit sign up requests, or do we want invite only? # Options: [true, false] # Default: true -accounts-registration-open: __REGISTRATION__ +accounts-registration-open: __REGISTRATION_OPEN__ # Bool. Do sign up requests require approval from an admin/moderator before an account can sign in/use the server? # Options: [true, false] diff --git a/scripts/backup b/scripts/backup index 709730a..36f9bc9 100755 --- a/scripts/backup +++ b/scripts/backup @@ -29,8 +29,11 @@ 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) + db_name=$(ynh_app_setting_get --app=$app --key=db_name) + datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= diff --git a/scripts/install b/scripts/install index 88297fa..ebd7ed6 100755 --- a/scripts/install +++ b/scripts/install @@ -26,9 +26,11 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url="/" + admin=$YNH_APP_ARG_ADMIN email=$YNH_APP_ARG_EMAIL password=$YNH_APP_ARG_PASSWORD + registration=$YNH_APP_ARG_REGISTRATION registration_approval=$YNH_APP_ARG_REGISTRATION_APPROVAL registration_reason=$YNH_APP_ARG_REGISTRATION_REASON @@ -71,12 +73,16 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= ynh_script_progression --message="Storing installation settings..." --weight=1 +ynh_app_setting_set --app=$app --key=final_path --value=$final_path + ynh_app_setting_set --app=$app --key=domain --value=$domain -ynh_app_setting_set --app=$app --key=path --value=$path_url +ynh_app_setting_set --app=$app --key=path_url --value=$path_url + ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=email --value=$email ynh_app_setting_set --app=$app --key=password --value=$password -ynh_app_setting_set --app=$app --key=registration --value=$registration + +ynh_app_setting_set --app=$app --key=registration_open --value=$registration_open ynh_app_setting_set --app=$app --key=registration_approval --value=$registration_approval ynh_app_setting_set --app=$app --key=registration_reason --value=$registration_reason @@ -136,7 +142,6 @@ ynh_script_progression --message="Setting up source files..." --weight=1 architecture=$YNH_ARCH -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" --source_id=$architecture diff --git a/scripts/restore b/scripts/restore index b9f4bd6..775238d 100755 --- a/scripts/restore +++ b/scripts/restore @@ -28,12 +28,20 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME -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) + +domain=$(ynh_app_setting_get --app=$app --key=domain) +port=$(ynh_app_setting_get --app=$app --key=port) +path_url=$(ynh_app_setting_get --app=$app --key=path_url) + db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) + +registration_open=$(ynh_app_setting_get --app=$app --key=registration_open) +registration_approval=$(ynh_app_setting_get --app=$app --key=registration_approval) +registration_reason=$(ynh_app_setting_get --app=$app --key=registration_reason) + datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 00700ee..291f73f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -20,12 +20,13 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) port=$(ynh_app_setting_get --app=$app --key=port) +path_url=$(ynh_app_setting_get --app=$app --key=path_url) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$(ynh_app_setting_get --app=$app --key=db_user) db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) -registration=$(ynh_app_setting_get --app=$app --key=registration) +registration_open=$(ynh_app_setting_get --app=$app --key=registration_open) registration_approval=$(ynh_app_setting_get --app=$app --key=registration_approval) registration_reason=$(ynh_app_setting_get --app=$app --key=registration_reason) @@ -85,7 +86,7 @@ then architecture=$YNH_ARCH # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" --source_id=$architecture + ynh_setup_source --dest_dir="$final_path" --source_id=$architecture --keep="config.yaml" fi # FIXME: this should be managed by the core in the future From c5fa10fdbc93237a39306a804af39a3d8d1257db Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Tue, 15 Mar 2022 02:23:13 +0100 Subject: [PATCH 14/20] fix var name --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 21384bd..3693246 100644 --- a/manifest.json +++ b/manifest.json @@ -66,7 +66,7 @@ } }, { - "name": "registration", + "name": "registration_open", "type": "boolean", "ask": { "en": "Open registration?", From 35e6f58143d1c078960c4228e5401042eb63fa57 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Tue, 15 Mar 2022 02:23:25 +0100 Subject: [PATCH 15/20] reorder var --- scripts/backup | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/backup b/scripts/backup index 36f9bc9..cbbf6ff 100755 --- a/scripts/backup +++ b/scripts/backup @@ -28,12 +28,12 @@ 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) db_name=$(ynh_app_setting_get --app=$app --key=db_name) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) + datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= From dbf381f42d009fbd6fbbb9059c14d2d97fc3ecc4 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Tue, 15 Mar 2022 02:29:06 +0100 Subject: [PATCH 16/20] fix var name --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index ebd7ed6..795e0d7 100755 --- a/scripts/install +++ b/scripts/install @@ -31,7 +31,7 @@ admin=$YNH_APP_ARG_ADMIN email=$YNH_APP_ARG_EMAIL password=$YNH_APP_ARG_PASSWORD -registration=$YNH_APP_ARG_REGISTRATION +registration_open=$YNH_APP_ARG_REGISTRATION registration_approval=$YNH_APP_ARG_REGISTRATION_APPROVAL registration_reason=$YNH_APP_ARG_REGISTRATION_REASON From 70b84ab9757e071b74c4749b9643285caa5816b5 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Tue, 15 Mar 2022 02:47:00 +0100 Subject: [PATCH 17/20] can I think? --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 795e0d7..d29a529 100755 --- a/scripts/install +++ b/scripts/install @@ -31,7 +31,7 @@ admin=$YNH_APP_ARG_ADMIN email=$YNH_APP_ARG_EMAIL password=$YNH_APP_ARG_PASSWORD -registration_open=$YNH_APP_ARG_REGISTRATION +registration_open=$YNH_APP_ARG_REGISTRATION_OPEN registration_approval=$YNH_APP_ARG_REGISTRATION_APPROVAL registration_reason=$YNH_APP_ARG_REGISTRATION_REASON From 0a9df5b3adb3bac611a36fd38666974667df5e30 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Tue, 15 Mar 2022 03:29:42 +0100 Subject: [PATCH 18/20] debug attemp --- scripts/restore | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/restore b/scripts/restore index 775238d..35bfec0 100755 --- a/scripts/restore +++ b/scripts/restore @@ -132,6 +132,13 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name" # RESTORE VARIOUS FILES #================================================= +mkdir -p /var/log/$app + +# for debugging purpose, will remove +# systemd[7948]: gotosocial.service: Failed to set up standard output: No such file or directory +# systemd[7948]: gotosocial.service: Failed at step STDOUT spawning /var/www/gotosocial/gotosocial: No such file or directory +ls -l $final_path + #================================================= # RESTORE SYSTEMD #================================================= From ba9915b3df6db556fdd48326837c34d4cb34eb75 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Tue, 15 Mar 2022 04:08:09 +0100 Subject: [PATCH 19/20] bump version from 0.2.1~ynh1 to 0.2.1~ynh2 --- manifest.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index 3693246..77280bf 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "An ActivityPub social network server, written in Golang.", "fr": "Un serveur de réseau social basé sur ActivityPub écrit en Golang." }, - "version": "0.2.1~ynh1", + "version": "0.2.1~ynh2", "url": "https://github.com/superseriousbusiness/gotosocial", "upstream": { "license": " AGPL-3.0-only", @@ -22,7 +22,7 @@ "email": "" }, "requirements": { - "yunohost": ">= 4.1.3" + "yunohost": ">= 4.3.1.8" }, "multi_instance": true, "services": [ From a543a3198b9842a796d11fd1f0213f2403ab7d48 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Tue, 15 Mar 2022 04:09:05 +0100 Subject: [PATCH 20/20] remove debug ls --- scripts/restore | 5 ----- 1 file changed, 5 deletions(-) diff --git a/scripts/restore b/scripts/restore index 35bfec0..c23fd76 100755 --- a/scripts/restore +++ b/scripts/restore @@ -134,11 +134,6 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name" mkdir -p /var/log/$app -# for debugging purpose, will remove -# systemd[7948]: gotosocial.service: Failed to set up standard output: No such file or directory -# systemd[7948]: gotosocial.service: Failed at step STDOUT spawning /var/www/gotosocial/gotosocial: No such file or directory -ls -l $final_path - #================================================= # RESTORE SYSTEMD #=================================================