From f1afa9176554d30d48a8fad0f83b1cde5a0483ee Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 23 Feb 2023 23:34:46 +0100 Subject: [PATCH 01/11] [autopatch] Upgrade auto-updater --- .github/workflows/updater.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/updater.yml b/.github/workflows/updater.yml index 6f3c1b92..64f2a2f8 100644 --- a/.github/workflows/updater.yml +++ b/.github/workflows/updater.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Fetch the source code - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: token: ${{ secrets.GITHUB_TOKEN }} - name: Run the updater script @@ -33,7 +33,7 @@ jobs: - name: Create Pull Request id: cpr if: ${{ env.PROCEED == 'true' }} - uses: peter-evans/create-pull-request@v3 + uses: peter-evans/create-pull-request@v4 with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: Update to version ${{ env.VERSION }} From 2cb6e7e12e0bb511f7ab498b2ab36e2050ce5f43 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Thu, 23 Feb 2023 22:34:53 +0000 Subject: [PATCH 02/11] Auto-update README --- README.md | 1 + README_fr.md | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index 94923284..58c72e50 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ It shall NOT be edited by hand. # Hubzilla for YunoHost [![Integration level](https://dash.yunohost.org/integration/hubzilla.svg)](https://dash.yunohost.org/appci/app/hubzilla) ![Working status](https://ci-apps.yunohost.org/ci/badges/hubzilla.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/hubzilla.maintain.svg) + [![Install Hubzilla with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=hubzilla) *[Lire ce readme en français.](./README_fr.md)* diff --git a/README_fr.md b/README_fr.md index e6c63577..61154099 100644 --- a/README_fr.md +++ b/README_fr.md @@ -6,6 +6,7 @@ It shall NOT be edited by hand. # Hubzilla pour YunoHost [![Niveau d’intégration](https://dash.yunohost.org/integration/hubzilla.svg)](https://dash.yunohost.org/appci/app/hubzilla) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/hubzilla.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/hubzilla.maintain.svg) + [![Installer Hubzilla avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=hubzilla) *[Read this readme in english.](./README.md)* From 2cd49caca57059a36e45237b69d424c2e90f9280 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Sun, 21 May 2023 06:08:08 +0000 Subject: [PATCH 03/11] Upgrade to v8.4.1 --- conf/app.src | 4 ++-- conf/app_addons.src | 4 ++-- manifest.json | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/conf/app.src b/conf/app.src index d7f8ac51..ac2a22ae 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://framagit.org/hubzilla/core/-/archive/8.0/core-8.0.tar.gz -SOURCE_SUM=fd345ea8569cf49ab7928fb57c7e0163409db18a67d3ce3905a78a233d2b9cbc +SOURCE_URL=https://framagit.org/hubzilla/core/-/archive/8.4.1/core-8.4.1.tar.gz +SOURCE_SUM=93dd8fc4d30da8a79a77303381b1451f8215c62f8b913e215664a9396cf47d61 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/conf/app_addons.src b/conf/app_addons.src index 803f2a06..05da7ff7 100644 --- a/conf/app_addons.src +++ b/conf/app_addons.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://framagit.org/hubzilla/addons/-/archive/8.0/addons-8.0.tar.gz -SOURCE_SUM=bbb4557b5789cffeb192c9543c6e63b0639b7eee919c5875c8f55d78e8c57706 +SOURCE_URL=https://framagit.org/hubzilla/addons/-/archive/8.4.1/addons-8.4.1.tar.gz +SOURCE_SUM=67f7b881f195b258c3d61922a6ce0f92832b907cafd5feb11b8abea4b2b055a0 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index db972ea4..965ce346 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Decentralized publication platform and social network.", "fr": "Plateforme de publication décentralisée et un réseau social." }, - "version": "8.0~ynh1", + "version": "8.4.1~ynh1", "url": "https://zotlabs.org/page/hubzilla/hubzilla-project", "upstream": { "license": "MIT", From 5b8ff7b4c09fffdde8302b44b3b4766d0f5a1959 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Sun, 21 May 2023 06:08:21 +0000 Subject: [PATCH 04/11] Auto-update README --- README.md | 3 ++- README_fr.md | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 94923284..654bba26 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ It shall NOT be edited by hand. # Hubzilla for YunoHost [![Integration level](https://dash.yunohost.org/integration/hubzilla.svg)](https://dash.yunohost.org/appci/app/hubzilla) ![Working status](https://ci-apps.yunohost.org/ci/badges/hubzilla.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/hubzilla.maintain.svg) + [![Install Hubzilla with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=hubzilla) *[Lire ce readme en français.](./README_fr.md)* @@ -18,7 +19,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in [Hubzilla](https://hub.libranet.de/directory?f=&global=1&pubforums=1) is a social networking platform built with control of your privacy at center stage. Your online communications can be as public as you wish or as private as you require. Private conversations, private photos, private videos. Your media isn't hidden behind an obscure URL which can be guessed, it is protected by state-of-the-art cross-domain authentication. What this all means for you: **less drama**. -**Shipped version:** 8.0~ynh1 +**Shipped version:** 8.4.1~ynh1 ## Screenshots diff --git a/README_fr.md b/README_fr.md index e6c63577..bd28ac56 100644 --- a/README_fr.md +++ b/README_fr.md @@ -6,6 +6,7 @@ It shall NOT be edited by hand. # Hubzilla pour YunoHost [![Niveau d’intégration](https://dash.yunohost.org/integration/hubzilla.svg)](https://dash.yunohost.org/appci/app/hubzilla) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/hubzilla.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/hubzilla.maintain.svg) + [![Installer Hubzilla avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=hubzilla) *[Read this readme in english.](./README.md)* @@ -18,7 +19,7 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po [Hubzilla](https://hub.libranet.de/directory?f=&global=1&pubforums=1) est une plate-forme de réseau social conçue avec le contrôle de votre vie privée au centre de la scène. Vos communications en ligne peuvent être aussi publiques que vous le souhaitez ou aussi privées que vous le souhaitez. Conversations privées, photos privées, vidéos privées. Votre média n'est pas caché derrière une URL obscure qui peut être devinée, il est protégé par une authentification interdomaine de pointe. Qu'est-ce que tout cela signifie pour vous : **moins de drames**. -**Version incluse :** 8.0~ynh1 +**Version incluse :** 8.4.1~ynh1 ## Captures d’écran From 4fdec90ad7cbdd68f63055fb1bdb845c3b4acffa Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sun, 21 May 2023 10:08:22 +0200 Subject: [PATCH 05/11] Update _common.sh --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index d0826a9d..f1b15037 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -6,7 +6,7 @@ # PHP APP SPECIFIC #================================================= -YNH_PHP_VERSION="8.0" +YNH_PHP_VERSION="8.1" php_dependencies="php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-imagick php${YNH_PHP_VERSION}-pgsql php${YNH_PHP_VERSION}-json" From 8c4502e021ee05c08c4fa61048d4722f865c32e8 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sun, 21 May 2023 10:11:06 +0200 Subject: [PATCH 06/11] Update _common.sh --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index f1b15037..441538f2 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -6,7 +6,7 @@ # PHP APP SPECIFIC #================================================= -YNH_PHP_VERSION="8.1" +YNH_PHP_VERSION="8.2" php_dependencies="php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-imagick php${YNH_PHP_VERSION}-pgsql php${YNH_PHP_VERSION}-json" From 6bdeea3bbf7e0cb661a10d5b40515cebda954302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 21 May 2023 10:46:19 +0200 Subject: [PATCH 07/11] v2 --- conf/app.src | 7 --- conf/app_addons.src | 7 --- conf/nginx.conf | 2 +- conf/poller-cron | 2 +- manifest.toml | 65 +++++++++++++++++++++++++++ scripts/_common.sh | 8 ++-- scripts/backup | 18 ++++---- scripts/install | 106 ++++++++++++++++++++++---------------------- scripts/remove | 32 ++++++------- scripts/restore | 64 +++++++++++++------------- scripts/upgrade | 100 ++++++++++++++++++++--------------------- 11 files changed, 231 insertions(+), 180 deletions(-) delete mode 100644 conf/app.src delete mode 100644 conf/app_addons.src create mode 100644 manifest.toml diff --git a/conf/app.src b/conf/app.src deleted file mode 100644 index ac2a22ae..00000000 --- a/conf/app.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://framagit.org/hubzilla/core/-/archive/8.4.1/core-8.4.1.tar.gz -SOURCE_SUM=93dd8fc4d30da8a79a77303381b1451f8215c62f8b913e215664a9396cf47d61 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= -SOURCE_EXTRACT=true diff --git a/conf/app_addons.src b/conf/app_addons.src deleted file mode 100644 index 05da7ff7..00000000 --- a/conf/app_addons.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://framagit.org/hubzilla/addons/-/archive/8.4.1/addons-8.4.1.tar.gz -SOURCE_SUM=67f7b881f195b258c3d61922a6ce0f92832b907cafd5feb11b8abea4b2b055a0 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= -SOURCE_EXTRACT=true diff --git a/conf/nginx.conf b/conf/nginx.conf index b17c3540..5fde905b 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -2,7 +2,7 @@ location __PATH__/ { # Path to source - alias __FINALPATH__/; + alias __INSTALL_DIR__/; if (!-e $request_filename) { rewrite ^(.*)$ /index.php?q=$1; diff --git a/conf/poller-cron b/conf/poller-cron index b07e685f..23967c05 100644 --- a/conf/poller-cron +++ b/conf/poller-cron @@ -1,2 +1,2 @@ # Run poller periodically to update Hubzilla -*/10 * * * * __APP__ /usr/bin/php__PHPVERSION__ -f __FINALPATH__/Zotlabs/Daemon/Master.php Cron > /dev/null 2>&1 +*/10 * * * * __APP__ /usr/bin/php__PHPVERSION__ -f __INSTALL_DIR__/Zotlabs/Daemon/Master.php Cron > /dev/null 2>&1 diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 00000000..02642cbf --- /dev/null +++ b/manifest.toml @@ -0,0 +1,65 @@ +packaging_format = 2 + +id = "hubzilla" +name = "Hubzilla" +description.en = "Decentralized publication platform and social network." +description.fr = "Plateforme de publication décentralisée et un réseau social." + +version = "8.4.1~ynh1" + +maintainers = ["Anmol Sharma"] + +[upstream] +license = "MIT" +website = "https://zotlabs.org/page/hubzilla/hubzilla-project" +code = "https://framagit.org/hubzilla/core" +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.9" +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 + type = "user" + + [install.database] + ask.en = "Choose the database to be used for the Hubzilla]" + ask.fr = "Choisissez la database de Hubzilla" + type = "string" + choices = ["mysql", "postgresql"] + default = "mysql" + +[resources] + [resources.sources] + [resources.sources.main] + url = "https://framagit.org/hubzilla/core/-/archive/8.4.1/core-8.4.1.tar.gz" + sha256 = "93dd8fc4d30da8a79a77303381b1451f8215c62f8b913e215664a9396cf47d61" + + [resources.sources.app_addons] + url = "https://framagit.org/hubzilla/addons/-/archive/8.4.1/addons-8.4.1.tar.gz" + sha256 = "67f7b881f195b258c3d61922a6ce0f92832b907cafd5feb11b8abea4b2b055a0" + + + [resources.system_user] + + [resources.install_dir] + + [resources.permissions] + main.url = "/" + + [resources.database] + type = "mysql" diff --git a/scripts/_common.sh b/scripts/_common.sh index 441538f2..5163543f 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -6,14 +6,14 @@ # PHP APP SPECIFIC #================================================= -YNH_PHP_VERSION="8.2" +#REMOVEME? YNH_PHP_VERSION="8.2" -php_dependencies="php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-imagick php${YNH_PHP_VERSION}-pgsql php${YNH_PHP_VERSION}-json" +#REMOVEME? php_dependencies="php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-imagick php${YNH_PHP_VERSION}-pgsql php${YNH_PHP_VERSION}-json" # dependencies used by the app (must be on a single line) -pkg_dependencies="$php_dependencies" +#REMOVEME? pkg_dependencies="$php_dependencies" -pg_pkg_dependencies="postgresql postgresql-contrib" +#REMOVEME? pg_pkg_dependencies="postgresql postgresql-contrib" #================================================= # PERSONAL HELPERS diff --git a/scripts/backup b/scripts/backup index b9d99fe9..5ede5392 100644 --- a/scripts/backup +++ b/scripts/backup @@ -14,24 +14,24 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { 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 settings..." -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? 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) -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) -database=$(ynh_app_setting_get --app=$app --key=database) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +#REMOVEME? database=$(ynh_app_setting_get --app=$app --key=database) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -42,7 +42,7 @@ 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 NGINX CONFIGURATION diff --git a/scripts/install b/scripts/install index 93b4e643..0ff4095c 100755 --- a/scripts/install +++ b/scripts/install @@ -13,23 +13,23 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { 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 #================================================= -domain=$YNH_APP_ARG_DOMAIN -path_url="/" -admin=$YNH_APP_ARG_ADMIN -database=$YNH_APP_ARG_DATABASE -phpversion=$YNH_PHP_VERSION +#REMOVEME? domain=$YNH_APP_ARG_DOMAIN +path="/" +#REMOVEME? admin=$YNH_APP_ARG_ADMIN +#REMOVEME? database=$YNH_APP_ARG_DATABASE +#REMOVEME? phpversion=$YNH_PHP_VERSION -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME email=$(ynh_user_get_info --username=$admin --key=mail) upload="256M" @@ -41,22 +41,22 @@ fpm_usage="low" #================================================= # 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" # Register (book) web path -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=domain --value=$domain -ynh_app_setting_set --app=$app --key=path --value=$path_url -ynh_app_setting_set --app=$app --key=admin --value=$admin +#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain +#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path +#REMOVEME? ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=database --value=$database ynh_app_setting_set --app=$app --key=email --value=$email ynh_app_setting_set --app=$app --key=upload --value=$upload @@ -70,41 +70,41 @@ ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --weight=1 +#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=1 if [ $database = "postgresql" ]; then - pkg_dependencies="$pkg_dependencies $pg_pkg_dependencies" +#REMOVEME? pkg_dependencies="$pkg_dependencies $pg_pkg_dependencies" fi -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 DATABASE #================================================= -db_name=$(ynh_sanitize_dbid --db_name=$app) -db_user=$db_name -ynh_app_setting_set --app=$app --key=db_name --value=$db_name +#REMOVEME? db_name=$(ynh_sanitize_dbid --db_name=$app) +#REMOVEME? db_user=$db_name +#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name if [ $database = "mysql" ]; then - ynh_script_progression --message="Creating a MySQL database..." --weight=1 - ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name +#REMOVEME? ynh_script_progression --message="Creating a MySQL database..." --weight=1 +#REMOVEME? ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name ynh_mysql_connect_as --user=$db_user --password="$db_pwd" --database=$db_name \ <<< "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;" db_type=0 elif [ $database = "postgresql" ]; then - ynh_script_progression --message="Creating a PostgreSQL database..." --weight=1 - ynh_psql_test_if_first_run - ynh_psql_setup_db --db_user=$db_user --db_name=$db_name +#REMOVEME? ynh_script_progression --message="Creating a PostgreSQL database..." --weight=1 +#REMOVEME? ynh_psql_test_if_first_run +#REMOVEME? ynh_psql_setup_db --db_user=$db_user --db_name=$db_name db_type=1 fi @@ -113,18 +113,18 @@ fi #================================================= ynh_script_progression --message="Setting up source files..." --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 # 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/addon" --source_id="app_addons" -touch "$final_path/php.log" -mkdir -p "$final_path/store" -mkdir -p "$final_path/cache/smarty3" +ynh_setup_source --dest_dir="$install_dir" +ynh_setup_source --dest_dir="$install_dir/addon" --source_id="app_addons" +touch "$install_dir/php.log" +mkdir -p "$install_dir/store" +mkdir -p "$install_dir/cache/smarty3" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" -chmod -R 775 $final_path/store $final_path/cache +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" +chmod -R 775 $install_dir/store $install_dir/cache #================================================= # PHP-FPM CONFIGURATION @@ -133,7 +133,7 @@ ynh_script_progression --message="Configuring PHP-FPM..." --weight=1 # Create a dedicated PHP-FPM config ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # NGINX CONFIGURATION @@ -151,9 +151,9 @@ ynh_add_nginx_config ynh_script_progression --message="Provisionning database..." --weight=1 if [ $database = "mysql" ]; then - ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < $final_path/install/schema_mysql.sql + ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < $install_dir/install/schema_mysql.sql elif [ $database = "postgresql" ]; then - ynh_psql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < $final_path/install/schema_postgres.sql + ynh_psql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < $install_dir/install/schema_postgres.sql fi #================================================= @@ -161,16 +161,16 @@ fi #================================================= ynh_script_progression --message="Adding a configuration file..." --weight=1 -ynh_add_config --template="../conf/htconfig.sample.php" --destination="$final_path/.htconfig.php" +ynh_add_config --template="../conf/htconfig.sample.php" --destination="$install_dir/.htconfig.php" # addon ldap config ynh_script_progression --message="Push LDAP configuration to .htconfig.php..." -cat ../conf/ldap_conf.php >> $final_path/.htconfig.php -ynh_store_file_checksum --file=$final_path/.htconfig.php +cat ../conf/ldap_conf.php >> $install_dir/.htconfig.php +ynh_store_file_checksum --file=$install_dir/.htconfig.php -chmod 600 "$final_path/.htconfig.php" -chown $app:$app "$final_path/.htconfig.php" +chmod 600 "$install_dir/.htconfig.php" +chown $app:$app "$install_dir/.htconfig.php" #================================================= # SET CRON JOB @@ -190,7 +190,7 @@ chmod 644 "/etc/cron.d/$app" ynh_script_progression --message="Configuring log rotation..." --weight=1 # Use logrotate to manage application logfile(s) -ynh_use_logrotate "$final_path/php.log" +ynh_use_logrotate "$install_dir/php.log" #================================================= # SETUP FAIL2BAN @@ -198,23 +198,23 @@ ynh_use_logrotate "$final_path/php.log" ynh_script_progression --message="Configuring Fail2Ban..." --weight=1 # Create a dedicated Fail2Ban config -ynh_add_fail2ban_config --logpath="$final_path/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP .*$" --max_retry="5" +ynh_add_fail2ban_config --logpath="$install_dir/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP .*$" --max_retry="5" #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring permissions..." --weight=1 +#REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1 # Everyone can access the app. # The "main" permission is automatically created before the install script. -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 a4d921ee..4bf5e318 100755 --- a/scripts/remove +++ b/scripts/remove @@ -14,13 +14,13 @@ source /usr/share/yunohost/helpers #================================================= ynh_script_progression --message="Loading settings..." --weight=1 -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) -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) -database=$(ynh_app_setting_get --app=$app --key=database) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? db_user=$db_name +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? database=$(ynh_app_setting_get --app=$app --key=database) #================================================= # STANDARD REMOVE @@ -38,21 +38,21 @@ ynh_remove_logrotate if [ $database = "mysql" ]; then # Removing MySQL database - ynh_script_progression --message="Removing MySQL database..." --weight=1 - ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name +#REMOVEME? ynh_script_progression --message="Removing MySQL database..." --weight=1 +#REMOVEME? ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name elif [ $database = "postgresql" ]; then # Removing PostgreSQL database - ynh_script_progression --message="Removing PostgreSQL database..." --weight=1 - ynh_psql_remove_db --db_user=$db_user --db_name=$db_name +#REMOVEME? ynh_script_progression --message="Removing PostgreSQL database..." --weight=1 +#REMOVEME? ynh_psql_remove_db --db_user=$db_user --db_name=$db_name fi #================================================= # 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 NGINX CONFIGURATION @@ -73,10 +73,10 @@ ynh_remove_fpm_config #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies..." --weight=1 +#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=1 # Remove metapackage and its dependencies -ynh_remove_app_dependencies +#REMOVEME? ynh_remove_app_dependencies #================================================= # REMOVE FAIL2BAN CONFIGURATION @@ -101,10 +101,10 @@ ynh_secure_remove --file="/etc/cron.d/$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 37001c2a..80087788 100644 --- a/scripts/restore +++ b/scripts/restore @@ -14,59 +14,59 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { 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 settings..." --weight=1 -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? 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) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) -database=$(ynh_app_setting_get --app=$app --key=database) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) +#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? db_user=$db_name +#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +#REMOVEME? database=$(ynh_app_setting_get --app=$app --key=database) -fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) -fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage) +#REMOVEME? fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) +#REMOVEME? fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage) #================================================= # 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 #================================================= # 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" -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 FAIL2BAN CONFIGURATION @@ -82,12 +82,12 @@ ynh_systemd_action --action=restart --service_name=fail2ban #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=1 +#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=1 if [ $database = "postgresql" ]; then - pkg_dependencies="$pkg_dependencies $pg_pkg_dependencies" +#REMOVEME? pkg_dependencies="$pkg_dependencies $pg_pkg_dependencies" fi -ynh_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_install_app_dependencies $pkg_dependencies #================================================= # RESTORE THE PHP-FPM CONFIGURATION @@ -111,15 +111,15 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= if [ $database = "mysql" ]; then - ynh_script_progression --message="Restoring MySQL database..." --weight=1 - db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) - ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +#REMOVEME? ynh_script_progression --message="Restoring MySQL database..." --weight=1 +#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) +#REMOVEME? ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql elif [ $database = "postgresql" ]; then - ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1 - db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) - ynh_psql_test_if_first_run - ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +#REMOVEME? ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1 +#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +#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_file_as_root --file="./db.sql" --database="$db_name" fi diff --git a/scripts/upgrade b/scripts/upgrade index d086ee34..184beb16 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -14,23 +14,23 @@ source /usr/share/yunohost/helpers #================================================= ynh_script_progression --message="Loading settings..." --weight=1 -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? 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) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) -database=$(ynh_app_setting_get --app=$app --key=database) -upload=$(ynh_app_setting_get --app=$app --key=upload) -random_string=$(ynh_app_setting_get --app=$app --key=random_string) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) +#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? db_user=$db_name +#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +#REMOVEME? database=$(ynh_app_setting_get --app=$app --key=database) +#REMOVEME? upload=$(ynh_app_setting_get --app=$app --key=upload) +#REMOVEME? random_string=$(ynh_app_setting_get --app=$app --key=random_string) email=$(ynh_user_get_info --username=$admin --key=mail) -fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) -fpm_free_footprint=$(ynh_app_setting_get --app=$app --key=fpm_free_footprint) -fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage) +#REMOVEME? fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) +#REMOVEME? fpm_free_footprint=$(ynh_app_setting_get --app=$app --key=fpm_free_footprint) +#REMOVEME? fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage) #================================================= # CHECK VERSION @@ -42,16 +42,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)..." --weight=1 +#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 # 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 @@ -60,16 +60,16 @@ ynh_abort_if_errors #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 -# 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 +# If install_dir doesn't exist, create it +if [ -z "$install_dir" ]; then +#REMOVEME? install_dir=/var/www/$app +#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir fi # 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 +#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name fi # If fpm_footprint doesn't exist, create it @@ -91,8 +91,8 @@ if [ -z "$fpm_usage" ]; then fi # Cleaning legacy permissions -if ynh_legacy_permissions_exists; then - ynh_legacy_permissions_delete_all +#REMOVEME? if ynh_legacy_permissions_exists; then +#REMOVEME? ynh_legacy_permissions_delete_all ynh_app_setting_delete --app=$app --key=is_public fi @@ -109,10 +109,10 @@ fi #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 +#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 # 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 @@ -123,26 +123,26 @@ then ynh_script_progression --message="Upgrading source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" --keep="store/ .htconfig.php php.log" - ynh_setup_source --dest_dir="$final_path/addon" --source_id="app_addons" + ynh_setup_source --dest_dir="$install_dir" --keep="store/ .htconfig.php php.log" + ynh_setup_source --dest_dir="$install_dir/addon" --source_id="app_addons" fi -mkdir -p "$final_path/store" -mkdir -p "$final_path/cache/smarty3" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" -chmod -R 775 $final_path/store $final_path/cache +mkdir -p "$install_dir/store" +mkdir -p "$install_dir/cache/smarty3" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" +chmod -R 775 $install_dir/store $install_dir/cache #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=1 +#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=1 if [ $database = "postgresql" ]; then - pkg_dependencies="$pkg_dependencies $pg_pkg_dependencies" +#REMOVEME? pkg_dependencies="$pkg_dependencies $pg_pkg_dependencies" fi -ynh_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_install_app_dependencies $pkg_dependencies #================================================= # PHP-FPM CONFIGURATION @@ -151,7 +151,7 @@ ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1 # Create a dedicated PHP-FPM config ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # NGINX CONFIGURATION @@ -170,25 +170,25 @@ ynh_script_progression --message="Updating a configuration file..." --weight=1 if [ $database = "mysql" ]; then db_type=0 - db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) +#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) # Change your databases character set and collation ynh_mysql_connect_as --user=$db_user --password="$db_pwd" --database=$db_name \ <<< "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;" elif [ $database = "postgresql" ]; then db_type=1 - db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) fi -ynh_add_config --template="../conf/htconfig.sample.php" --destination="$final_path/.htconfig.php" +ynh_add_config --template="../conf/htconfig.sample.php" --destination="$install_dir/.htconfig.php" # addon ldap config ynh_script_progression --message="Push LDAP configuration to .htconfig.php..." -cat ../conf/ldap_conf.php >> $final_path/.htconfig.php -ynh_store_file_checksum --file=$final_path/.htconfig.php +cat ../conf/ldap_conf.php >> $install_dir/.htconfig.php +ynh_store_file_checksum --file=$install_dir/.htconfig.php -chmod 600 "$final_path/.htconfig.php" -chown $app:$app "$final_path/.htconfig.php" +chmod 600 "$install_dir/.htconfig.php" +chown $app:$app "$install_dir/.htconfig.php" #================================================= # UPGRADE CRON JOB @@ -216,14 +216,14 @@ ynh_use_logrotate --non-append ynh_script_progression --message="Reconfiguring Fail2Ban..." --weight=1 # Create a dedicated Fail2Ban config -ynh_add_fail2ban_config --logpath="$final_path/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP .*$" --max_retry="5" +ynh_add_fail2ban_config --logpath="$install_dir/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP .*$" --max_retry="5" #================================================= # 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 From e26c611aaecfdfb318521bb642b65b2768488b33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 21 May 2023 11:00:26 +0200 Subject: [PATCH 08/11] v2 --- .github/workflows/updater.sh | 133 -------------------------- .github/workflows/updater.yml | 52 ---------- conf/htconfig.sample.php | 2 +- doc/ADMIN.md | 11 +++ doc/{DISCLAIMER_fr.md => ADMIN_fr.md} | 8 +- doc/DESCRIPTION.md | 2 +- doc/DESCRIPTION_fr.md | 2 +- doc/DISCLAIMER.md | 17 ---- manifest.json | 58 ----------- manifest.toml | 30 +++--- scripts/_common.sh | 9 -- scripts/backup | 34 +------ scripts/install | 104 +------------------- scripts/remove | 47 +-------- scripts/restore | 76 +-------------- scripts/upgrade | 103 +------------------- 16 files changed, 43 insertions(+), 645 deletions(-) delete mode 100644 .github/workflows/updater.sh delete mode 100644 .github/workflows/updater.yml create mode 100644 doc/ADMIN.md rename doc/{DISCLAIMER_fr.md => ADMIN_fr.md} (63%) delete mode 100644 doc/DISCLAIMER.md delete mode 100644 manifest.json diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh deleted file mode 100644 index 83913d7a..00000000 --- a/.github/workflows/updater.sh +++ /dev/null @@ -1,133 +0,0 @@ -#!/bin/bash - -#================================================= -# PACKAGE UPDATING HELPER -#================================================= - -# This script is meant to be run by GitHub Actions -# The YunoHost-Apps organisation offers a template Action to run this script periodically -# Since each app is different, maintainers can adapt its contents so as to perform -# automatic actions when a new upstream release is detected. - -#================================================= -# FETCHING LATEST RELEASE AND ITS ASSETS -#================================================= - -# Fetching information -current_version=$(cat manifest.json | jq -j '.version|split("~")[0]') -# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions) -version=$(curl --silent "https://framagit.org/api/v4/projects/27084/releases" | jq -r '.[] | select( .upcoming_release != true ) | .tag_name' | sort -V | tail -1) -assets=("https://framagit.org/hubzilla/core/-/archive/$version/core-$version.tar.gz" "https://framagit.org/hubzilla/addons/-/archive/$version/addons-$version.tar.gz") - -# Later down the script, we assume the version has only digits and dots -# Sometimes the release name starts with a "v", so let's filter it out. -# You may need more tweaks here if the upstream repository has different naming conventions. -if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then - version=${version:1} -fi - -# Setting up the environment variables -echo "Current version: $current_version" -echo "Latest release from upstream: $version" -echo "VERSION=$version" >> $GITHUB_ENV -# For the time being, let's assume the script will fail -echo "PROCEED=false" >> $GITHUB_ENV - -# Proceed only if the retrieved version is greater than the current one -if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then - echo "::warning ::No new version available" - exit 0 -# Proceed only if a PR for this new version does not already exist -elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then - echo "::warning ::A branch already exists for this update" - exit 0 -fi - -# Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.) -echo "${#assets[@]} available asset(s)" - -#================================================= -# UPDATE SOURCE FILES -#================================================= - -# Here we use the $assets variable to get the resources published in the upstream release. -# Here is an example for Grav, it has to be adapted in accordance with how the upstream releases look like. - -# Let's loop over the array of assets URLs -for asset_url in ${assets[@]}; do - - echo "Handling asset at $asset_url" - - # Assign the asset to a source file in conf/ directory - # Here we base the source file name upon a unique keyword in the assets url (admin vs. update) - # Leave $src empty to ignore the asset - case $asset_url in - *"core"*) - src="app" - ;; - *"addons"*) - src="app_addons" - ;; - *) - src="" - ;; - esac - - # If $src is not empty, let's process the asset - if [ ! -z "$src" ]; then - - # Create the temporary directory - tempdir="$(mktemp -d)" - - # Download sources and calculate checksum - filename=${asset_url##*/} - curl --silent -4 -L $asset_url -o "$tempdir/$filename" - checksum=$(sha256sum "$tempdir/$filename" | head -c 64) - - # Delete temporary directory - rm -rf $tempdir - - # Get extension - if [[ $filename == *.tar.gz ]]; then - extension=tar.gz - else - extension=${filename##*.} - fi - - # Rewrite source file - cat < conf/$src.src -SOURCE_URL=$asset_url -SOURCE_SUM=$checksum -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=$extension -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= -SOURCE_EXTRACT=true -EOT - echo "... conf/$src.src updated" - - else - echo "... asset ignored" - fi - -done - -#================================================= -# SPECIFIC UPDATE STEPS -#================================================= - -# Any action on the app's source code can be done. -# The GitHub Action workflow takes care of committing all changes after this script ends. - -#================================================= -# GENERIC FINALIZATION -#================================================= - -# Replace new version in manifest -echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json - -# No need to update the README, yunohost-bot takes care of it - -# The Action will proceed only if the PROCEED environment variable is set to true -echo "PROCEED=true" >> $GITHUB_ENV -exit 0 diff --git a/.github/workflows/updater.yml b/.github/workflows/updater.yml deleted file mode 100644 index 64f2a2f8..00000000 --- a/.github/workflows/updater.yml +++ /dev/null @@ -1,52 +0,0 @@ -# This workflow allows GitHub Actions to automagically update your app whenever a new upstream release is detected. -# You need to enable Actions in your repository settings, and fetch this Action from the YunoHost-Apps organization. -# This file should be enough by itself, but feel free to tune it to your needs. -# It calls updater.sh, which is where you should put the app-specific update steps. -name: Check for new upstream releases -on: - # Allow to manually trigger the workflow - workflow_dispatch: - # Run it every day at 6:00 UTC - schedule: - - cron: '0 6 * * *' -jobs: - updater: - runs-on: ubuntu-latest - steps: - - name: Fetch the source code - uses: actions/checkout@v3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - - name: Run the updater script - id: run_updater - run: | - # Setting up Git user - git config --global user.name 'yunohost-bot' - git config --global user.email 'yunohost-bot@users.noreply.github.com' - # Run the updater script - /bin/bash .github/workflows/updater.sh - - name: Commit changes - id: commit - if: ${{ env.PROCEED == 'true' }} - run: | - git commit -am "Upgrade to v$VERSION" - - name: Create Pull Request - id: cpr - if: ${{ env.PROCEED == 'true' }} - uses: peter-evans/create-pull-request@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - commit-message: Update to version ${{ env.VERSION }} - committer: 'yunohost-bot ' - author: 'yunohost-bot ' - signoff: false - base: testing - branch: ci-auto-update-v${{ env.VERSION }} - delete-branch: true - title: 'Upgrade to version ${{ env.VERSION }}' - body: | - Upgrade to v${{ env.VERSION }} - [See upstream release page](${{ env.RELEASE }}) - Provided description: - ${{ env.DESCRIPTION }} - draft: false diff --git a/conf/htconfig.sample.php b/conf/htconfig.sample.php index af51076b..1484262f 100644 --- a/conf/htconfig.sample.php +++ b/conf/htconfig.sample.php @@ -17,7 +17,7 @@ $db_port = 0; // leave 0 for default or set your port $db_user = '__DB_USER__'; $db_pass = '__DB_PWD__'; $db_data = '__DB_NAME__'; -$db_type = __DB_TYPE__; // use 1 for postgres, 0 for mysql +$db_type = 0; // use 1 for postgres, 0 for mysql /* * Notice: Many of the following settings will be available in the admin panel diff --git a/doc/ADMIN.md b/doc/ADMIN.md new file mode 100644 index 00000000..585d562e --- /dev/null +++ b/doc/ADMIN.md @@ -0,0 +1,11 @@ +## Ldap Admin user rights, logs and failed database updates + +- **For admin rights**: When installation is complete, you will need to visit your new hub's page and login with the **admin account username** which was entered at the time of installation process. You should then be able to create your first channel and have the **admin rights** for the hub. + +- **For normal YunoHost users**: Normal LDAP users can login through LDAP authentication and create there channels. + +- **Failing to get admin rights**: If the admin cannot access the admin settings at `https://__DOMAIN__/admin` then you have to **manually add 4096** to the **account_roles** under **accounts** for that user in the **database through phpMyAdmin**. + +- **For logs**: Go to **admin->logs** and enter the file name **php.log**. + +- **Failed Database after Upgrade:** Some times databse upgrade fails after version upgrade. You can go to hub eg. `https://__DOMAIN__/admin/dbsync/` and check the numbers of failled update. These updates will have to be ran manually by **phpMyAdmin**. diff --git a/doc/DISCLAIMER_fr.md b/doc/ADMIN_fr.md similarity index 63% rename from doc/DISCLAIMER_fr.md rename to doc/ADMIN_fr.md index cf4be09b..5ec943ba 100644 --- a/doc/DISCLAIMER_fr.md +++ b/doc/ADMIN_fr.md @@ -1,10 +1,4 @@ -## Installation -Avant l'installation, lisez les [instructions d'installation de Hubzilla](https://framagit.org/hubzilla/core/blob/master/install/INSTALL.txt) pour obtenir des informations importantes sur : - -### Enregistrez un nouveau domaine et ajoutez-le à YunoHost -- Hubzilla nécessite un domaine dédié, alors obtenez-en un et ajoutez-le à l'aide du panneau d'administration YunoHost. **Domaines -> Ajouter un domaine**. Comme Hubzilla utilise le domaine complet et est installé à la racine, vous pouvez créer un sous-domaine tel que hubzilla.domain.tld. N'oubliez pas de mettre à jour vos DNS si vous les gérez manuellement. - -## Droits d'utilisateur de l'administrateur Ldap, journaux et échec des mises à jour de la base de données +## Droits d'utilisateur de l'administrateur Ldap, journaux et échec des mises à jour de la base de données - **Pour les droits d'administrateur** : lorsque l'installation est terminée, vous devrez visiter la page de votre nouveau hub et vous connecter avec le **nom d'utilisateur du compte administrateur** qui a été saisi au moment du processus d'installation. Vous devriez alors pouvoir créer votre premier canal et disposer des **droits d'administrateur** pour le hub. diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md index ff21f97a..2007147a 100644 --- a/doc/DESCRIPTION.md +++ b/doc/DESCRIPTION.md @@ -1 +1 @@ -[Hubzilla](https://hub.libranet.de/directory?f=&global=1&pubforums=1) is a social networking platform built with control of your privacy at center stage. Your online communications can be as public as you wish or as private as you require. Private conversations, private photos, private videos. Your media isn't hidden behind an obscure URL which can be guessed, it is protected by state-of-the-art cross-domain authentication. What this all means for you: **less drama**. +Hubzilla is a social networking platform built with control of your privacy at center stage. Your online communications can be as public as you wish or as private as you require. Private conversations, private photos, private videos. Your media isn't hidden behind an obscure URL which can be guessed, it is protected by state-of-the-art cross-domain authentication. diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md index 11636de6..390a662f 100644 --- a/doc/DESCRIPTION_fr.md +++ b/doc/DESCRIPTION_fr.md @@ -1 +1 @@ -[Hubzilla](https://hub.libranet.de/directory?f=&global=1&pubforums=1) est une plate-forme de réseau social conçue avec le contrôle de votre vie privée au centre de la scène. Vos communications en ligne peuvent être aussi publiques que vous le souhaitez ou aussi privées que vous le souhaitez. Conversations privées, photos privées, vidéos privées. Votre média n'est pas caché derrière une URL obscure qui peut être devinée, il est protégé par une authentification interdomaine de pointe. Qu'est-ce que tout cela signifie pour vous : **moins de drames**. +Hubzilla est une plate-forme de réseau social conçue avec le contrôle de votre vie privée au centre de la scène. Vos communications en ligne peuvent être aussi publiques que vous le souhaitez ou aussi privées que vous le souhaitez. Conversations privées, photos privées, vidéos privées. Votre média n'est pas caché derrière une URL obscure qui peut être devinée, il est protégé par une authentification interdomaine de pointe. diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md deleted file mode 100644 index 7fbd776d..00000000 --- a/doc/DISCLAIMER.md +++ /dev/null @@ -1,17 +0,0 @@ -## Installation -Before installing, read the [Hubzilla installation instructions](https://framagit.org/hubzilla/core/blob/master/install/INSTALL.txt) for important information about: - -### Register a new domain and add it to YunoHost -- Hubzilla requires a dedicated domain, so obtain one and add it using the YunoHost admin panel. **Domains -> Add domain**. As Hubzilla uses the full domain and is installed on the root, you can create a subdomain such as hubzilla.domain.tld. Don't forget to update your DNS if you manage them manually. - -## Ldap Admin user rights, logs and failed database updates - -- **For admin rights**: When installation is complete, you will need to visit your new hub's page and login with the **admin account username** which was entered at the time of installation process. You should then be able to create your first channel and have the **admin rights** for the hub. - -- **For normal YunoHost users**: Normal LDAP users can login through LDAP authentication and create there channels. - -- **Failing to get admin rights**: If the admin cannot access the admin settings at `https://hubzilla.example.com/admin` then you have to **manually add 4096** to the **account_roles** under **accounts** for that user in the **database through phpMyAdmin**. - -- **For logs**: Go to **admin->logs** and enter the file name **php.log**. - -- **Failed Database after Upgrade:** Some times databse upgrade fails after version upgrade. You can go to hub eg. `https://hubzilla.example.com/admin/dbsync/` and check the numbers of failled update. These updates will have to be ran manually by **phpMyAdmin**. diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 965ce346..00000000 --- a/manifest.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "packaging_format": 1, - "id": "hubzilla", - "name": "Hubzilla", - "description": { - "en": "Decentralized publication platform and social network.", - "fr": "Plateforme de publication décentralisée et un réseau social." - }, - "version": "8.4.1~ynh1", - "url": "https://zotlabs.org/page/hubzilla/hubzilla-project", - "upstream": { - "license": "MIT", - "website": "https://zotlabs.org/page/hubzilla/hubzilla-project", - "code": "https://framagit.org/hubzilla/core" - }, - "license": "MIT", - "maintainer": { - "name": "Anmol Sharma" - }, - "previous_maintainers": { - "name": "Andrew Manning", - "email": "andrew@reticu.li" - }, - "requirements": { - "yunohost": ">= 11.0.9" - }, - "multi_instance": true, - "services": [ - "nginx", - "php8.0-fpm", - "mysql" - ], - "arguments": { - "install": [ - { - "name": "domain", - "type": "domain" - }, - { - "name": "admin", - "type": "user" - }, - { - "name": "database", - "type": "string", - "ask": { - "en": "Choose the database to be used for the Hubzilla]", - "fr": "Choisissez la database de Hubzilla" - }, - "choices": [ - "mysql", - "postgresql" - ], - "default": "mysql" - } - ] - } -} diff --git a/manifest.toml b/manifest.toml index 02642cbf..5f1eb927 100644 --- a/manifest.toml +++ b/manifest.toml @@ -13,45 +13,36 @@ maintainers = ["Anmol Sharma"] license = "MIT" website = "https://zotlabs.org/page/hubzilla/hubzilla-project" code = "https://framagit.org/hubzilla/core" -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.9" -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"] +yunohost = ">= 11.1.19" +architectures = "all" 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, ... +ldap = true +sso = false +disk = "50M" +ram.build = "50M" +ram.runtime = "50M" [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 type = "user" - [install.database] - ask.en = "Choose the database to be used for the Hubzilla]" - ask.fr = "Choisissez la database de Hubzilla" - type = "string" - choices = ["mysql", "postgresql"] - default = "mysql" - [resources] [resources.sources] [resources.sources.main] url = "https://framagit.org/hubzilla/core/-/archive/8.4.1/core-8.4.1.tar.gz" sha256 = "93dd8fc4d30da8a79a77303381b1451f8215c62f8b913e215664a9396cf47d61" + autoupdate.strategy = "latest_github_tag" [resources.sources.app_addons] url = "https://framagit.org/hubzilla/addons/-/archive/8.4.1/addons-8.4.1.tar.gz" sha256 = "67f7b881f195b258c3d61922a6ce0f92832b907cafd5feb11b8abea4b2b055a0" + autoupdate.strategy = "latest_github_tag" [resources.system_user] @@ -61,5 +52,8 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen [resources.permissions] main.url = "/" + [resources.apt] + packages = "mariadb-server php8.2-curl php8.2-gd php8.2-mysql php8.2-mbstring php8.2-xml php8.2-zip php8.2-cli php8.2-imagick" + [resources.database] type = "mysql" diff --git a/scripts/_common.sh b/scripts/_common.sh index 5163543f..1e47ce72 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -6,15 +6,6 @@ # PHP APP SPECIFIC #================================================= -#REMOVEME? YNH_PHP_VERSION="8.2" - -#REMOVEME? php_dependencies="php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-imagick php${YNH_PHP_VERSION}-pgsql php${YNH_PHP_VERSION}-json" - -# dependencies used by the app (must be on a single line) -#REMOVEME? pkg_dependencies="$php_dependencies" - -#REMOVEME? pg_pkg_dependencies="postgresql postgresql-contrib" - #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index 5ede5392..9d780ff6 100644 --- a/scripts/backup +++ b/scripts/backup @@ -10,29 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? ynh_clean_setup () { - true -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_print_info --message="Loading settings..." - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) -#REMOVEME? database=$(ynh_app_setting_get --app=$app --key=database) - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= @@ -80,16 +57,9 @@ ynh_backup --src_path="/etc/cron.d/$app" #================================================= # BACKUP THE DATABASE #================================================= +ynh_print_info --message="Backup of the MySQL database..." -if [ $database = "mysql" ]; then - # Backup MySQL database - ynh_print_info --message="Backup of the MySQL database..." - ynh_mysql_dump_db --database="$db_name" > db.sql -elif [ $database = "postgresql" ]; then - # Backup PostgreSQL database - ynh_print_info --message="Backup of the PostgreSQL database..." - ynh_psql_dump_db --database="$db_name" > db.sql -fi +ynh_mysql_dump_db --database="$db_name" > db.sql #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 0ff4095c..a0f6d82a 100755 --- a/scripts/install +++ b/scripts/install @@ -9,54 +9,23 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? ynh_clean_setup () { - true -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -#REMOVEME? domain=$YNH_APP_ARG_DOMAIN -path="/" -#REMOVEME? admin=$YNH_APP_ARG_ADMIN -#REMOVEME? database=$YNH_APP_ARG_DATABASE -#REMOVEME? phpversion=$YNH_PHP_VERSION - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - email=$(ynh_user_get_info --username=$admin --key=mail) upload="256M" random_string="$(ynh_string_random --length=48)" + fpm_footprint="low" fpm_free_footprint=0 fpm_usage="low" -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= -#REMOVEME? ynh_script_progression --message="Validating installation parameters..." --weight=1 - -#REMOVEME? install_dir=/var/www/$app -#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder" - -# Register (book) web path -#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path - #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -#REMOVEME? ynh_script_progression --message="Storing installation settings..." --weight=1 +ynh_script_progression --message="Storing installation settings..." --weight=1 -#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain -#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path -#REMOVEME? ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=database --value=$database ynh_app_setting_set --app=$app --key=email --value=$email ynh_app_setting_set --app=$app --key=upload --value=$upload @@ -65,63 +34,19 @@ ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage -#================================================= -# STANDARD MODIFICATIONS -#================================================= -# INSTALL DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=1 - -if [ $database = "postgresql" ]; then -#REMOVEME? pkg_dependencies="$pkg_dependencies $pg_pkg_dependencies" -fi -#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# CREATE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Configuring system user..." --weight=1 - -# Create a system user -#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" - -#================================================= -# CREATE A DATABASE -#================================================= - -#REMOVEME? db_name=$(ynh_sanitize_dbid --db_name=$app) -#REMOVEME? db_user=$db_name -#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name - -if [ $database = "mysql" ]; then -#REMOVEME? ynh_script_progression --message="Creating a MySQL database..." --weight=1 -#REMOVEME? ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name - - ynh_mysql_connect_as --user=$db_user --password="$db_pwd" --database=$db_name \ - <<< "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;" - - db_type=0 -elif [ $database = "postgresql" ]; then -#REMOVEME? ynh_script_progression --message="Creating a PostgreSQL database..." --weight=1 -#REMOVEME? ynh_psql_test_if_first_run -#REMOVEME? ynh_psql_setup_db --db_user=$db_user --db_name=$db_name - db_type=1 -fi - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=1 -#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" ynh_setup_source --dest_dir="$install_dir/addon" --source_id="app_addons" + touch "$install_dir/php.log" mkdir -p "$install_dir/store" mkdir -p "$install_dir/cache/smarty3" -chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" chmod -R 775 $install_dir/store $install_dir/cache @@ -133,7 +58,6 @@ ynh_script_progression --message="Configuring PHP-FPM..." --weight=1 # Create a dedicated PHP-FPM config ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint -#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # NGINX CONFIGURATION @@ -150,11 +74,7 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Provisionning database..." --weight=1 -if [ $database = "mysql" ]; then - ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < $install_dir/install/schema_mysql.sql -elif [ $database = "postgresql" ]; then - ynh_psql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < $install_dir/install/schema_postgres.sql -fi +ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < $install_dir/install/schema_mysql.sql #================================================= # ADD A CONFIGURATION @@ -200,22 +120,6 @@ ynh_script_progression --message="Configuring Fail2Ban..." --weight=1 # Create a dedicated Fail2Ban config ynh_add_fail2ban_config --logpath="$install_dir/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP .*$" --max_retry="5" -#================================================= -# SETUP SSOWAT -#================================================= -#REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1 - -# Everyone can access the app. -# The "main" permission is automatically created before the install script. -#REMOVEME? ynh_permission_update --permission="main" --add="visitors" - -#================================================= -# RELOAD NGINX -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/remove b/scripts/remove index 4bf5e318..553b4bc4 100755 --- a/scripts/remove +++ b/scripts/remove @@ -9,19 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading settings..." --weight=1 - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#REMOVEME? db_user=$db_name -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? database=$(ynh_app_setting_get --app=$app --key=database) - #================================================= # STANDARD REMOVE #================================================= @@ -38,22 +25,14 @@ ynh_remove_logrotate if [ $database = "mysql" ]; then # Removing MySQL database -#REMOVEME? ynh_script_progression --message="Removing MySQL database..." --weight=1 -#REMOVEME? ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name + ynh_script_progression --message="Removing MySQL database..." --weight=1 + ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name elif [ $database = "postgresql" ]; then # Removing PostgreSQL database -#REMOVEME? ynh_script_progression --message="Removing PostgreSQL database..." --weight=1 -#REMOVEME? ynh_psql_remove_db --db_user=$db_user --db_name=$db_name + ynh_script_progression --message="Removing PostgreSQL database..." --weight=1 + ynh_psql_remove_db --db_user=$db_user --db_name=$db_name fi -#================================================= -# REMOVE APP MAIN DIR -#================================================= -#REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=1 - -# Remove the app directory securely -#REMOVEME? ynh_secure_remove --file="$install_dir" - #================================================= # REMOVE NGINX CONFIGURATION #================================================= @@ -70,14 +49,6 @@ ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=1 # Remove the dedicated PHP-FPM config ynh_remove_fpm_config -#================================================= -# REMOVE DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=1 - -# Remove metapackage and its dependencies -#REMOVEME? ynh_remove_app_dependencies - #================================================= # REMOVE FAIL2BAN CONFIGURATION #================================================= @@ -96,16 +67,6 @@ ynh_script_progression --message="Removing various files..." --weight=1 # Remove a cron file ynh_secure_remove --file="/etc/cron.d/$app" -#================================================= -# GENERIC FINALIZATION -#================================================= -# REMOVE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." --weight=1 - -# Delete a system user -#REMOVEME? ynh_system_user_delete --username=$app - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 80087788..71ec97b1 100644 --- a/scripts/restore +++ b/scripts/restore @@ -10,53 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? ynh_clean_setup () { - true -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading settings..." --weight=1 - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) -#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin) -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#REMOVEME? db_user=$db_name -#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) -#REMOVEME? database=$(ynh_app_setting_get --app=$app --key=database) - -#REMOVEME? fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) -#REMOVEME? fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage) - -#================================================= -# CHECK IF THE APP CAN BE RESTORED -#================================================= -#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=1 - -#REMOVEME? test ! -d $install_dir \ - || ynh_die --message="There is already a directory: $install_dir " - -#================================================= -# STANDARD RESTORATION STEPS -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 - -# Create the dedicated user (if not existing) -#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" - #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -64,7 +17,6 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$install_dir" -chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" @@ -77,18 +29,6 @@ ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf" ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf" ynh_systemd_action --action=restart --service_name=fail2ban -#================================================= -# SPECIFIC RESTORATION -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=1 - -if [ $database = "postgresql" ]; then -#REMOVEME? pkg_dependencies="$pkg_dependencies $pg_pkg_dependencies" -fi -#REMOVEME? ynh_install_app_dependencies $pkg_dependencies - #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= @@ -96,9 +36,6 @@ ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weig ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" -# Recreate a dedicated php-fpm config -ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$phpversion - #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= @@ -110,18 +47,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" # RESTORE THE DATABASE #================================================= -if [ $database = "mysql" ]; then -#REMOVEME? ynh_script_progression --message="Restoring MySQL database..." --weight=1 -#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) -#REMOVEME? ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd - ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql -elif [ $database = "postgresql" ]; then -#REMOVEME? ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1 -#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) -#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_file_as_root --file="./db.sql" --database="$db_name" -fi +ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql #================================================= # RESTORE VARIOUS FILES diff --git a/scripts/upgrade b/scripts/upgrade index 184beb16..329c0eab 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -14,45 +14,14 @@ source /usr/share/yunohost/helpers #================================================= ynh_script_progression --message="Loading settings..." --weight=1 -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) -#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin) -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#REMOVEME? db_user=$db_name -#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) -#REMOVEME? database=$(ynh_app_setting_get --app=$app --key=database) -#REMOVEME? upload=$(ynh_app_setting_get --app=$app --key=upload) -#REMOVEME? random_string=$(ynh_app_setting_get --app=$app --key=random_string) - email=$(ynh_user_get_info --username=$admin --key=mail) -#REMOVEME? fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) -#REMOVEME? fpm_free_footprint=$(ynh_app_setting_get --app=$app --key=fpm_free_footprint) -#REMOVEME? fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage) #================================================= # CHECK VERSION #================================================= -ynh_script_progression --message="Checking version..." --weight=1 upgrade_type=$(ynh_check_app_version_changed) -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 - -# Backup the current version of the app -#REMOVEME? ynh_backup_before_upgrade -#REMOVEME? ynh_clean_setup () { - # Restore it if the upgrade fails -#REMOVEME? ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -60,60 +29,24 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 -# If install_dir doesn't exist, create it -if [ -z "$install_dir" ]; then -#REMOVEME? install_dir=/var/www/$app -#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir -fi - -# If db_name doesn't exist, create it -if [ -z "$db_name" ]; then - db_name=$(ynh_sanitize_dbid --db_name=$app) -#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name -fi - # If fpm_footprint doesn't exist, create it -if [ -z "$fpm_footprint" ]; then +if [ -z "${fpm_footprint:-}" ]; then fpm_footprint=low ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint fi # If fpm_free_footprint doesn't exist, create it -if [ -z "$fpm_free_footprint" ]; then +if [ -z "${fpm_free_footprint:-}" ]; then fpm_free_footprint=0 ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint fi # If fpm_usage doesn't exist, create it -if [ -z "$fpm_usage" ]; then +if [ -z "${fpm_usage:-}" ]; then fpm_usage=low ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage fi -# Cleaning legacy permissions -#REMOVEME? if ynh_legacy_permissions_exists; then -#REMOVEME? ynh_legacy_permissions_delete_all - - ynh_app_setting_delete --app=$app --key=is_public -fi - -# Switch $database to "mysql" or "postgresql" -if [[ $database == "1" ]] 2>/dev/null; then - database="mysql" - ynh_app_setting_set --app=$app --key=database --value=$database -elif [[ $database == "2" ]] 2>/dev/null; then - database="postgresql" - ynh_app_setting_set --app=$app --key=database --value=$database -fi - -#================================================= -# CREATE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 - -# Create a dedicated user (if not existing) -#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -129,21 +62,11 @@ fi mkdir -p "$install_dir/store" mkdir -p "$install_dir/cache/smarty3" -chmod 750 "$install_dir" + chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" chmod -R 775 $install_dir/store $install_dir/cache -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=1 - -if [ $database = "postgresql" ]; then -#REMOVEME? pkg_dependencies="$pkg_dependencies $pg_pkg_dependencies" -fi -#REMOVEME? ynh_install_app_dependencies $pkg_dependencies - #================================================= # PHP-FPM CONFIGURATION #================================================= @@ -151,7 +74,6 @@ ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1 # Create a dedicated PHP-FPM config ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint -#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # NGINX CONFIGURATION @@ -169,15 +91,7 @@ ynh_add_nginx_config ynh_script_progression --message="Updating a configuration file..." --weight=1 if [ $database = "mysql" ]; then - db_type=0 -#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) - # Change your databases character set and collation - ynh_mysql_connect_as --user=$db_user --password="$db_pwd" --database=$db_name \ - <<< "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;" -elif [ $database = "postgresql" ]; then - db_type=1 -#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) -fi + ynh_mysql_connect_as --user=$db_user --password="$db_pwd" --database=$db_name <<< "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;" ynh_add_config --template="../conf/htconfig.sample.php" --destination="$install_dir/.htconfig.php" @@ -218,13 +132,6 @@ ynh_script_progression --message="Reconfiguring Fail2Ban..." --weight=1 # Create a dedicated Fail2Ban config ynh_add_fail2ban_config --logpath="$install_dir/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP .*$" --max_retry="5" -#================================================= -# RELOAD NGINX -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= From 10f0eea4e97260ca795f9c1e54baedc952191f9b Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Sun, 21 May 2023 09:00:35 +0000 Subject: [PATCH 09/11] Auto-update README --- README.md | 22 +--------------------- README_fr.md | 22 +--------------------- 2 files changed, 2 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index 654bba26..83a4169e 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Overview -[Hubzilla](https://hub.libranet.de/directory?f=&global=1&pubforums=1) is a social networking platform built with control of your privacy at center stage. Your online communications can be as public as you wish or as private as you require. Private conversations, private photos, private videos. Your media isn't hidden behind an obscure URL which can be guessed, it is protected by state-of-the-art cross-domain authentication. What this all means for you: **less drama**. +Hubzilla is a social networking platform built with control of your privacy at center stage. Your online communications can be as public as you wish or as private as you require. Private conversations, private photos, private videos. Your media isn't hidden behind an obscure URL which can be guessed, it is protected by state-of-the-art cross-domain authentication. **Shipped version:** 8.4.1~ynh1 @@ -25,26 +25,6 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ![Screenshot of Hubzilla](./doc/screenshots/hubzilla-1.png) -## Disclaimers / important information - -## Installation -Before installing, read the [Hubzilla installation instructions](https://framagit.org/hubzilla/core/blob/master/install/INSTALL.txt) for important information about: - -### Register a new domain and add it to YunoHost -- Hubzilla requires a dedicated domain, so obtain one and add it using the YunoHost admin panel. **Domains -> Add domain**. As Hubzilla uses the full domain and is installed on the root, you can create a subdomain such as hubzilla.domain.tld. Don't forget to update your DNS if you manage them manually. - -## Ldap Admin user rights, logs and failed database updates - -- **For admin rights**: When installation is complete, you will need to visit your new hub's page and login with the **admin account username** which was entered at the time of installation process. You should then be able to create your first channel and have the **admin rights** for the hub. - -- **For normal YunoHost users**: Normal LDAP users can login through LDAP authentication and create there channels. - -- **Failing to get admin rights**: If the admin cannot access the admin settings at `https://hubzilla.example.com/admin` then you have to **manually add 4096** to the **account_roles** under **accounts** for that user in the **database through phpMyAdmin**. - -- **For logs**: Go to **admin->logs** and enter the file name **php.log**. - -- **Failed Database after Upgrade:** Some times databse upgrade fails after version upgrade. You can go to hub eg. `https://hubzilla.example.com/admin/dbsync/` and check the numbers of failled update. These updates will have to be ran manually by **phpMyAdmin**. - ## Documentation and resources * Official app website: diff --git a/README_fr.md b/README_fr.md index bd28ac56..3125ddc1 100644 --- a/README_fr.md +++ b/README_fr.md @@ -16,7 +16,7 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po ## Vue d’ensemble -[Hubzilla](https://hub.libranet.de/directory?f=&global=1&pubforums=1) est une plate-forme de réseau social conçue avec le contrôle de votre vie privée au centre de la scène. Vos communications en ligne peuvent être aussi publiques que vous le souhaitez ou aussi privées que vous le souhaitez. Conversations privées, photos privées, vidéos privées. Votre média n'est pas caché derrière une URL obscure qui peut être devinée, il est protégé par une authentification interdomaine de pointe. Qu'est-ce que tout cela signifie pour vous : **moins de drames**. +Hubzilla est une plate-forme de réseau social conçue avec le contrôle de votre vie privée au centre de la scène. Vos communications en ligne peuvent être aussi publiques que vous le souhaitez ou aussi privées que vous le souhaitez. Conversations privées, photos privées, vidéos privées. Votre média n'est pas caché derrière une URL obscure qui peut être devinée, il est protégé par une authentification interdomaine de pointe. **Version incluse :** 8.4.1~ynh1 @@ -25,26 +25,6 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po ![Capture d’écran de Hubzilla](./doc/screenshots/hubzilla-1.png) -## Avertissements / informations importantes - -## Installation -Avant l'installation, lisez les [instructions d'installation de Hubzilla](https://framagit.org/hubzilla/core/blob/master/install/INSTALL.txt) pour obtenir des informations importantes sur : - -### Enregistrez un nouveau domaine et ajoutez-le à YunoHost -- Hubzilla nécessite un domaine dédié, alors obtenez-en un et ajoutez-le à l'aide du panneau d'administration YunoHost. **Domaines -> Ajouter un domaine**. Comme Hubzilla utilise le domaine complet et est installé à la racine, vous pouvez créer un sous-domaine tel que hubzilla.domain.tld. N'oubliez pas de mettre à jour vos DNS si vous les gérez manuellement. - -## Droits d'utilisateur de l'administrateur Ldap, journaux et échec des mises à jour de la base de données - -- **Pour les droits d'administrateur** : lorsque l'installation est terminée, vous devrez visiter la page de votre nouveau hub et vous connecter avec le **nom d'utilisateur du compte administrateur** qui a été saisi au moment du processus d'installation. Vous devriez alors pouvoir créer votre premier canal et disposer des **droits d'administrateur** pour le hub. - -- **Pour les utilisateurs YunoHost normaux** : les utilisateurs LDAP normaux peuvent se connecter via l'authentification LDAP et y créer des canaux. - -- **Échec de l'obtention des droits d'administrateur** : si l'administrateur ne peut pas accéder aux paramètres d'administration sur `https://hubzilla.example.com/admin`, vous devez **ajouter manuellement 4096** aux **account_roles* * sous **comptes** pour cet utilisateur dans la **base de données via phpMyAdmin**. - -- **Pour les logs** : Allez dans **admin->logs** et saisissez le nom du fichier **php.log**. - -- **Échec de la base de données après la mise à niveau :** Parfois, la mise à niveau de la base de données échoue après la mise à niveau de la version. Vous pouvez aller au hub, par exemple. `https://hubzilla.example.com/admin/dbsync/` et vérifiez le nombre de mises à jour défaillantes. Ces mises à jour devront être exécutées manuellement par **phpMyAdmin**. - ## Documentations et ressources * Site officiel de l’app : From 353a34d191334f0da382b96bf2d99b1544937bf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 21 May 2023 11:00:45 +0200 Subject: [PATCH 10/11] Create tests.toml --- tests.toml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tests.toml diff --git a/tests.toml b/tests.toml new file mode 100644 index 00000000..eb73b8d5 --- /dev/null +++ b/tests.toml @@ -0,0 +1,3 @@ +test_format = 1.0 + +[default] \ No newline at end of file From e6e578eb1de7d9bdfc3362ae90e06205af789a4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 21 May 2023 11:02:17 +0200 Subject: [PATCH 11/11] Revert "Merge pull request #140 from YunoHost-Apps/version-2" This reverts commit c0a03befc7a9f816b59614bf0041b3ae11e3e58c, reversing changes made to 8748acdacfc00e3ee5d74ff5b24b29f199e7335a. --- .github/workflows/updater.sh | 133 ++++++++++++++++++++++++++ .github/workflows/updater.yml | 52 ++++++++++ README.md | 22 ++++- README_fr.md | 22 ++++- conf/app.src | 7 ++ conf/app_addons.src | 7 ++ conf/htconfig.sample.php | 2 +- conf/nginx.conf | 2 +- conf/poller-cron | 2 +- doc/ADMIN.md | 11 --- doc/DESCRIPTION.md | 2 +- doc/DESCRIPTION_fr.md | 2 +- doc/DISCLAIMER.md | 17 ++++ doc/{ADMIN_fr.md => DISCLAIMER_fr.md} | 8 +- manifest.json | 58 +++++++++++ manifest.toml | 59 ------------ scripts/_common.sh | 9 ++ scripts/backup | 36 ++++++- scripts/install | 132 +++++++++++++++++++++---- scripts/remove | 39 ++++++++ scripts/restore | 82 +++++++++++++++- scripts/upgrade | 127 ++++++++++++++++++++---- tests.toml | 3 - 23 files changed, 711 insertions(+), 123 deletions(-) create mode 100644 .github/workflows/updater.sh create mode 100644 .github/workflows/updater.yml create mode 100644 conf/app.src create mode 100644 conf/app_addons.src delete mode 100644 doc/ADMIN.md create mode 100644 doc/DISCLAIMER.md rename doc/{ADMIN_fr.md => DISCLAIMER_fr.md} (63%) create mode 100644 manifest.json delete mode 100644 manifest.toml delete mode 100644 tests.toml diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh new file mode 100644 index 00000000..83913d7a --- /dev/null +++ b/.github/workflows/updater.sh @@ -0,0 +1,133 @@ +#!/bin/bash + +#================================================= +# PACKAGE UPDATING HELPER +#================================================= + +# This script is meant to be run by GitHub Actions +# The YunoHost-Apps organisation offers a template Action to run this script periodically +# Since each app is different, maintainers can adapt its contents so as to perform +# automatic actions when a new upstream release is detected. + +#================================================= +# FETCHING LATEST RELEASE AND ITS ASSETS +#================================================= + +# Fetching information +current_version=$(cat manifest.json | jq -j '.version|split("~")[0]') +# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions) +version=$(curl --silent "https://framagit.org/api/v4/projects/27084/releases" | jq -r '.[] | select( .upcoming_release != true ) | .tag_name' | sort -V | tail -1) +assets=("https://framagit.org/hubzilla/core/-/archive/$version/core-$version.tar.gz" "https://framagit.org/hubzilla/addons/-/archive/$version/addons-$version.tar.gz") + +# Later down the script, we assume the version has only digits and dots +# Sometimes the release name starts with a "v", so let's filter it out. +# You may need more tweaks here if the upstream repository has different naming conventions. +if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then + version=${version:1} +fi + +# Setting up the environment variables +echo "Current version: $current_version" +echo "Latest release from upstream: $version" +echo "VERSION=$version" >> $GITHUB_ENV +# For the time being, let's assume the script will fail +echo "PROCEED=false" >> $GITHUB_ENV + +# Proceed only if the retrieved version is greater than the current one +if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then + echo "::warning ::No new version available" + exit 0 +# Proceed only if a PR for this new version does not already exist +elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then + echo "::warning ::A branch already exists for this update" + exit 0 +fi + +# Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.) +echo "${#assets[@]} available asset(s)" + +#================================================= +# UPDATE SOURCE FILES +#================================================= + +# Here we use the $assets variable to get the resources published in the upstream release. +# Here is an example for Grav, it has to be adapted in accordance with how the upstream releases look like. + +# Let's loop over the array of assets URLs +for asset_url in ${assets[@]}; do + + echo "Handling asset at $asset_url" + + # Assign the asset to a source file in conf/ directory + # Here we base the source file name upon a unique keyword in the assets url (admin vs. update) + # Leave $src empty to ignore the asset + case $asset_url in + *"core"*) + src="app" + ;; + *"addons"*) + src="app_addons" + ;; + *) + src="" + ;; + esac + + # If $src is not empty, let's process the asset + if [ ! -z "$src" ]; then + + # Create the temporary directory + tempdir="$(mktemp -d)" + + # Download sources and calculate checksum + filename=${asset_url##*/} + curl --silent -4 -L $asset_url -o "$tempdir/$filename" + checksum=$(sha256sum "$tempdir/$filename" | head -c 64) + + # Delete temporary directory + rm -rf $tempdir + + # Get extension + if [[ $filename == *.tar.gz ]]; then + extension=tar.gz + else + extension=${filename##*.} + fi + + # Rewrite source file + cat < conf/$src.src +SOURCE_URL=$asset_url +SOURCE_SUM=$checksum +SOURCE_SUM_PRG=sha256sum +SOURCE_FORMAT=$extension +SOURCE_IN_SUBDIR=true +SOURCE_FILENAME= +SOURCE_EXTRACT=true +EOT + echo "... conf/$src.src updated" + + else + echo "... asset ignored" + fi + +done + +#================================================= +# SPECIFIC UPDATE STEPS +#================================================= + +# Any action on the app's source code can be done. +# The GitHub Action workflow takes care of committing all changes after this script ends. + +#================================================= +# GENERIC FINALIZATION +#================================================= + +# Replace new version in manifest +echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json + +# No need to update the README, yunohost-bot takes care of it + +# The Action will proceed only if the PROCEED environment variable is set to true +echo "PROCEED=true" >> $GITHUB_ENV +exit 0 diff --git a/.github/workflows/updater.yml b/.github/workflows/updater.yml new file mode 100644 index 00000000..64f2a2f8 --- /dev/null +++ b/.github/workflows/updater.yml @@ -0,0 +1,52 @@ +# This workflow allows GitHub Actions to automagically update your app whenever a new upstream release is detected. +# You need to enable Actions in your repository settings, and fetch this Action from the YunoHost-Apps organization. +# This file should be enough by itself, but feel free to tune it to your needs. +# It calls updater.sh, which is where you should put the app-specific update steps. +name: Check for new upstream releases +on: + # Allow to manually trigger the workflow + workflow_dispatch: + # Run it every day at 6:00 UTC + schedule: + - cron: '0 6 * * *' +jobs: + updater: + runs-on: ubuntu-latest + steps: + - name: Fetch the source code + uses: actions/checkout@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + - name: Run the updater script + id: run_updater + run: | + # Setting up Git user + git config --global user.name 'yunohost-bot' + git config --global user.email 'yunohost-bot@users.noreply.github.com' + # Run the updater script + /bin/bash .github/workflows/updater.sh + - name: Commit changes + id: commit + if: ${{ env.PROCEED == 'true' }} + run: | + git commit -am "Upgrade to v$VERSION" + - name: Create Pull Request + id: cpr + if: ${{ env.PROCEED == 'true' }} + uses: peter-evans/create-pull-request@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: Update to version ${{ env.VERSION }} + committer: 'yunohost-bot ' + author: 'yunohost-bot ' + signoff: false + base: testing + branch: ci-auto-update-v${{ env.VERSION }} + delete-branch: true + title: 'Upgrade to version ${{ env.VERSION }}' + body: | + Upgrade to v${{ env.VERSION }} + [See upstream release page](${{ env.RELEASE }}) + Provided description: + ${{ env.DESCRIPTION }} + draft: false diff --git a/README.md b/README.md index 83a4169e..654bba26 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Overview -Hubzilla is a social networking platform built with control of your privacy at center stage. Your online communications can be as public as you wish or as private as you require. Private conversations, private photos, private videos. Your media isn't hidden behind an obscure URL which can be guessed, it is protected by state-of-the-art cross-domain authentication. +[Hubzilla](https://hub.libranet.de/directory?f=&global=1&pubforums=1) is a social networking platform built with control of your privacy at center stage. Your online communications can be as public as you wish or as private as you require. Private conversations, private photos, private videos. Your media isn't hidden behind an obscure URL which can be guessed, it is protected by state-of-the-art cross-domain authentication. What this all means for you: **less drama**. **Shipped version:** 8.4.1~ynh1 @@ -25,6 +25,26 @@ Hubzilla is a social networking platform built with control of your privacy at c ![Screenshot of Hubzilla](./doc/screenshots/hubzilla-1.png) +## Disclaimers / important information + +## Installation +Before installing, read the [Hubzilla installation instructions](https://framagit.org/hubzilla/core/blob/master/install/INSTALL.txt) for important information about: + +### Register a new domain and add it to YunoHost +- Hubzilla requires a dedicated domain, so obtain one and add it using the YunoHost admin panel. **Domains -> Add domain**. As Hubzilla uses the full domain and is installed on the root, you can create a subdomain such as hubzilla.domain.tld. Don't forget to update your DNS if you manage them manually. + +## Ldap Admin user rights, logs and failed database updates + +- **For admin rights**: When installation is complete, you will need to visit your new hub's page and login with the **admin account username** which was entered at the time of installation process. You should then be able to create your first channel and have the **admin rights** for the hub. + +- **For normal YunoHost users**: Normal LDAP users can login through LDAP authentication and create there channels. + +- **Failing to get admin rights**: If the admin cannot access the admin settings at `https://hubzilla.example.com/admin` then you have to **manually add 4096** to the **account_roles** under **accounts** for that user in the **database through phpMyAdmin**. + +- **For logs**: Go to **admin->logs** and enter the file name **php.log**. + +- **Failed Database after Upgrade:** Some times databse upgrade fails after version upgrade. You can go to hub eg. `https://hubzilla.example.com/admin/dbsync/` and check the numbers of failled update. These updates will have to be ran manually by **phpMyAdmin**. + ## Documentation and resources * Official app website: diff --git a/README_fr.md b/README_fr.md index 3125ddc1..bd28ac56 100644 --- a/README_fr.md +++ b/README_fr.md @@ -16,7 +16,7 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po ## Vue d’ensemble -Hubzilla est une plate-forme de réseau social conçue avec le contrôle de votre vie privée au centre de la scène. Vos communications en ligne peuvent être aussi publiques que vous le souhaitez ou aussi privées que vous le souhaitez. Conversations privées, photos privées, vidéos privées. Votre média n'est pas caché derrière une URL obscure qui peut être devinée, il est protégé par une authentification interdomaine de pointe. +[Hubzilla](https://hub.libranet.de/directory?f=&global=1&pubforums=1) est une plate-forme de réseau social conçue avec le contrôle de votre vie privée au centre de la scène. Vos communications en ligne peuvent être aussi publiques que vous le souhaitez ou aussi privées que vous le souhaitez. Conversations privées, photos privées, vidéos privées. Votre média n'est pas caché derrière une URL obscure qui peut être devinée, il est protégé par une authentification interdomaine de pointe. Qu'est-ce que tout cela signifie pour vous : **moins de drames**. **Version incluse :** 8.4.1~ynh1 @@ -25,6 +25,26 @@ Hubzilla est une plate-forme de réseau social conçue avec le contrôle de votr ![Capture d’écran de Hubzilla](./doc/screenshots/hubzilla-1.png) +## Avertissements / informations importantes + +## Installation +Avant l'installation, lisez les [instructions d'installation de Hubzilla](https://framagit.org/hubzilla/core/blob/master/install/INSTALL.txt) pour obtenir des informations importantes sur : + +### Enregistrez un nouveau domaine et ajoutez-le à YunoHost +- Hubzilla nécessite un domaine dédié, alors obtenez-en un et ajoutez-le à l'aide du panneau d'administration YunoHost. **Domaines -> Ajouter un domaine**. Comme Hubzilla utilise le domaine complet et est installé à la racine, vous pouvez créer un sous-domaine tel que hubzilla.domain.tld. N'oubliez pas de mettre à jour vos DNS si vous les gérez manuellement. + +## Droits d'utilisateur de l'administrateur Ldap, journaux et échec des mises à jour de la base de données + +- **Pour les droits d'administrateur** : lorsque l'installation est terminée, vous devrez visiter la page de votre nouveau hub et vous connecter avec le **nom d'utilisateur du compte administrateur** qui a été saisi au moment du processus d'installation. Vous devriez alors pouvoir créer votre premier canal et disposer des **droits d'administrateur** pour le hub. + +- **Pour les utilisateurs YunoHost normaux** : les utilisateurs LDAP normaux peuvent se connecter via l'authentification LDAP et y créer des canaux. + +- **Échec de l'obtention des droits d'administrateur** : si l'administrateur ne peut pas accéder aux paramètres d'administration sur `https://hubzilla.example.com/admin`, vous devez **ajouter manuellement 4096** aux **account_roles* * sous **comptes** pour cet utilisateur dans la **base de données via phpMyAdmin**. + +- **Pour les logs** : Allez dans **admin->logs** et saisissez le nom du fichier **php.log**. + +- **Échec de la base de données après la mise à niveau :** Parfois, la mise à niveau de la base de données échoue après la mise à niveau de la version. Vous pouvez aller au hub, par exemple. `https://hubzilla.example.com/admin/dbsync/` et vérifiez le nombre de mises à jour défaillantes. Ces mises à jour devront être exécutées manuellement par **phpMyAdmin**. + ## Documentations et ressources * Site officiel de l’app : diff --git a/conf/app.src b/conf/app.src new file mode 100644 index 00000000..ac2a22ae --- /dev/null +++ b/conf/app.src @@ -0,0 +1,7 @@ +SOURCE_URL=https://framagit.org/hubzilla/core/-/archive/8.4.1/core-8.4.1.tar.gz +SOURCE_SUM=93dd8fc4d30da8a79a77303381b1451f8215c62f8b913e215664a9396cf47d61 +SOURCE_SUM_PRG=sha256sum +SOURCE_FORMAT=tar.gz +SOURCE_IN_SUBDIR=true +SOURCE_FILENAME= +SOURCE_EXTRACT=true diff --git a/conf/app_addons.src b/conf/app_addons.src new file mode 100644 index 00000000..05da7ff7 --- /dev/null +++ b/conf/app_addons.src @@ -0,0 +1,7 @@ +SOURCE_URL=https://framagit.org/hubzilla/addons/-/archive/8.4.1/addons-8.4.1.tar.gz +SOURCE_SUM=67f7b881f195b258c3d61922a6ce0f92832b907cafd5feb11b8abea4b2b055a0 +SOURCE_SUM_PRG=sha256sum +SOURCE_FORMAT=tar.gz +SOURCE_IN_SUBDIR=true +SOURCE_FILENAME= +SOURCE_EXTRACT=true diff --git a/conf/htconfig.sample.php b/conf/htconfig.sample.php index 1484262f..af51076b 100644 --- a/conf/htconfig.sample.php +++ b/conf/htconfig.sample.php @@ -17,7 +17,7 @@ $db_port = 0; // leave 0 for default or set your port $db_user = '__DB_USER__'; $db_pass = '__DB_PWD__'; $db_data = '__DB_NAME__'; -$db_type = 0; // use 1 for postgres, 0 for mysql +$db_type = __DB_TYPE__; // use 1 for postgres, 0 for mysql /* * Notice: Many of the following settings will be available in the admin panel diff --git a/conf/nginx.conf b/conf/nginx.conf index 5fde905b..b17c3540 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -2,7 +2,7 @@ location __PATH__/ { # Path to source - alias __INSTALL_DIR__/; + alias __FINALPATH__/; if (!-e $request_filename) { rewrite ^(.*)$ /index.php?q=$1; diff --git a/conf/poller-cron b/conf/poller-cron index 23967c05..b07e685f 100644 --- a/conf/poller-cron +++ b/conf/poller-cron @@ -1,2 +1,2 @@ # Run poller periodically to update Hubzilla -*/10 * * * * __APP__ /usr/bin/php__PHPVERSION__ -f __INSTALL_DIR__/Zotlabs/Daemon/Master.php Cron > /dev/null 2>&1 +*/10 * * * * __APP__ /usr/bin/php__PHPVERSION__ -f __FINALPATH__/Zotlabs/Daemon/Master.php Cron > /dev/null 2>&1 diff --git a/doc/ADMIN.md b/doc/ADMIN.md deleted file mode 100644 index 585d562e..00000000 --- a/doc/ADMIN.md +++ /dev/null @@ -1,11 +0,0 @@ -## Ldap Admin user rights, logs and failed database updates - -- **For admin rights**: When installation is complete, you will need to visit your new hub's page and login with the **admin account username** which was entered at the time of installation process. You should then be able to create your first channel and have the **admin rights** for the hub. - -- **For normal YunoHost users**: Normal LDAP users can login through LDAP authentication and create there channels. - -- **Failing to get admin rights**: If the admin cannot access the admin settings at `https://__DOMAIN__/admin` then you have to **manually add 4096** to the **account_roles** under **accounts** for that user in the **database through phpMyAdmin**. - -- **For logs**: Go to **admin->logs** and enter the file name **php.log**. - -- **Failed Database after Upgrade:** Some times databse upgrade fails after version upgrade. You can go to hub eg. `https://__DOMAIN__/admin/dbsync/` and check the numbers of failled update. These updates will have to be ran manually by **phpMyAdmin**. diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md index 2007147a..ff21f97a 100644 --- a/doc/DESCRIPTION.md +++ b/doc/DESCRIPTION.md @@ -1 +1 @@ -Hubzilla is a social networking platform built with control of your privacy at center stage. Your online communications can be as public as you wish or as private as you require. Private conversations, private photos, private videos. Your media isn't hidden behind an obscure URL which can be guessed, it is protected by state-of-the-art cross-domain authentication. +[Hubzilla](https://hub.libranet.de/directory?f=&global=1&pubforums=1) is a social networking platform built with control of your privacy at center stage. Your online communications can be as public as you wish or as private as you require. Private conversations, private photos, private videos. Your media isn't hidden behind an obscure URL which can be guessed, it is protected by state-of-the-art cross-domain authentication. What this all means for you: **less drama**. diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md index 390a662f..11636de6 100644 --- a/doc/DESCRIPTION_fr.md +++ b/doc/DESCRIPTION_fr.md @@ -1 +1 @@ -Hubzilla est une plate-forme de réseau social conçue avec le contrôle de votre vie privée au centre de la scène. Vos communications en ligne peuvent être aussi publiques que vous le souhaitez ou aussi privées que vous le souhaitez. Conversations privées, photos privées, vidéos privées. Votre média n'est pas caché derrière une URL obscure qui peut être devinée, il est protégé par une authentification interdomaine de pointe. +[Hubzilla](https://hub.libranet.de/directory?f=&global=1&pubforums=1) est une plate-forme de réseau social conçue avec le contrôle de votre vie privée au centre de la scène. Vos communications en ligne peuvent être aussi publiques que vous le souhaitez ou aussi privées que vous le souhaitez. Conversations privées, photos privées, vidéos privées. Votre média n'est pas caché derrière une URL obscure qui peut être devinée, il est protégé par une authentification interdomaine de pointe. Qu'est-ce que tout cela signifie pour vous : **moins de drames**. diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md new file mode 100644 index 00000000..7fbd776d --- /dev/null +++ b/doc/DISCLAIMER.md @@ -0,0 +1,17 @@ +## Installation +Before installing, read the [Hubzilla installation instructions](https://framagit.org/hubzilla/core/blob/master/install/INSTALL.txt) for important information about: + +### Register a new domain and add it to YunoHost +- Hubzilla requires a dedicated domain, so obtain one and add it using the YunoHost admin panel. **Domains -> Add domain**. As Hubzilla uses the full domain and is installed on the root, you can create a subdomain such as hubzilla.domain.tld. Don't forget to update your DNS if you manage them manually. + +## Ldap Admin user rights, logs and failed database updates + +- **For admin rights**: When installation is complete, you will need to visit your new hub's page and login with the **admin account username** which was entered at the time of installation process. You should then be able to create your first channel and have the **admin rights** for the hub. + +- **For normal YunoHost users**: Normal LDAP users can login through LDAP authentication and create there channels. + +- **Failing to get admin rights**: If the admin cannot access the admin settings at `https://hubzilla.example.com/admin` then you have to **manually add 4096** to the **account_roles** under **accounts** for that user in the **database through phpMyAdmin**. + +- **For logs**: Go to **admin->logs** and enter the file name **php.log**. + +- **Failed Database after Upgrade:** Some times databse upgrade fails after version upgrade. You can go to hub eg. `https://hubzilla.example.com/admin/dbsync/` and check the numbers of failled update. These updates will have to be ran manually by **phpMyAdmin**. diff --git a/doc/ADMIN_fr.md b/doc/DISCLAIMER_fr.md similarity index 63% rename from doc/ADMIN_fr.md rename to doc/DISCLAIMER_fr.md index 5ec943ba..cf4be09b 100644 --- a/doc/ADMIN_fr.md +++ b/doc/DISCLAIMER_fr.md @@ -1,4 +1,10 @@ -## Droits d'utilisateur de l'administrateur Ldap, journaux et échec des mises à jour de la base de données +## Installation +Avant l'installation, lisez les [instructions d'installation de Hubzilla](https://framagit.org/hubzilla/core/blob/master/install/INSTALL.txt) pour obtenir des informations importantes sur : + +### Enregistrez un nouveau domaine et ajoutez-le à YunoHost +- Hubzilla nécessite un domaine dédié, alors obtenez-en un et ajoutez-le à l'aide du panneau d'administration YunoHost. **Domaines -> Ajouter un domaine**. Comme Hubzilla utilise le domaine complet et est installé à la racine, vous pouvez créer un sous-domaine tel que hubzilla.domain.tld. N'oubliez pas de mettre à jour vos DNS si vous les gérez manuellement. + +## Droits d'utilisateur de l'administrateur Ldap, journaux et échec des mises à jour de la base de données - **Pour les droits d'administrateur** : lorsque l'installation est terminée, vous devrez visiter la page de votre nouveau hub et vous connecter avec le **nom d'utilisateur du compte administrateur** qui a été saisi au moment du processus d'installation. Vous devriez alors pouvoir créer votre premier canal et disposer des **droits d'administrateur** pour le hub. diff --git a/manifest.json b/manifest.json new file mode 100644 index 00000000..965ce346 --- /dev/null +++ b/manifest.json @@ -0,0 +1,58 @@ +{ + "packaging_format": 1, + "id": "hubzilla", + "name": "Hubzilla", + "description": { + "en": "Decentralized publication platform and social network.", + "fr": "Plateforme de publication décentralisée et un réseau social." + }, + "version": "8.4.1~ynh1", + "url": "https://zotlabs.org/page/hubzilla/hubzilla-project", + "upstream": { + "license": "MIT", + "website": "https://zotlabs.org/page/hubzilla/hubzilla-project", + "code": "https://framagit.org/hubzilla/core" + }, + "license": "MIT", + "maintainer": { + "name": "Anmol Sharma" + }, + "previous_maintainers": { + "name": "Andrew Manning", + "email": "andrew@reticu.li" + }, + "requirements": { + "yunohost": ">= 11.0.9" + }, + "multi_instance": true, + "services": [ + "nginx", + "php8.0-fpm", + "mysql" + ], + "arguments": { + "install": [ + { + "name": "domain", + "type": "domain" + }, + { + "name": "admin", + "type": "user" + }, + { + "name": "database", + "type": "string", + "ask": { + "en": "Choose the database to be used for the Hubzilla]", + "fr": "Choisissez la database de Hubzilla" + }, + "choices": [ + "mysql", + "postgresql" + ], + "default": "mysql" + } + ] + } +} diff --git a/manifest.toml b/manifest.toml deleted file mode 100644 index 5f1eb927..00000000 --- a/manifest.toml +++ /dev/null @@ -1,59 +0,0 @@ -packaging_format = 2 - -id = "hubzilla" -name = "Hubzilla" -description.en = "Decentralized publication platform and social network." -description.fr = "Plateforme de publication décentralisée et un réseau social." - -version = "8.4.1~ynh1" - -maintainers = ["Anmol Sharma"] - -[upstream] -license = "MIT" -website = "https://zotlabs.org/page/hubzilla/hubzilla-project" -code = "https://framagit.org/hubzilla/core" - -[integration] -yunohost = ">= 11.1.19" -architectures = "all" -multi_instance = true -ldap = true -sso = false -disk = "50M" -ram.build = "50M" -ram.runtime = "50M" - -[install] - [install.domain] - type = "domain" - full_domain = true - - [install.admin] - type = "user" - -[resources] - [resources.sources] - [resources.sources.main] - url = "https://framagit.org/hubzilla/core/-/archive/8.4.1/core-8.4.1.tar.gz" - sha256 = "93dd8fc4d30da8a79a77303381b1451f8215c62f8b913e215664a9396cf47d61" - autoupdate.strategy = "latest_github_tag" - - [resources.sources.app_addons] - url = "https://framagit.org/hubzilla/addons/-/archive/8.4.1/addons-8.4.1.tar.gz" - sha256 = "67f7b881f195b258c3d61922a6ce0f92832b907cafd5feb11b8abea4b2b055a0" - autoupdate.strategy = "latest_github_tag" - - - [resources.system_user] - - [resources.install_dir] - - [resources.permissions] - main.url = "/" - - [resources.apt] - packages = "mariadb-server php8.2-curl php8.2-gd php8.2-mysql php8.2-mbstring php8.2-xml php8.2-zip php8.2-cli php8.2-imagick" - - [resources.database] - type = "mysql" diff --git a/scripts/_common.sh b/scripts/_common.sh index 1e47ce72..441538f2 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -6,6 +6,15 @@ # PHP APP SPECIFIC #================================================= +YNH_PHP_VERSION="8.2" + +php_dependencies="php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-imagick php${YNH_PHP_VERSION}-pgsql php${YNH_PHP_VERSION}-json" + +# dependencies used by the app (must be on a single line) +pkg_dependencies="$php_dependencies" + +pg_pkg_dependencies="postgresql postgresql-contrib" + #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index 9d780ff6..b9d99fe9 100644 --- a/scripts/backup +++ b/scripts/backup @@ -10,6 +10,29 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +ynh_clean_setup () { + true +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_print_info --message="Loading 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) +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +database=$(ynh_app_setting_get --app=$app --key=database) + #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= @@ -19,7 +42,7 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$install_dir" +ynh_backup --src_path="$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION @@ -57,9 +80,16 @@ ynh_backup --src_path="/etc/cron.d/$app" #================================================= # BACKUP THE DATABASE #================================================= -ynh_print_info --message="Backup of the MySQL database..." -ynh_mysql_dump_db --database="$db_name" > db.sql +if [ $database = "mysql" ]; then + # Backup MySQL database + ynh_print_info --message="Backup of the MySQL database..." + ynh_mysql_dump_db --database="$db_name" > db.sql +elif [ $database = "postgresql" ]; then + # Backup PostgreSQL database + ynh_print_info --message="Backup of the PostgreSQL database..." + ynh_psql_dump_db --database="$db_name" > db.sql +fi #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index a0f6d82a..93b4e643 100755 --- a/scripts/install +++ b/scripts/install @@ -9,23 +9,54 @@ source _common.sh source /usr/share/yunohost/helpers +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +ynh_clean_setup () { + true +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= +domain=$YNH_APP_ARG_DOMAIN +path_url="/" +admin=$YNH_APP_ARG_ADMIN +database=$YNH_APP_ARG_DATABASE +phpversion=$YNH_PHP_VERSION + +app=$YNH_APP_INSTANCE_NAME + email=$(ynh_user_get_info --username=$admin --key=mail) upload="256M" random_string="$(ynh_string_random --length=48)" - fpm_footprint="low" fpm_free_footprint=0 fpm_usage="low" +#================================================= +# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS +#================================================= +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" + +# Register (book) web path +ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url + #================================================= # STORE SETTINGS FROM MANIFEST #================================================= ynh_script_progression --message="Storing installation settings..." --weight=1 +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=admin --value=$admin ynh_app_setting_set --app=$app --key=database --value=$database ynh_app_setting_set --app=$app --key=email --value=$email ynh_app_setting_set --app=$app --key=upload --value=$upload @@ -34,22 +65,66 @@ ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage +#================================================= +# STANDARD MODIFICATIONS +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Installing dependencies..." --weight=1 + +if [ $database = "postgresql" ]; then + pkg_dependencies="$pkg_dependencies $pg_pkg_dependencies" +fi +ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies + +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." --weight=1 + +# Create a system user +ynh_system_user_create --username=$app --home_dir="$final_path" + +#================================================= +# CREATE A DATABASE +#================================================= + +db_name=$(ynh_sanitize_dbid --db_name=$app) +db_user=$db_name +ynh_app_setting_set --app=$app --key=db_name --value=$db_name + +if [ $database = "mysql" ]; then + ynh_script_progression --message="Creating a MySQL database..." --weight=1 + ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name + + ynh_mysql_connect_as --user=$db_user --password="$db_pwd" --database=$db_name \ + <<< "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;" + + db_type=0 +elif [ $database = "postgresql" ]; then + ynh_script_progression --message="Creating a PostgreSQL database..." --weight=1 + ynh_psql_test_if_first_run + ynh_psql_setup_db --db_user=$db_user --db_name=$db_name + db_type=1 +fi + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=1 +ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$install_dir" -ynh_setup_source --dest_dir="$install_dir/addon" --source_id="app_addons" +ynh_setup_source --dest_dir="$final_path" +ynh_setup_source --dest_dir="$final_path/addon" --source_id="app_addons" +touch "$final_path/php.log" +mkdir -p "$final_path/store" +mkdir -p "$final_path/cache/smarty3" -touch "$install_dir/php.log" -mkdir -p "$install_dir/store" -mkdir -p "$install_dir/cache/smarty3" - -chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" -chmod -R 775 $install_dir/store $install_dir/cache +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" +chmod -R 775 $final_path/store $final_path/cache #================================================= # PHP-FPM CONFIGURATION @@ -58,6 +133,7 @@ ynh_script_progression --message="Configuring PHP-FPM..." --weight=1 # Create a dedicated PHP-FPM config ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # NGINX CONFIGURATION @@ -74,23 +150,27 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Provisionning database..." --weight=1 -ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < $install_dir/install/schema_mysql.sql +if [ $database = "mysql" ]; then + ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < $final_path/install/schema_mysql.sql +elif [ $database = "postgresql" ]; then + ynh_psql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < $final_path/install/schema_postgres.sql +fi #================================================= # ADD A CONFIGURATION #================================================= ynh_script_progression --message="Adding a configuration file..." --weight=1 -ynh_add_config --template="../conf/htconfig.sample.php" --destination="$install_dir/.htconfig.php" +ynh_add_config --template="../conf/htconfig.sample.php" --destination="$final_path/.htconfig.php" # addon ldap config ynh_script_progression --message="Push LDAP configuration to .htconfig.php..." -cat ../conf/ldap_conf.php >> $install_dir/.htconfig.php -ynh_store_file_checksum --file=$install_dir/.htconfig.php +cat ../conf/ldap_conf.php >> $final_path/.htconfig.php +ynh_store_file_checksum --file=$final_path/.htconfig.php -chmod 600 "$install_dir/.htconfig.php" -chown $app:$app "$install_dir/.htconfig.php" +chmod 600 "$final_path/.htconfig.php" +chown $app:$app "$final_path/.htconfig.php" #================================================= # SET CRON JOB @@ -110,7 +190,7 @@ chmod 644 "/etc/cron.d/$app" ynh_script_progression --message="Configuring log rotation..." --weight=1 # Use logrotate to manage application logfile(s) -ynh_use_logrotate "$install_dir/php.log" +ynh_use_logrotate "$final_path/php.log" #================================================= # SETUP FAIL2BAN @@ -118,7 +198,23 @@ ynh_use_logrotate "$install_dir/php.log" ynh_script_progression --message="Configuring Fail2Ban..." --weight=1 # Create a dedicated Fail2Ban config -ynh_add_fail2ban_config --logpath="$install_dir/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP .*$" --max_retry="5" +ynh_add_fail2ban_config --logpath="$final_path/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP .*$" --max_retry="5" + +#================================================= +# SETUP SSOWAT +#================================================= +ynh_script_progression --message="Configuring permissions..." --weight=1 + +# Everyone can access the app. +# The "main" permission is automatically created before the install script. +ynh_permission_update --permission="main" --add="visitors" + +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index 553b4bc4..a4d921ee 100755 --- a/scripts/remove +++ b/scripts/remove @@ -9,6 +9,19 @@ source _common.sh source /usr/share/yunohost/helpers +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading settings..." --weight=1 + +app=$YNH_APP_INSTANCE_NAME + +domain=$(ynh_app_setting_get --app=$app --key=domain) +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) +database=$(ynh_app_setting_get --app=$app --key=database) + #================================================= # STANDARD REMOVE #================================================= @@ -33,6 +46,14 @@ elif [ $database = "postgresql" ]; then ynh_psql_remove_db --db_user=$db_user --db_name=$db_name fi +#================================================= +# REMOVE APP MAIN DIR +#================================================= +ynh_script_progression --message="Removing app main directory..." --weight=1 + +# Remove the app directory securely +ynh_secure_remove --file="$final_path" + #================================================= # REMOVE NGINX CONFIGURATION #================================================= @@ -49,6 +70,14 @@ ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=1 # Remove the dedicated PHP-FPM config ynh_remove_fpm_config +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_script_progression --message="Removing dependencies..." --weight=1 + +# Remove metapackage and its dependencies +ynh_remove_app_dependencies + #================================================= # REMOVE FAIL2BAN CONFIGURATION #================================================= @@ -67,6 +96,16 @@ ynh_script_progression --message="Removing various files..." --weight=1 # Remove a cron file ynh_secure_remove --file="/etc/cron.d/$app" +#================================================= +# GENERIC FINALIZATION +#================================================= +# REMOVE DEDICATED USER +#================================================= +ynh_script_progression --message="Removing the dedicated system user..." --weight=1 + +# Delete a system user +ynh_system_user_delete --username=$app + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 71ec97b1..37001c2a 100644 --- a/scripts/restore +++ b/scripts/restore @@ -10,15 +10,63 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +ynh_clean_setup () { + true +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading 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) +admin=$(ynh_app_setting_get --app=$app --key=admin) +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 +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +database=$(ynh_app_setting_get --app=$app --key=database) + +fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) +fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage) + +#================================================= +# CHECK IF THE APP CAN BE RESTORED +#================================================= +ynh_script_progression --message="Validating restoration parameters..." --weight=1 + +test ! -d $final_path \ + || ynh_die --message="There is already a directory: $final_path " + +#================================================= +# STANDARD RESTORATION STEPS +#================================================= +# RECREATE THE DEDICATED USER +#================================================= +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" + #================================================= # RESTORE THE APP MAIN DIR #================================================= ynh_script_progression --message="Restoring the app main directory..." --weight=1 -ynh_restore_file --origin_path="$install_dir" +ynh_restore_file --origin_path="$final_path" -chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" #================================================= # RESTORE FAIL2BAN CONFIGURATION @@ -29,6 +77,18 @@ ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf" ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf" ynh_systemd_action --action=restart --service_name=fail2ban +#================================================= +# SPECIFIC RESTORATION +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Reinstalling dependencies..." --weight=1 + +if [ $database = "postgresql" ]; then + pkg_dependencies="$pkg_dependencies $pg_pkg_dependencies" +fi +ynh_install_app_dependencies $pkg_dependencies + #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= @@ -36,6 +96,9 @@ ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weig ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" +# Recreate a dedicated php-fpm config +ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$phpversion + #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= @@ -47,7 +110,18 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" # RESTORE THE DATABASE #================================================= -ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql +if [ $database = "mysql" ]; then + ynh_script_progression --message="Restoring MySQL database..." --weight=1 + db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) + ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd + ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql +elif [ $database = "postgresql" ]; then + ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1 + db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) + ynh_psql_test_if_first_run + ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd + ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name" +fi #================================================= # RESTORE VARIOUS FILES diff --git a/scripts/upgrade b/scripts/upgrade index 329c0eab..d086ee34 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -14,14 +14,45 @@ source /usr/share/yunohost/helpers #================================================= ynh_script_progression --message="Loading 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) +admin=$(ynh_app_setting_get --app=$app --key=admin) +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 +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +database=$(ynh_app_setting_get --app=$app --key=database) +upload=$(ynh_app_setting_get --app=$app --key=upload) +random_string=$(ynh_app_setting_get --app=$app --key=random_string) + email=$(ynh_user_get_info --username=$admin --key=mail) +fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) +fpm_free_footprint=$(ynh_app_setting_get --app=$app --key=fpm_free_footprint) +fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage) #================================================= # CHECK VERSION #================================================= +ynh_script_progression --message="Checking version..." --weight=1 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 + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # Restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -29,24 +60,60 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 +# 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 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 fpm_footprint doesn't exist, create it -if [ -z "${fpm_footprint:-}" ]; then +if [ -z "$fpm_footprint" ]; then fpm_footprint=low ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint fi # If fpm_free_footprint doesn't exist, create it -if [ -z "${fpm_free_footprint:-}" ]; then +if [ -z "$fpm_free_footprint" ]; then fpm_free_footprint=0 ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint fi # If fpm_usage doesn't exist, create it -if [ -z "${fpm_usage:-}" ]; then +if [ -z "$fpm_usage" ]; then fpm_usage=low ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage fi +# Cleaning legacy permissions +if ynh_legacy_permissions_exists; then + ynh_legacy_permissions_delete_all + + ynh_app_setting_delete --app=$app --key=is_public +fi + +# Switch $database to "mysql" or "postgresql" +if [[ $database == "1" ]] 2>/dev/null; then + database="mysql" + ynh_app_setting_set --app=$app --key=database --value=$database +elif [[ $database == "2" ]] 2>/dev/null; then + database="postgresql" + ynh_app_setting_set --app=$app --key=database --value=$database +fi + +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 + +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -56,16 +123,26 @@ then ynh_script_progression --message="Upgrading source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$install_dir" --keep="store/ .htconfig.php php.log" - ynh_setup_source --dest_dir="$install_dir/addon" --source_id="app_addons" + ynh_setup_source --dest_dir="$final_path" --keep="store/ .htconfig.php php.log" + ynh_setup_source --dest_dir="$final_path/addon" --source_id="app_addons" fi -mkdir -p "$install_dir/store" -mkdir -p "$install_dir/cache/smarty3" +mkdir -p "$final_path/store" +mkdir -p "$final_path/cache/smarty3" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" +chmod -R 775 $final_path/store $final_path/cache -chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" -chmod -R 775 $install_dir/store $install_dir/cache +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." --weight=1 + +if [ $database = "postgresql" ]; then + pkg_dependencies="$pkg_dependencies $pg_pkg_dependencies" +fi +ynh_install_app_dependencies $pkg_dependencies #================================================= # PHP-FPM CONFIGURATION @@ -74,6 +151,7 @@ ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1 # Create a dedicated PHP-FPM config ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # NGINX CONFIGURATION @@ -91,18 +169,26 @@ ynh_add_nginx_config ynh_script_progression --message="Updating a configuration file..." --weight=1 if [ $database = "mysql" ]; then - ynh_mysql_connect_as --user=$db_user --password="$db_pwd" --database=$db_name <<< "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;" + db_type=0 + db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) + # Change your databases character set and collation + ynh_mysql_connect_as --user=$db_user --password="$db_pwd" --database=$db_name \ + <<< "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;" +elif [ $database = "postgresql" ]; then + db_type=1 + db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +fi -ynh_add_config --template="../conf/htconfig.sample.php" --destination="$install_dir/.htconfig.php" +ynh_add_config --template="../conf/htconfig.sample.php" --destination="$final_path/.htconfig.php" # addon ldap config ynh_script_progression --message="Push LDAP configuration to .htconfig.php..." -cat ../conf/ldap_conf.php >> $install_dir/.htconfig.php -ynh_store_file_checksum --file=$install_dir/.htconfig.php +cat ../conf/ldap_conf.php >> $final_path/.htconfig.php +ynh_store_file_checksum --file=$final_path/.htconfig.php -chmod 600 "$install_dir/.htconfig.php" -chown $app:$app "$install_dir/.htconfig.php" +chmod 600 "$final_path/.htconfig.php" +chown $app:$app "$final_path/.htconfig.php" #================================================= # UPGRADE CRON JOB @@ -130,7 +216,14 @@ ynh_use_logrotate --non-append ynh_script_progression --message="Reconfiguring Fail2Ban..." --weight=1 # Create a dedicated Fail2Ban config -ynh_add_fail2ban_config --logpath="$install_dir/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP .*$" --max_retry="5" +ynh_add_fail2ban_config --logpath="$final_path/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP .*$" --max_retry="5" + +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT diff --git a/tests.toml b/tests.toml deleted file mode 100644 index eb73b8d5..00000000 --- a/tests.toml +++ /dev/null @@ -1,3 +0,0 @@ -test_format = 1.0 - -[default] \ No newline at end of file