From ac10b87996009fad22ad676da770aa7ef4faf4ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Wed, 27 Sep 2023 15:59:19 +0200 Subject: [PATCH] v2 --- conf/arm64.src | 7 -- conf/armv6.src | 7 -- conf/armv7.src | 7 -- conf/config.yaml | 2 +- conf/i386.src | 7 -- conf/systemd.service | 4 +- conf/x86-64.src | 7 -- manifest.toml | 106 ++++++++++++++++++++++++++++ scripts/_common.sh | 2 +- scripts/backup | 20 +++--- scripts/install | 118 +++++++++++++++---------------- scripts/remove | 34 ++++----- scripts/restore | 152 ++++++++++++++++++++-------------------- scripts/upgrade | 162 +++++++++++++++++++++---------------------- 14 files changed, 353 insertions(+), 282 deletions(-) delete mode 100644 conf/arm64.src delete mode 100644 conf/armv6.src delete mode 100644 conf/armv7.src delete mode 100644 conf/i386.src delete mode 100644 conf/x86-64.src create mode 100644 manifest.toml diff --git a/conf/arm64.src b/conf/arm64.src deleted file mode 100644 index 6e6a22e..0000000 --- a/conf/arm64.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://github.com/superseriousbusiness/gotosocial/releases/download/v0.11.1/gotosocial_0.11.1_linux_arm64.tar.gz -SOURCE_SUM=d5478c5833df4c7a0510b452546640e10575d2fa45fa43dbbc2e2714f762362a -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_EXTRACT=true -SOURCE_IN_SUBDIR=false -SOURCE_FILENAME=gotosocial_0.11.1_linux_arm64.tar.gz diff --git a/conf/armv6.src b/conf/armv6.src deleted file mode 100644 index b039f2c..0000000 --- a/conf/armv6.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://github.com/superseriousbusiness/gotosocial/releases/download/v0.11.1/gotosocial_0.11.1_linux_armv6.tar.gz -SOURCE_SUM=aadd5ecab1d2a42923ca34bdea7791ab5682ef46b36e9b515a57b55217f397bc -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_EXTRACT=true -SOURCE_IN_SUBDIR=false -SOURCE_FILENAME=gotosocial_0.11.1_linux_armv6.tar.gz diff --git a/conf/armv7.src b/conf/armv7.src deleted file mode 100644 index 9ff86cc..0000000 --- a/conf/armv7.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://github.com/superseriousbusiness/gotosocial/releases/download/v0.11.1/gotosocial_0.11.1_linux_armv7.tar.gz -SOURCE_SUM=6c19c23f7476ab0cd5e7e698bfd47bafa582eba84b810dcb8539e97a419cc136 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_EXTRACT=true -SOURCE_IN_SUBDIR=false -SOURCE_FILENAME=gotosocial_0.11.1_linux_armv7.tar.gz diff --git a/conf/config.yaml b/conf/config.yaml index 5cbc7b0..ed325d6 100644 --- a/conf/config.yaml +++ b/conf/config.yaml @@ -426,7 +426,7 @@ storage-backend: "__STORAGE_BACKEND__" # Only required when running with the local storage backend. # Examples: ["/home/gotosocial/storage", "/opt/gotosocial/datastorage"] # Default: "/gotosocial/storage" -storage-local-base-path: "__DATADIR__" +storage-local-base-path: "__DATA_DIR__" # String. API endpoint of the S3 compatible service. # Only required when running with the s3 storage backend. diff --git a/conf/i386.src b/conf/i386.src deleted file mode 100644 index a9d1351..0000000 --- a/conf/i386.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://github.com/superseriousbusiness/gotosocial/releases/download/v0.11.1/gotosocial_0.11.1_linux_386.tar.gz -SOURCE_SUM=f66f455c7406ac40ff04320cb8f030b5affe8acd39937a8727b0ea53887c7227 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_EXTRACT=true -SOURCE_IN_SUBDIR=false -SOURCE_FILENAME=gotosocial_0.11.1_linux_386.tar.gz diff --git a/conf/systemd.service b/conf/systemd.service index 0c5bc1f..efc257a 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -8,8 +8,8 @@ Restart=on-failure User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/ -ExecStart=__FINALPATH__/gotosocial --config-path config.yaml server start +WorkingDirectory=__INSTALL_DIR__/ +ExecStart=__INSTALL_DIR__/gotosocial --config-path config.yaml server start StandardOutput=append:/var/log/__APP__/__APP__.log StandardError=inherit diff --git a/conf/x86-64.src b/conf/x86-64.src deleted file mode 100644 index b539f88..0000000 --- a/conf/x86-64.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://github.com/superseriousbusiness/gotosocial/releases/download/v0.11.1/gotosocial_0.11.1_linux_amd64.tar.gz -SOURCE_SUM=4e44a5cb4044a523c51b5d178dfd06efb077a17dac22a9a170d6204cb7aed407 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_EXTRACT=true -SOURCE_IN_SUBDIR=false -SOURCE_FILENAME=gotosocial_0.11.1_linux_amd64.tar.gz diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..c8b46f3 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,106 @@ +packaging_format = 2 + +id = "gotosocial" +name = "GoToSocial" +description.en = "ActivityPub social network server" +description.fr = "Serveur de réseau social basé sur ActivityPub" + +version = "0.11.1~ynh4" + +maintainers = ["OniriCorpe"] + +[upstream] +license = "AGPL-3.0-only" +website = "https://gotosocial.org/" +demo = "" +admindoc = "https://docs.gotosocial.org/en/latest/" +userdoc = "https://docs.gotosocial.org/en/latest/" +code = "https://github.com/superseriousbusiness/gotosocial" +cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number) +fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin. + +[integration] +yunohost = ">= 11.0.6" +architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"] +multi_instance = true +ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials. +sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal. +disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... +ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... +ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... + +[install] + [install.domain] + # this is a generic question - ask strings are automatically handled by Yunohost's core + type = "domain" + full_domain = true + + [install.admin] + # this is a generic question - ask strings are automatically handled by Yunohost's core + help.en = "Must be in lower case and without special characters." + help.fr = "Doit être en minuscule et sans caractère special." + type = "string" + example = "johndoe" + + [install.email] + ask.en = "The email adress of your admin account." + ask.fr = "L'adresse e-mail de votre compte admin." + type = "string" + example = "johndoe@example.com" + + [install.password] + # this is a generic question - ask strings are automatically handled by Yunohost's core + help.en = "Must contain: upper case, lower case, number and special character." + help.fr = "Il doit contenir : majuscule, minuscule, chiffre et caractère spécial." + type = "password" + + [install.accounts_registration_open] + ask.en = "Open registration?" + ask.fr = "Inscriptions ouvertes ?" + help.en = "Do you want people to be able to just submit sign up requests (true), or do you want invite only (false)?" + help.fr = "Voulez-vous que les gens puissent envoyer des demandes d'inscription (true) ou voulez-vous que les inscriptions soient uniquement sur invitation (false) ?" + type = "boolean" + default = false + + [install.accounts_approval_required] + ask.en = "Registration approval?" + ask.fr = "Vérification manuelle des inscriptions ?" + help.en = "Do sign up requests require approval from an admin/moderator before an account can sign in/use the server?" + help.fr = "Les demandes d'inscription doivent-elles être approuvées par un-e administrateur-ice/modérateur-ice avant qu'un compte puisse se connecter et utiliser le serveur ?" + type = "boolean" + default = true + + [install.accounts_reason_required] + ask.en = "Request registration reason?" + ask.fr = "Demande de motif pour les inscriptions ?" + help.en = "Are sign up requests required to submit a reason for the request (eg., an explanation of why they want to join the instance)?" + help.fr = "Les demandes d'inscription doivent-elles être accompagnée d'un motif (par exemple, une explication de la raison pour laquelle la personne veut rejoindre l'instance) ?" + type = "boolean" + default = true + +[resources] + [resources.sources.main] + in_subdir = false + arm64.url = "https://github.com/superseriousbusiness/gotosocial/releases/download/v0.11.1/gotosocial_0.11.1_linux_arm64.tar.gz" + arm64.sha256 = "d5478c5833df4c7a0510b452546640e10575d2fa45fa43dbbc2e2714f762362a" + armel.url = "https://github.com/superseriousbusiness/gotosocial/releases/download/v0.11.1/gotosocial_0.11.1_linux_armv6.tar.gz" + armel.sha256 = "aadd5ecab1d2a42923ca34bdea7791ab5682ef46b36e9b515a57b55217f397bc" + armhf.url = "https://github.com/superseriousbusiness/gotosocial/releases/download/v0.11.1/gotosocial_0.11.1_linux_armv7.tar.gz" + armhf.sha256 = "6c19c23f7476ab0cd5e7e698bfd47bafa582eba84b810dcb8539e97a419cc136" + i386.url = "https://github.com/superseriousbusiness/gotosocial/releases/download/v0.11.1/gotosocial_0.11.1_linux_386.tar.gz" + i386.sha256 = "f66f455c7406ac40ff04320cb8f030b5affe8acd39937a8727b0ea53887c7227" + amd64.url = "https://github.com/superseriousbusiness/gotosocial/releases/download/v0.11.1/gotosocial_0.11.1_linux_amd64.tar.gz" + amd64.sha256 = "4e44a5cb4044a523c51b5d178dfd06efb077a17dac22a9a170d6204cb7aed407" + + + [resources.system_user] + + [resources.install_dir] + + [resources.data_dir] + + [resources.permissions] + main.url = "/" + + [resources.database] + type = "postgresql" diff --git a/scripts/_common.sh b/scripts/_common.sh index 4452969..6cf1f26 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="postgresql postgresql-contrib" +#REMOVEME? pkg_dependencies="postgresql postgresql-contrib" #================================================= # PERSONAL HELPERS diff --git a/scripts/backup b/scripts/backup index 14f4599..5faddb4 100755 --- a/scripts/backup +++ b/scripts/backup @@ -14,27 +14,27 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { ### Remove this function if there's nothing to clean before calling the remove script. true } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading installation settings..." +#REMOVEME? ynh_print_info --message="Loading installation settings..." -app="$YNH_APP_INSTANCE_NAME" +#REMOVEME? app="$YNH_APP_INSTANCE_NAME" -domain=$(ynh_app_setting_get --app="$app" --key=domain) +#REMOVEME? domain=$(ynh_app_setting_get --app="$app" --key=domain) -db_name=$(ynh_app_setting_get --app="$app" --key=db_name) +#REMOVEME? db_name=$(ynh_app_setting_get --app="$app" --key=db_name) -final_path=$(ynh_app_setting_get --app="$app" --key=final_path) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app="$app" --key=install_dir) -datadir=$(ynh_app_setting_get --app="$app" --key=datadir) +#REMOVEME? data_dir=$(ynh_app_setting_get --app="$app" --key=data_dir) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -50,13 +50,13 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$final_path" +ynh_backup --src_path="$install_dir" #================================================= # BACKUP THE DATA DIR #================================================= -ynh_backup --src_path="$datadir" --is_big +ynh_backup --src_path="$data_dir" --is_big #================================================= # BACKUP THE NGINX CONFIGURATION diff --git a/scripts/install b/scripts/install index 082d69a..4ddcfa3 100755 --- a/scripts/install +++ b/scripts/install @@ -13,37 +13,37 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { ### Remove this function if there's nothing to clean before calling the remove script. true } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -app="$YNH_APP_INSTANCE_NAME" +#REMOVEME? app="$YNH_APP_INSTANCE_NAME" landing_page_user="" -domain="$YNH_APP_ARG_DOMAIN" -path_url="/" +#REMOVEME? domain="$YNH_APP_ARG_DOMAIN" +path="/" client_max_body_size="100M" -admin="$YNH_APP_ARG_ADMIN" -email="$YNH_APP_ARG_EMAIL" -password="$YNH_APP_ARG_PASSWORD" +#REMOVEME? admin="$YNH_APP_ARG_ADMIN" +#REMOVEME? email="$YNH_APP_ARG_EMAIL" +#REMOVEME? password="$YNH_APP_ARG_PASSWORD" # Config stuff: cache_memory_target="100MiB" -accounts_registration_open=$(convert_bool "$YNH_APP_ARG_ACCOUNTS_REGISTRATION_OPEN") -accounts_approval_required=$(convert_bool "$YNH_APP_ARG_ACCOUNTS_APPROVAL_REQUIRED") -accounts_reason_required=$(convert_bool "$YNH_APP_ARG_ACCOUNTS_REASON_REQUIRED") +#REMOVEME? accounts_registration_open=$(convert_bool "$YNH_APP_ARG_ACCOUNTS_REGISTRATION_OPEN") +#REMOVEME? accounts_approval_required=$(convert_bool "$YNH_APP_ARG_ACCOUNTS_APPROVAL_REQUIRED") +#REMOVEME? accounts_reason_required=$(convert_bool "$YNH_APP_ARG_ACCOUNTS_REASON_REQUIRED") accounts_allow_custom_css="false" accounts_custom_css_length="10000" @@ -89,30 +89,30 @@ advanced_rate_limit_requests="300" # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression --message="Validating installation parameters..." --weight=1 +#REMOVEME? ynh_script_progression --message="Validating installation parameters..." --weight=1 -final_path="/var/www/$app" -test ! -e "$final_path" || ynh_die --message="This path already contains a folder" +#REMOVEME? install_dir="/var/www/$app" +#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder" -ynh_webpath_register --app="$app" --domain="$domain" --path_url="$path_url" +#REMOVEME? ynh_webpath_register --app="$app" --domain="$domain" --path="$path" #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." --weight=1 +#REMOVEME? ynh_script_progression --message="Storing installation settings..." --weight=1 -ynh_app_setting_set --app="$app" --key=final_path --value="$final_path" +#REMOVEME? ynh_app_setting_set --app="$app" --key=install_dir --value="$install_dir" ynh_app_setting_set --app="$app" --key=landing_page_user --value="$landing_page_user" -ynh_app_setting_set --app="$app" --key=domain --value="$domain" -ynh_app_setting_set --app="$app" --key=path_url --value="$path_url" +#REMOVEME? ynh_app_setting_set --app="$app" --key=domain --value="$domain" +#REMOVEME? ynh_app_setting_set --app="$app" --key=path --value="$path" ynh_app_setting_set --app="$app" --key=client_max_body_size --value="$client_max_body_size" -ynh_app_setting_set --app="$app" --key=admin --value="$admin" +#REMOVEME? 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" +#REMOVEME? ynh_app_setting_set --app="$app" --key=password --value="$password" ynh_app_setting_set --app="$app" --key=cache_memory_target --value="$cache_memory_target" @@ -151,9 +151,9 @@ ynh_app_setting_set --app="$app" --key=statuses_poll_option_max_chars --value="$ ynh_app_setting_set --app="$app" --key=statuses_media_max_files --value="$statuses_media_max_files" ynh_app_setting_set --app="$app" --key=smtp_host --value="$smtp_host" -ynh_app_setting_set --app="$app" --key=smtp_port --value="$smtp_port" +#REMOVEME? ynh_app_setting_set --app="$app" --key=smtp_port --value="$smtp_port" ynh_app_setting_set --app="$app" --key=smtp_username --value="$smtp_username" -ynh_app_setting_set --app="$app" --key=smtp_password --value="$smtp_password" +#REMOVEME? ynh_app_setting_set --app="$app" --key=smtp_password --value="$smtp_password" ynh_app_setting_set --app="$app" --key=smtp_from --value="$smtp_from" ynh_app_setting_set --app="$app" --key=smtp_disclose_recipients --value="$smtp_disclose_recipients" @@ -165,40 +165,40 @@ ynh_app_setting_set --app="$app" --key=advanced_rate_limit_requests --value="$ad #================================================= # FIND AND OPEN A PORT #================================================= -ynh_script_progression --message="Finding an available port..." --weight=1 +#REMOVEME? ynh_script_progression --message="Finding an available port..." --weight=1 # Find an available port -port=$(ynh_find_port --port=8095) -ynh_app_setting_set --app="$app" --key=port --value="$port" +#REMOVEME? port=$(ynh_find_port --port=8095) +#REMOVEME? ynh_app_setting_set --app="$app" --key=port --value="$port" #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --weight=5 +#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=5 -ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies" +#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies" #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Configuring system user..." --weight=1 +#REMOVEME? ynh_script_progression --message="Configuring system user..." --weight=1 # Create a system user -ynh_system_user_create --username="$app" --home_dir="$final_path" +#REMOVEME? ynh_system_user_create --username="$app" --home_dir="$install_dir" #================================================= # CREATE A POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Creating a PostgreSQL database..." --weight=5 +#REMOVEME? ynh_script_progression --message="Creating a PostgreSQL database..." --weight=5 -db_name=$(ynh_sanitize_dbid --db_name="$app") -db_user="$db_name" -db_pwd=$(ynh_string_random --length=30) -ynh_app_setting_set --app="$app" --key=db_name --value="$db_name" -ynh_app_setting_set --app="$app" --key=db_user --value="$db_user" -ynh_app_setting_set --app="$app" --key=db_pwd --value="$db_pwd" -ynh_psql_test_if_first_run -ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" --db_pwd="$db_pwd" +#REMOVEME? db_name=$(ynh_sanitize_dbid --db_name="$app") +#REMOVEME? db_user="$db_name" +#REMOVEME? db_pwd=$(ynh_string_random --length=30) +#REMOVEME? ynh_app_setting_set --app="$app" --key=db_name --value="$db_name" +#REMOVEME? ynh_app_setting_set --app="$app" --key=db_user --value="$db_user" +#REMOVEME? ynh_app_setting_set --app="$app" --key=db_pwd --value="$db_pwd" +#REMOVEME? ynh_psql_test_if_first_run +#REMOVEME? ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" --db_pwd="$db_pwd" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -213,7 +213,7 @@ ynh_script_progression --message="Setting up source files..." --weight=1 architecture=$(detect_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="$install_dir" # FIXME: this should be managed by the core in the future # Here, as a packager, you may have to tweak the ownerhsip/permissions @@ -221,9 +221,9 @@ ynh_setup_source --dest_dir="$final_path" --source_id="$architecture" # files in some cases. # But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder _ # this will be treated as a security issue. -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R "$app:www-data" "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R "$app:www-data" "$install_dir" #================================================= # NGINX CONFIGURATION @@ -238,10 +238,10 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Creating a data directory..." --weight=1 -datadir=/home/yunohost.app/$app -ynh_app_setting_set --app="$app" --key=datadir --value="$datadir" +#REMOVEME? data_dir=/home/yunohost.app/$app +#REMOVEME? ynh_app_setting_set --app="$app" --key=data_dir --value="$data_dir" -mkdir -p "$datadir" +mkdir -p "$data_dir" # FIXME: this should be managed by the core in the future # Here, as a packager, you may have to tweak the ownerhsip/permissions @@ -249,22 +249,22 @@ mkdir -p "$datadir" # files in some cases. # But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder - # this will be treated as a security issue. -chmod 750 "$datadir" -chmod -R o-rwx "$datadir" -chown -R "$app:www-data" "$datadir" +chmod 750 "$data_dir" +chmod -R o-rwx "$data_dir" +chown -R "$app:www-data" "$data_dir" #================================================= # ADD A CONFIGURATION #================================================= ynh_script_progression --message="Adding a configuration file..." --weight=1 -ynh_add_config --template="config.yaml" --destination="$final_path/config.yaml" +ynh_add_config --template="config.yaml" --destination="$install_dir/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/config.yaml" -chown "$app:$app" "$final_path/config.yaml" +chmod 400 "$install_dir/config.yaml" +chown "$app:$app" "$install_dir/config.yaml" #================================================= # SETUP SYSTEMD @@ -307,12 +307,12 @@ yunohost service add "$app" --description="Gotosocial server" --log="/var/log/$a #================================================= ynh_script_progression --message="Creating gotosocial admin user..." --weight=1 -# using "/var/www/$app" instead of "$final_path" as a temporary workaround for this bug: +# using "/var/www/$app" instead of "$install_dir" as a temporary workaround for this bug: # bad_ynh_exec_syntax() false positive: https://github.com/YunoHost/package_linter/issues/123 -ynh_exec_warn_less /var/www/"$app"/gotosocial --config-path "$final_path/config.yaml" admin account create --username "$admin" --email "$email" --password "$password" +ynh_exec_warn_less /var/www/"$app"/gotosocial --config-path "$install_dir/config.yaml" admin account create --username "$admin" --email "$email" --password "$password" -ynh_exec_warn_less /var/www/"$app"/gotosocial --config-path "$final_path/config.yaml" admin account promote --username "$admin" +ynh_exec_warn_less /var/www/"$app"/gotosocial --config-path "$install_dir/config.yaml" admin account promote --username "$admin" #================================================= # START SYSTEMD SERVICE @@ -325,17 +325,17 @@ ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$ #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring permissions..." --weight=1 +#REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1 # Everyone can access the app. -ynh_permission_update --permission="main" --add="visitors" +#REMOVEME? ynh_permission_update --permission="main" --add="visitors" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 -ynh_systemd_action --service_name=nginx --action=reload +#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index 0298c20..d2b9e25 100755 --- a/scripts/remove +++ b/scripts/remove @@ -12,16 +12,16 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 +#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 -app="$YNH_APP_INSTANCE_NAME" +#REMOVEME? app="$YNH_APP_INSTANCE_NAME" -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) -final_path=$(ynh_app_setting_get --app="$app" --key=final_path) -datadir=$(ynh_app_setting_get --app="$app" --key=datadir) +#REMOVEME? domain=$(ynh_app_setting_get --app="$app" --key=domain) +#REMOVEME? port=$(ynh_app_setting_get --app="$app" --key=port) +#REMOVEME? db_name=$(ynh_app_setting_get --app="$app" --key=db_name) +#REMOVEME? db_user=$(ynh_app_setting_get --app="$app" --key=db_user) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app="$app" --key=install_dir) +#REMOVEME? data_dir=$(ynh_app_setting_get --app="$app" --key=data_dir) #================================================= # STANDARD REMOVE @@ -47,26 +47,26 @@ ynh_remove_systemd_config #================================================= # REMOVE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Removing the PostgreSQL database..." --weight=5 +#REMOVEME? ynh_script_progression --message="Removing the PostgreSQL database..." --weight=5 # Remove a database if it exists, along with the associated user -ynh_psql_remove_db --db_user="$db_user" --db_name="$db_name" +#REMOVEME? ynh_psql_remove_db --db_user="$db_user" --db_name="$db_name" #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies..." --weight=5 +#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=5 # Remove metapackage and its dependencies -ynh_remove_app_dependencies +#REMOVEME? ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory..." --weight=1 +#REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=1 # Remove the app directory securely -ynh_secure_remove --file="$final_path" +#REMOVEME? ynh_secure_remove --file="$install_dir" #================================================= # REMOVE APP DATA DIR @@ -74,7 +74,7 @@ ynh_secure_remove --file="$final_path" ynh_script_progression --message="Removing app data directory..." --weight=1 # Remove the app directory securely -ynh_secure_remove --file="$datadir" +#REMOVEME? ynh_secure_remove --file="$data_dir" #================================================= # REMOVE NGINX CONFIGURATION @@ -125,10 +125,10 @@ ynh_secure_remove --file="/var/log/$app" #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Removing the dedicated system user..." --weight=1 +#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." --weight=1 # Delete a system user -ynh_system_user_delete --username="$app" +#REMOVEME? ynh_system_user_delete --username="$app" #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index 9247bf9..e41bce6 100755 --- a/scripts/restore +++ b/scripts/restore @@ -14,89 +14,89 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { #### Remove this function if there's nothing to clean before calling the remove script. true } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 +#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 -app="$YNH_APP_INSTANCE_NAME" +#REMOVEME? app="$YNH_APP_INSTANCE_NAME" -final_path=$(ynh_app_setting_get --app="$app" --key=final_path) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app="$app" --key=install_dir) -landing_page_user=$(ynh_app_setting_get --app="$app" --key=landing_page_user) +#REMOVEME? landing_page_user=$(ynh_app_setting_get --app="$app" --key=landing_page_user) -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) +#REMOVEME? domain=$(ynh_app_setting_get --app="$app" --key=domain) +#REMOVEME? port=$(ynh_app_setting_get --app="$app" --key=port) +#REMOVEME? path=$(ynh_app_setting_get --app="$app" --key=path) -client_max_body_size=$(ynh_app_setting_get --app="$app" --key=client_max_body_size) +#REMOVEME? client_max_body_size=$(ynh_app_setting_get --app="$app" --key=client_max_body_size) -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) +#REMOVEME? db_name=$(ynh_app_setting_get --app="$app" --key=db_name) +#REMOVEME? db_user=$(ynh_app_setting_get --app="$app" --key=db_user) +#REMOVEME? db_pwd=$(ynh_app_setting_get --app="$app" --key=db_pwd) -datadir=$(ynh_app_setting_get --app="$app" --key=datadir) +#REMOVEME? data_dir=$(ynh_app_setting_get --app="$app" --key=data_dir) -cache_memory_target=$(ynh_app_setting_get --app="$app" --key=cache_memory_target) +#REMOVEME? cache_memory_target=$(ynh_app_setting_get --app="$app" --key=cache_memory_target) -instance_expose_peers=$(ynh_app_setting_get --app="$app" --key=instance_expose_peers) -instance_expose_suspended=$(ynh_app_setting_get --app="$app" --key=instance_expose_suspended) -instance_expose_suspended_web=$(ynh_app_setting_get --app="$app" --key=instance_expose_suspended_web) -instance_expose_public_timeline=$(ynh_app_setting_get --app="$app" --key=instance_expose_public_timeline) -instance_deliver_to_shared_inboxes=$(ynh_app_setting_get --app="$app" --key=instance_deliver_to_shared_inboxes) -instance_inject_mastodon_version=$(ynh_app_setting_get --app="$app" --key=instance_inject_mastodon_version) +#REMOVEME? instance_expose_peers=$(ynh_app_setting_get --app="$app" --key=instance_expose_peers) +#REMOVEME? instance_expose_suspended=$(ynh_app_setting_get --app="$app" --key=instance_expose_suspended) +#REMOVEME? instance_expose_suspended_web=$(ynh_app_setting_get --app="$app" --key=instance_expose_suspended_web) +#REMOVEME? instance_expose_public_timeline=$(ynh_app_setting_get --app="$app" --key=instance_expose_public_timeline) +#REMOVEME? instance_deliver_to_shared_inboxes=$(ynh_app_setting_get --app="$app" --key=instance_deliver_to_shared_inboxes) +#REMOVEME? instance_inject_mastodon_version=$(ynh_app_setting_get --app="$app" --key=instance_inject_mastodon_version) -accounts_registration_open=$(ynh_app_setting_get --app="$app" --key=accounts_registration_open) -accounts_approval_required=$(ynh_app_setting_get --app="$app" --key=accounts_approval_required) -accounts_reason_required=$(ynh_app_setting_get --app="$app" --key=accounts_reason_required) -accounts_allow_custom_css=$(ynh_app_setting_get --app="$app" --key=accounts_allow_custom_css) -accounts_custom_css_length=$(ynh_app_setting_get --app="$app" --key=accounts_custom_css_length) +#REMOVEME? accounts_registration_open=$(ynh_app_setting_get --app="$app" --key=accounts_registration_open) +#REMOVEME? accounts_approval_required=$(ynh_app_setting_get --app="$app" --key=accounts_approval_required) +#REMOVEME? accounts_reason_required=$(ynh_app_setting_get --app="$app" --key=accounts_reason_required) +#REMOVEME? accounts_allow_custom_css=$(ynh_app_setting_get --app="$app" --key=accounts_allow_custom_css) +#REMOVEME? accounts_custom_css_length=$(ynh_app_setting_get --app="$app" --key=accounts_custom_css_length) -media_image_max_size=$(ynh_app_setting_get --app="$app" --key=media_image_max_size) -media_video_max_size=$(ynh_app_setting_get --app="$app" --key=media_video_max_size) -media_description_min_chars=$(ynh_app_setting_get --app="$app" --key=media_description_min_chars) -media_description_max_chars=$(ynh_app_setting_get --app="$app" --key=media_description_max_chars) -media_remote_cache_days=$(ynh_app_setting_get --app="$app" --key=media_remote_cache_days) -media_emoji_local_max_size=$(ynh_app_setting_get --app="$app" --key=media_emoji_local_max_size) -media_emoji_remote_max_size=$(ynh_app_setting_get --app="$app" --key=media_emoji_remote_max_size) +#REMOVEME? media_image_max_size=$(ynh_app_setting_get --app="$app" --key=media_image_max_size) +#REMOVEME? media_video_max_size=$(ynh_app_setting_get --app="$app" --key=media_video_max_size) +#REMOVEME? media_description_min_chars=$(ynh_app_setting_get --app="$app" --key=media_description_min_chars) +#REMOVEME? media_description_max_chars=$(ynh_app_setting_get --app="$app" --key=media_description_max_chars) +#REMOVEME? media_remote_cache_days=$(ynh_app_setting_get --app="$app" --key=media_remote_cache_days) +#REMOVEME? media_emoji_local_max_size=$(ynh_app_setting_get --app="$app" --key=media_emoji_local_max_size) +#REMOVEME? media_emoji_remote_max_size=$(ynh_app_setting_get --app="$app" --key=media_emoji_remote_max_size) -storage_backend=$(ynh_app_setting_get --app="$app" --key=storage_backend) -storage_s3_endpoint=$(ynh_app_setting_get --app="$app" --key=storage_s3_endpoint) -storage_s3_proxy=$(ynh_app_setting_get --app="$app" --key=storage_s3_proxy) -storage_s3_access_key=$(ynh_app_setting_get --app="$app" --key=storage_s3_access_key) -storage_s3_secret_key=$(ynh_app_setting_get --app="$app" --key=storage_s3_secret_key) -storage_s3_bucket=$(ynh_app_setting_get --app="$app" --key=storage_s3_bucket) +#REMOVEME? storage_backend=$(ynh_app_setting_get --app="$app" --key=storage_backend) +#REMOVEME? storage_s3_endpoint=$(ynh_app_setting_get --app="$app" --key=storage_s3_endpoint) +#REMOVEME? storage_s3_proxy=$(ynh_app_setting_get --app="$app" --key=storage_s3_proxy) +#REMOVEME? storage_s3_access_key=$(ynh_app_setting_get --app="$app" --key=storage_s3_access_key) +#REMOVEME? storage_s3_secret_key=$(ynh_app_setting_get --app="$app" --key=storage_s3_secret_key) +#REMOVEME? storage_s3_bucket=$(ynh_app_setting_get --app="$app" --key=storage_s3_bucket) -statuses_max_chars=$(ynh_app_setting_get --app="$app" --key=statuses_max_chars) -statuses_cw_max_chars=$(ynh_app_setting_get --app="$app" --key=statuses_cw_max_chars) -statuses_poll_max_options=$(ynh_app_setting_get --app="$app" --key=statuses_poll_max_options) -statuses_poll_option_max_chars=$(ynh_app_setting_get --app="$app" --key=statuses_poll_option_max_chars) -statuses_media_max_files=$(ynh_app_setting_get --app="$app" --key=statuses_media_max_files) +#REMOVEME? statuses_max_chars=$(ynh_app_setting_get --app="$app" --key=statuses_max_chars) +#REMOVEME? statuses_cw_max_chars=$(ynh_app_setting_get --app="$app" --key=statuses_cw_max_chars) +#REMOVEME? statuses_poll_max_options=$(ynh_app_setting_get --app="$app" --key=statuses_poll_max_options) +#REMOVEME? statuses_poll_option_max_chars=$(ynh_app_setting_get --app="$app" --key=statuses_poll_option_max_chars) +#REMOVEME? statuses_media_max_files=$(ynh_app_setting_get --app="$app" --key=statuses_media_max_files) -smtp_host=$(ynh_app_setting_get --app="$app" --key=smtp_host) -smtp_port=$(ynh_app_setting_get --app="$app" --key=smtp_port) -smtp_username=$(ynh_app_setting_get --app="$app" --key=smtp_username) -smtp_password=$(ynh_app_setting_get --app="$app" --key=smtp_password) -smtp_from=$(ynh_app_setting_get --app="$app" --key=smtp_from) -smtp_disclose_recipients=$(ynh_app_setting_get --app="$app" --key=smtp_disclose_recipients) +#REMOVEME? smtp_host=$(ynh_app_setting_get --app="$app" --key=smtp_host) +#REMOVEME? smtp_port=$(ynh_app_setting_get --app="$app" --key=smtp_port) +#REMOVEME? smtp_username=$(ynh_app_setting_get --app="$app" --key=smtp_username) +#REMOVEME? smtp_password=$(ynh_app_setting_get --app="$app" --key=smtp_password) +#REMOVEME? smtp_from=$(ynh_app_setting_get --app="$app" --key=smtp_from) +#REMOVEME? smtp_disclose_recipients=$(ynh_app_setting_get --app="$app" --key=smtp_disclose_recipients) -advanced_cookies_samesite=$(ynh_app_setting_get --app="$app" --key=advanced_cookies_samesite) -advanced_rate_limit_requests=$(ynh_app_setting_get --app="$app" --key=advanced_rate_limit_requests) +#REMOVEME? advanced_cookies_samesite=$(ynh_app_setting_get --app="$app" --key=advanced_cookies_samesite) +#REMOVEME? advanced_rate_limit_requests=$(ynh_app_setting_get --app="$app" --key=advanced_rate_limit_requests) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." --weight=1 +#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=1 -test ! -d "$final_path" \ - || ynh_die --message="There is already a directory: $final_path " +#REMOVEME? test ! -d "$install_dir" \ + || ynh_die --message="There is already a directory: $install_dir " #================================================= # STANDARD RESTORATION STEPS @@ -110,17 +110,17 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 +#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 # Create the dedicated user (if not existing) -ynh_system_user_create --username="$app" --home_dir="$final_path" +#REMOVEME? ynh_system_user_create --username="$app" --home_dir="$install_dir" #================================================= # RESTORE THE APP MAIN DIR #================================================= ynh_script_progression --message="Restoring the app main directory..." --weight=1 -ynh_restore_file --origin_path="$final_path" +ynh_restore_file --origin_path="$install_dir" # FIXME: this should be managed by the core in the future # Here, as a packager, you may have to tweak the ownerhsip/permissions @@ -128,18 +128,18 @@ ynh_restore_file --origin_path="$final_path" # files in some cases. # But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder - # this will be treated as a security issue. -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R "$app:www-data" "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R "$app:www-data" "$install_dir" #================================================= # RESTORE THE DATA DIRECTORY #================================================= ynh_script_progression --message="Restoring the data directory..." --weight=5 -ynh_restore_file --origin_path="$datadir" --not_mandatory +ynh_restore_file --origin_path="$data_dir" --not_mandatory -mkdir -p "$datadir" +mkdir -p "$data_dir" # FIXME: this should be managed by the core in the future # Here, as a packager, you may have to tweak the ownerhsip/permissions @@ -147,27 +147,27 @@ mkdir -p "$datadir" # files in some cases. # But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder - # this will be treated as a security issue. -chmod 750 "$datadir" -chmod -R o-rwx "$datadir" -chown -R "$app:www-data" "$datadir" +chmod 750 "$data_dir" +chmod -R o-rwx "$data_dir" +chown -R "$app:www-data" "$data_dir" #================================================= # SPECIFIC RESTORATION #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=5 +#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=5 # Define and install dependencies -ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies" +#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies" #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=5 +#REMOVEME? ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=5 -ynh_psql_test_if_first_run -ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" --db_pwd="$db_pwd" +#REMOVEME? ynh_psql_test_if_first_run +#REMOVEME? ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" --db_pwd="$db_pwd" ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS unaccent;" --database="$db_name" ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database="$db_name" ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS citext;" --database="$db_name" @@ -188,12 +188,12 @@ architecture="$(detect_arch)" # compare if the system arch is different from the binary arch # if so, download the correct binary -if [ "$architecture" != "$(file "$final_path"/gotosocial | cut -d ',' -f 2 | tr -d ' ')" ] +if [ "$architecture" != "$(file "$install_dir"/gotosocial | cut -d ',' -f 2 | tr -d ' ')" ] then ynh_script_progression --message="Migrating binary architecture..." # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" --source_id="$architecture" --keep="config.yaml" + ynh_setup_source --dest_dir="$install_dir" --keep="config.yaml" fi # FIXME: this should be managed by the core in the future @@ -202,9 +202,9 @@ fi # files in some cases. # But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder _ # this will be treated as a security issue. -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R "$app:www-data" "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R "$app:www-data" "$install_dir" #================================================= # RESTORE VARIOUS FILES diff --git a/scripts/upgrade b/scripts/upgrade index 1e54fd0..0a8e199 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,71 +12,71 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +#REMOVEME? ynh_script_progression --message="Loading installation settings..." -app="$YNH_APP_INSTANCE_NAME" +#REMOVEME? app="$YNH_APP_INSTANCE_NAME" -final_path=$(ynh_app_setting_get --app="$app" --key=final_path) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app="$app" --key=install_dir) -landing_page_user=$(ynh_app_setting_get --app="$app" --key=landing_page_user) +#REMOVEME? landing_page_user=$(ynh_app_setting_get --app="$app" --key=landing_page_user) -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) +#REMOVEME? domain=$(ynh_app_setting_get --app="$app" --key=domain) +#REMOVEME? port=$(ynh_app_setting_get --app="$app" --key=port) +#REMOVEME? path=$(ynh_app_setting_get --app="$app" --key=path) -client_max_body_size=$(ynh_app_setting_get --app="$app" --key=client_max_body_size) +#REMOVEME? client_max_body_size=$(ynh_app_setting_get --app="$app" --key=client_max_body_size) -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) +#REMOVEME? db_name=$(ynh_app_setting_get --app="$app" --key=db_name) +#REMOVEME? db_user=$(ynh_app_setting_get --app="$app" --key=db_user) +#REMOVEME? db_pwd=$(ynh_app_setting_get --app="$app" --key=db_pwd) -datadir=$(ynh_app_setting_get --app="$app" --key=datadir) +#REMOVEME? data_dir=$(ynh_app_setting_get --app="$app" --key=data_dir) -cache_memory_target=$(ynh_app_setting_get --app="$app" --key=cache_memory_target) +#REMOVEME? cache_memory_target=$(ynh_app_setting_get --app="$app" --key=cache_memory_target) -instance_expose_peers=$(ynh_app_setting_get --app="$app" --key=instance_expose_peers) -instance_expose_suspended=$(ynh_app_setting_get --app="$app" --key=instance_expose_suspended) -instance_expose_suspended_web=$(ynh_app_setting_get --app="$app" --key=instance_expose_suspended_web) -instance_expose_public_timeline=$(ynh_app_setting_get --app="$app" --key=instance_expose_public_timeline) -instance_deliver_to_shared_inboxes=$(ynh_app_setting_get --app="$app" --key=instance_deliver_to_shared_inboxes) -instance_inject_mastodon_version=$(ynh_app_setting_get --app="$app" --key=instance_inject_mastodon_version) +#REMOVEME? instance_expose_peers=$(ynh_app_setting_get --app="$app" --key=instance_expose_peers) +#REMOVEME? instance_expose_suspended=$(ynh_app_setting_get --app="$app" --key=instance_expose_suspended) +#REMOVEME? instance_expose_suspended_web=$(ynh_app_setting_get --app="$app" --key=instance_expose_suspended_web) +#REMOVEME? instance_expose_public_timeline=$(ynh_app_setting_get --app="$app" --key=instance_expose_public_timeline) +#REMOVEME? instance_deliver_to_shared_inboxes=$(ynh_app_setting_get --app="$app" --key=instance_deliver_to_shared_inboxes) +#REMOVEME? instance_inject_mastodon_version=$(ynh_app_setting_get --app="$app" --key=instance_inject_mastodon_version) -accounts_registration_open=$(ynh_app_setting_get --app="$app" --key=accounts_registration_open) -accounts_approval_required=$(ynh_app_setting_get --app="$app" --key=accounts_approval_required) -accounts_reason_required=$(ynh_app_setting_get --app="$app" --key=accounts_reason_required) -accounts_allow_custom_css=$(ynh_app_setting_get --app="$app" --key=accounts_allow_custom_css) -accounts_custom_css_length=$(ynh_app_setting_get --app="$app" --key=accounts_custom_css_length) +#REMOVEME? accounts_registration_open=$(ynh_app_setting_get --app="$app" --key=accounts_registration_open) +#REMOVEME? accounts_approval_required=$(ynh_app_setting_get --app="$app" --key=accounts_approval_required) +#REMOVEME? accounts_reason_required=$(ynh_app_setting_get --app="$app" --key=accounts_reason_required) +#REMOVEME? accounts_allow_custom_css=$(ynh_app_setting_get --app="$app" --key=accounts_allow_custom_css) +#REMOVEME? accounts_custom_css_length=$(ynh_app_setting_get --app="$app" --key=accounts_custom_css_length) -media_image_max_size=$(ynh_app_setting_get --app="$app" --key=media_image_max_size) -media_video_max_size=$(ynh_app_setting_get --app="$app" --key=media_video_max_size) -media_description_min_chars=$(ynh_app_setting_get --app="$app" --key=media_description_min_chars) -media_description_max_chars=$(ynh_app_setting_get --app="$app" --key=media_description_max_chars) -media_remote_cache_days=$(ynh_app_setting_get --app="$app" --key=media_remote_cache_days) -media_emoji_local_max_size=$(ynh_app_setting_get --app="$app" --key=media_emoji_local_max_size) -media_emoji_remote_max_size=$(ynh_app_setting_get --app="$app" --key=media_emoji_remote_max_size) +#REMOVEME? media_image_max_size=$(ynh_app_setting_get --app="$app" --key=media_image_max_size) +#REMOVEME? media_video_max_size=$(ynh_app_setting_get --app="$app" --key=media_video_max_size) +#REMOVEME? media_description_min_chars=$(ynh_app_setting_get --app="$app" --key=media_description_min_chars) +#REMOVEME? media_description_max_chars=$(ynh_app_setting_get --app="$app" --key=media_description_max_chars) +#REMOVEME? media_remote_cache_days=$(ynh_app_setting_get --app="$app" --key=media_remote_cache_days) +#REMOVEME? media_emoji_local_max_size=$(ynh_app_setting_get --app="$app" --key=media_emoji_local_max_size) +#REMOVEME? media_emoji_remote_max_size=$(ynh_app_setting_get --app="$app" --key=media_emoji_remote_max_size) -storage_backend=$(ynh_app_setting_get --app="$app" --key=storage_backend) -storage_s3_endpoint=$(ynh_app_setting_get --app="$app" --key=storage_s3_endpoint) -storage_s3_proxy=$(ynh_app_setting_get --app="$app" --key=storage_s3_proxy) -storage_s3_access_key=$(ynh_app_setting_get --app="$app" --key=storage_s3_access_key) -storage_s3_secret_key=$(ynh_app_setting_get --app="$app" --key=storage_s3_secret_key) -storage_s3_bucket=$(ynh_app_setting_get --app="$app" --key=storage_s3_bucket) +#REMOVEME? storage_backend=$(ynh_app_setting_get --app="$app" --key=storage_backend) +#REMOVEME? storage_s3_endpoint=$(ynh_app_setting_get --app="$app" --key=storage_s3_endpoint) +#REMOVEME? storage_s3_proxy=$(ynh_app_setting_get --app="$app" --key=storage_s3_proxy) +#REMOVEME? storage_s3_access_key=$(ynh_app_setting_get --app="$app" --key=storage_s3_access_key) +#REMOVEME? storage_s3_secret_key=$(ynh_app_setting_get --app="$app" --key=storage_s3_secret_key) +#REMOVEME? storage_s3_bucket=$(ynh_app_setting_get --app="$app" --key=storage_s3_bucket) -statuses_max_chars=$(ynh_app_setting_get --app="$app" --key=statuses_max_chars) -statuses_cw_max_chars=$(ynh_app_setting_get --app="$app" --key=statuses_cw_max_chars) -statuses_poll_max_options=$(ynh_app_setting_get --app="$app" --key=statuses_poll_max_options) -statuses_poll_option_max_chars=$(ynh_app_setting_get --app="$app" --key=statuses_poll_option_max_chars) -statuses_media_max_files=$(ynh_app_setting_get --app="$app" --key=statuses_media_max_files) +#REMOVEME? statuses_max_chars=$(ynh_app_setting_get --app="$app" --key=statuses_max_chars) +#REMOVEME? statuses_cw_max_chars=$(ynh_app_setting_get --app="$app" --key=statuses_cw_max_chars) +#REMOVEME? statuses_poll_max_options=$(ynh_app_setting_get --app="$app" --key=statuses_poll_max_options) +#REMOVEME? statuses_poll_option_max_chars=$(ynh_app_setting_get --app="$app" --key=statuses_poll_option_max_chars) +#REMOVEME? statuses_media_max_files=$(ynh_app_setting_get --app="$app" --key=statuses_media_max_files) -smtp_host=$(ynh_app_setting_get --app="$app" --key=smtp_host) -smtp_port=$(ynh_app_setting_get --app="$app" --key=smtp_port) -smtp_username=$(ynh_app_setting_get --app="$app" --key=smtp_username) -smtp_password=$(ynh_app_setting_get --app="$app" --key=smtp_password) -smtp_from=$(ynh_app_setting_get --app="$app" --key=smtp_from) -smtp_disclose_recipients=$(ynh_app_setting_get --app="$app" --key=smtp_disclose_recipients) +#REMOVEME? smtp_host=$(ynh_app_setting_get --app="$app" --key=smtp_host) +#REMOVEME? smtp_port=$(ynh_app_setting_get --app="$app" --key=smtp_port) +#REMOVEME? smtp_username=$(ynh_app_setting_get --app="$app" --key=smtp_username) +#REMOVEME? smtp_password=$(ynh_app_setting_get --app="$app" --key=smtp_password) +#REMOVEME? smtp_from=$(ynh_app_setting_get --app="$app" --key=smtp_from) +#REMOVEME? smtp_disclose_recipients=$(ynh_app_setting_get --app="$app" --key=smtp_disclose_recipients) -advanced_cookies_samesite=$(ynh_app_setting_get --app="$app" --key=advanced_cookies_samesite) -advanced_rate_limit_requests=$(ynh_app_setting_get --app="$app" --key=advanced_rate_limit_requests) +#REMOVEME? advanced_cookies_samesite=$(ynh_app_setting_get --app="$app" --key=advanced_cookies_samesite) +#REMOVEME? advanced_rate_limit_requests=$(ynh_app_setting_get --app="$app" --key=advanced_rate_limit_requests) #================================================= # CHECK VERSION @@ -93,16 +93,16 @@ 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)..." +#REMOVEME? 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 -ynh_clean_setup () { +#REMOVEME? ynh_backup_before_upgrade +#REMOVEME? ynh_clean_setup () { # Restore it if the upgrade fails - ynh_restore_upgradebackup +#REMOVEME? ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # STANDARD UPGRADE STEPS @@ -122,9 +122,9 @@ ynh_script_progression --message="Ensuring downward compatibility..." if ynh_compare_current_package_version --comparison lt --version 0.2.1~ynh4 || [ -z "$db_user" ] then # import old parameters - 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) +#REMOVEME? registration_open=$(ynh_app_setting_get --app="$app" --key=registration_open) +#REMOVEME? registration_approval=$(ynh_app_setting_get --app="$app" --key=registration_approval) +#REMOVEME? registration_reason=$(ynh_app_setting_get --app="$app" --key=registration_reason) # declaration of new parameters client_max_body_size="100M" media_image_max_size="2097152" @@ -143,7 +143,7 @@ then registration_reason=$(convert_bool "$registration_reason") # fix db_user existence db_user=$db_name - ynh_app_setting_set --app="$app" --key=db_user --value="$db_user" +#REMOVEME? ynh_app_setting_set --app="$app" --key=db_user --value="$db_user" # registration of new parameters ynh_app_setting_set --app="$app" --key=client_max_body_size --value="$client_max_body_size" ynh_app_setting_set --app="$app" --key=media_image_max_size --value="$media_image_max_size" @@ -166,9 +166,9 @@ fi if ynh_compare_current_package_version --comparison lt --version 0.3.7~ynh1 || [ -z "$instance_expose_peers" ] then # import old parameters - 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) +#REMOVEME? registration_open=$(ynh_app_setting_get --app="$app" --key=registration_open) +#REMOVEME? registration_approval=$(ynh_app_setting_get --app="$app" --key=registration_approval) +#REMOVEME? registration_reason=$(ynh_app_setting_get --app="$app" --key=registration_reason) # declaration of new parameters instance_expose_peers="false" instance_expose_suspended="false" @@ -261,9 +261,9 @@ then smtp_disclose_recipients="false" # registration of parameters ynh_app_setting_set --app="$app" --key=smtp_host --value="$smtp_host" - ynh_app_setting_set --app="$app" --key=smtp_port --value="$smtp_port" +#REMOVEME? ynh_app_setting_set --app="$app" --key=smtp_port --value="$smtp_port" ynh_app_setting_set --app="$app" --key=smtp_username --value="$smtp_username" - ynh_app_setting_set --app="$app" --key=smtp_password --value="$smtp_password" +#REMOVEME? ynh_app_setting_set --app="$app" --key=smtp_password --value="$smtp_password" ynh_app_setting_set --app="$app" --key=smtp_from --value="$smtp_from" ynh_app_setting_set --app="$app" --key=smtp_disclose_recipients --value="$smtp_disclose_recipients" fi @@ -272,10 +272,10 @@ fi if ynh_compare_current_package_version --comparison lt --version 0.8.0~ynh3 then # get settings from problem key - allow_custom_css=$(ynh_app_setting_get --app="$app" --key=allow_custom_css) - approval_required=$(ynh_app_setting_get --app="$app" --key=approval_required) - reason_required=$(ynh_app_setting_get --app="$app" --key=reason_required) - registration_open=$(ynh_app_setting_get --app="$app" --key=registration_open) +#REMOVEME? allow_custom_css=$(ynh_app_setting_get --app="$app" --key=allow_custom_css) +#REMOVEME? approval_required=$(ynh_app_setting_get --app="$app" --key=approval_required) +#REMOVEME? reason_required=$(ynh_app_setting_get --app="$app" --key=reason_required) +#REMOVEME? registration_open=$(ynh_app_setting_get --app="$app" --key=registration_open) # apply setting to correct key if set on old key if [ -n "$allow_custom_css" ] then @@ -329,10 +329,10 @@ fi #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." +#REMOVEME? 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" +#REMOVEME? ynh_system_user_create --username="$app" --home_dir="$install_dir" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -346,7 +346,7 @@ then architecture=$(detect_arch) # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" --source_id="$architecture" --keep="config.yaml" + ynh_setup_source --dest_dir="$install_dir" --keep="config.yaml" fi # FIXME: this should be managed by the core in the future @@ -355,9 +355,9 @@ fi # files in some cases. # But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder - # this will be treated as a security issue. -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R "$app:www-data" "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R "$app:www-data" "$install_dir" #================================================= # NGINX CONFIGURATION @@ -370,9 +370,9 @@ ynh_add_nginx_config #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading dependencies..." +#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." -ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies" +#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies" #================================================= # UPDATE A CONFIG FILE @@ -384,13 +384,13 @@ ynh_script_progression --message="Updating a configuration file..." ### 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="config.yaml" --destination="$final_path/config.yaml" +ynh_add_config --template="config.yaml" --destination="$install_dir/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/config.yaml" -chown "$app:$app" "$final_path/config.yaml" +chmod 400 "$install_dir/config.yaml" +chown "$app:$app" "$install_dir/config.yaml" #================================================= # SETUP SYSTEMD @@ -435,9 +435,9 @@ ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$ #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." -ynh_systemd_action --service_name=nginx --action=reload +#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT