From 2b66f4319f44ef9d5046586fe012e98c09eeff87 Mon Sep 17 00:00:00 2001 From: Salamandar <6552989+Salamandar@users.noreply.github.com> Date: Mon, 29 Jan 2024 23:41:03 +0100 Subject: [PATCH] Revert "Testing" --- README.md | 6 ++ README_fr.md | 6 ++ check_process | 23 ++++++ conf/nginx.conf | 1 - doc/ADMIn.md | 3 - doc/DISCLAIMER.md | 3 + doc/{ADMIN_fr.md => DISCLAIMER_fr.md} | 2 +- manifest.json | 54 +++++++++++++ manifest.toml | 70 ----------------- scripts/_common.sh | 3 + scripts/backup | 25 +++++- scripts/change_url | 89 ++++++++++++++++++++- scripts/install | 109 +++++++++++++++++++++++--- scripts/remove | 65 ++++++++++++++- scripts/restore | 73 ++++++++++++----- scripts/upgrade | 69 +++++++++++++--- tests.toml | 8 -- 17 files changed, 478 insertions(+), 131 deletions(-) create mode 100644 check_process delete mode 100644 doc/ADMIn.md create mode 100644 doc/DISCLAIMER.md rename doc/{ADMIN_fr.md => DISCLAIMER_fr.md} (66%) create mode 100644 manifest.json delete mode 100644 manifest.toml delete mode 100644 tests.toml diff --git a/README.md b/README.md index db71bbc..f3d6439 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,12 @@ And as described in the couchdb official website: ![Screenshot of CouchDB](./doc/screenshots/Apache_CouchDB_v2.1.1_Fauxton_Console.png) +## Disclaimers / important information + +## Configuration + +You can do most configuration of CouchDB from fauxton, the web interface, accessible at the domain you specified: `https://domain.tld/_utils/index.html` + ## Documentation and resources * Official app website: diff --git a/README_fr.md b/README_fr.md index 9a7a3ea..49b6a83 100644 --- a/README_fr.md +++ b/README_fr.md @@ -29,6 +29,12 @@ Comme le présente wikipédia: ![Capture d’écran de CouchDB](./doc/screenshots/Apache_CouchDB_v2.1.1_Fauxton_Console.png) +## Avertissements / informations importantes + +## Configuration + +Vous pouvez effectuer la plupart des configurations de CouchDB à partir de fauxton, l'interface Web, accessible sur le domaine que vous avez spécifié : `https://domain.tld/_utils/index.html` + ## Documentations et ressources * Site officiel de l’app : diff --git a/check_process b/check_process new file mode 100644 index 0000000..5be5a1a --- /dev/null +++ b/check_process @@ -0,0 +1,23 @@ +;; Test complet + ; Manifest + domain="domain.tld" + path="/path" + is_public=1 + password="1Strong-Password" + ; Checks + pkg_linter=1 + setup_sub_dir=1 + setup_root=1 + setup_nourl=0 + setup_private=1 + setup_public=1 + upgrade=1 + # 3.1.1~ynh3 + upgrade=1 from_commit=0e91958cfd8406e71e9c4e506620c5e9b7110a5f + backup_restore=1 + multi_instance=0 + port_already_use=0 + change_url=1 +;;; Options +Email=squeak@eauchat.org +Notification=none diff --git a/conf/nginx.conf b/conf/nginx.conf index 861e68e..e89a443 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,4 +1,3 @@ -#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__/ { proxy_pass http://127.0.0.1:__PORT__/; diff --git a/doc/ADMIn.md b/doc/ADMIn.md deleted file mode 100644 index 92e33bd..0000000 --- a/doc/ADMIn.md +++ /dev/null @@ -1,3 +0,0 @@ -## Configuration - -You can do most configuration of CouchDB from fauxton, the web interface, accessible at the domain you specified: `https://__DOMAIN____PATH__/_utils/index.html` diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md new file mode 100644 index 0000000..3d835fd --- /dev/null +++ b/doc/DISCLAIMER.md @@ -0,0 +1,3 @@ +## Configuration + +You can do most configuration of CouchDB from fauxton, the web interface, accessible at the domain you specified: `https://domain.tld/_utils/index.html` diff --git a/doc/ADMIN_fr.md b/doc/DISCLAIMER_fr.md similarity index 66% rename from doc/ADMIN_fr.md rename to doc/DISCLAIMER_fr.md index 955f6b0..5470e72 100644 --- a/doc/ADMIN_fr.md +++ b/doc/DISCLAIMER_fr.md @@ -1,3 +1,3 @@ ## Configuration -Vous pouvez effectuer la plupart des configurations de CouchDB à partir de fauxton, l'interface Web, accessible sur le domaine que vous avez spécifié : `https://__DOMAIN____PATH__/_utils/index.html` +Vous pouvez effectuer la plupart des configurations de CouchDB à partir de fauxton, l'interface Web, accessible sur le domaine que vous avez spécifié : `https://domain.tld/_utils/index.html` diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..28e31ca --- /dev/null +++ b/manifest.json @@ -0,0 +1,54 @@ +{ + "name": "CouchDB", + "id": "couchdb", + "packaging_format": 1, + "description": { + "en": "Open-source document-oriented NoSQL database", + "fr": "Système de gestion de base de données orienté documents" + }, + "version": "3.2.2~ynh2", + "url": "https://couchdb.apache.org/", + "upstream": { + "license": "Apache-2.0", + "website": "https://couchdb.apache.org/", + "admindoc": "https://docs.couchdb.org/en/stable/", + "code": "https://github.com/apache/couchdb", + "cpe": "cpe:2.3:a:apache:couchdb" + }, + "license": "Apache-2.0", + "maintainer": { + "name": "Squeak", + "email": "squeak@eauchat.org", + "url": "https://squeak.eauchat.org" + }, + "requirements": { + "yunohost": ">= 11.1" + }, + "multi_instance": false, + "services": [ + "nginx" + ], + "arguments": { + "install": [ + { + "name": "domain", + "type": "domain" + }, + { + "name": "path", + "type": "path", + "example": "/couch", + "default": "/couch" + }, + { + "name": "is_public", + "type": "boolean", + "default": true + }, + { + "name": "password", + "type": "password" + } + ] + } +} diff --git a/manifest.toml b/manifest.toml deleted file mode 100644 index a071623..0000000 --- a/manifest.toml +++ /dev/null @@ -1,70 +0,0 @@ -#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json - -packaging_format = 2 - -id = "couchdb" -name = "CouchDB" -description.en = "Open-source document-oriented NoSQL database" -description.fr = "Système de gestion de base de données orienté documents" - -version = "3.2.2~ynh2" - -maintainers = ["Squeak"] - -[upstream] -license = "Apache-2.0" -website = "https://couchdb.apache.org/" -admindoc = "https://docs.couchdb.org/en/stable/" -code = "https://github.com/apache/couchdb" -cpe = "cpe:2.3:a:apache:couchdb" - -[integration] -yunohost = ">= 11.1" -architectures = "all" -multi_instance = false - -ldap = "not_relevant" - -sso = "not_relevant" - -disk = "20M" -ram.build = "150M" -ram.runtime = "60M" - -[install] - [install.domain] - type = "domain" - - [install.path] - type = "path" - default = "/couch" - - [install.init_main_permission] - type = "group" - default = "visitors" - - [install.password] - type = "password" - -[resources] - [resources.system_user] - - [resources.install_dir] - dir = "/opt/couchdb" - - [resources.data_dir] - - [resources.permissions] - main.url = "/" - - [resources.ports] - main.default = 5984 - - [resources.apt] - packages = ["gnupg", "ca-certificates"] - - # Find a way to do that here - # [resources.apt.extras.couchdb] - # repo = "deb https://apache.jfrog.io/artifactory/couchdb-deb/ $(lsb_release -c -s) main" - # key = "https://couchdb.apache.org/repo/keys.asc" - # packages = ["couchdb"] diff --git a/scripts/_common.sh b/scripts/_common.sh index 944a65e..196f5af 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,6 +4,9 @@ # COMMON VARIABLES #================================================= +# dependencies used by the app (must be on a single line) +pkg_dependencies="gnupg ca-certificates" + #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index 907da7a..143d201 100755 --- a/scripts/backup +++ b/scripts/backup @@ -10,6 +10,27 @@ 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 installation settings..." + +app=$YNH_APP_INSTANCE_NAME + +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) + #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= @@ -19,13 +40,13 @@ 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 DATA DIR #================================================= -ynh_backup --src_path="$data_dir" --is_big +ynh_backup --src_path="$datadir" --is_big #================================================= # BACKUP THE NGINX CONFIGURATION diff --git a/scripts/change_url b/scripts/change_url index 16e0f3c..04a206d 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -9,6 +9,62 @@ source _common.sh source /usr/share/yunohost/helpers +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +old_domain=$YNH_APP_OLD_DOMAIN +old_path=$YNH_APP_OLD_PATH + +new_domain=$YNH_APP_NEW_DOMAIN +new_path=$YNH_APP_NEW_PATH + +app=$YNH_APP_INSTANCE_NAME + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." --weight=2 + +# Needed for helper "ynh_add_nginx_config" +final_path=$(ynh_app_setting_get --app=$app --key=final_path) + +# Add settings here as needed by your application +port=$(ynh_app_setting_get --app=$app --key=port) + +#================================================= +# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=15 + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. + ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" + + # Restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# CHECK WHICH PARTS SHOULD BE CHANGED +#================================================= + +change_domain=0 +if [ "$old_domain" != "$new_domain" ] +then + change_domain=1 +fi + +change_path=0 +if [ "$old_path" != "$new_path" ] +then + change_path=1 +fi + #================================================= # STANDARD MODIFICATIONS #================================================= @@ -16,7 +72,38 @@ source /usr/share/yunohost/helpers #================================================= ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2 -ynh_change_url_nginx_config +nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf + +# Change the path in the NGINX config file +if [ $change_path -eq 1 ] +then + # Make a backup of the original NGINX config file if modified + ynh_backup_if_checksum_is_different --file="$nginx_conf_path" + # Set global variables for NGINX helper + domain="$old_domain" + path_url="$new_path" + # Create a dedicated NGINX config + ynh_add_nginx_config +fi + +# Change the domain for NGINX +if [ $change_domain -eq 1 ] +then + # Delete file checksum for the old conf file location + ynh_delete_file_checksum --file="$nginx_conf_path" + mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf + # Store file checksum for the new config file location + ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" +fi + +#================================================= +# GENERIC FINALISATION +#================================================= +# 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/install b/scripts/install index 706e974..8ebd4c9 100755 --- a/scripts/install +++ b/scripts/install @@ -9,6 +9,69 @@ 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=$YNH_APP_ARG_PATH +is_public=$YNH_APP_ARG_IS_PUBLIC +password=$YNH_APP_ARG_PASSWORD + +app=$YNH_APP_INSTANCE_NAME + +#================================================= +# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS +#================================================= +ynh_script_progression --message="Validating installation parameters..." --weight=1 + +final_path=/opt/couchdb +test ! -e "$final_path" || ynh_die --message="This path already contains a folder" + +datadir=/var/lib/$app + +# 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=password --value=$password +ynh_app_setting_set --app=$app --key=final_path --value=$final_path +ynh_app_setting_set --app=$app --key=datadir --value=$datadir + +#================================================= +# STANDARD MODIFICATIONS +#================================================= +# FIND AND OPEN A PORT +#================================================= +ynh_script_progression --message="Finding an available port..." --weight=2 + +# Find an available port +port=$(ynh_find_port --port=5984) +ynh_app_setting_set --app=$app --key=port --value=$port + +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Installing dependencies..." --weight=8 + +ynh_install_app_dependencies $pkg_dependencies + #================================================= # NGINX CONFIGURATION #================================================= @@ -24,22 +87,19 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Installing CouchDB..." --weight=60 -echo "\ -couchdb couchdb/mode select standalone +COUCHDB_PASSWORD=$password +echo "couchdb couchdb/mode select standalone couchdb couchdb/mode seen true couchdb couchdb/bindaddress string 127.0.0.1 couchdb couchdb/bindaddress seen true -couchdb couchdb/cookie string $password -couchdb couchdb/adminpass password $password +couchdb couchdb/cookie string ${COUCHDB_PASSWORD} +couchdb couchdb/adminpass password ${COUCHDB_PASSWORD} couchdb couchdb/adminpass seen true -couchdb couchdb/adminpass_again password $password +couchdb couchdb/adminpass_again password ${COUCHDB_PASSWORD} couchdb couchdb/adminpass_again seen true" | debconf-set-selections DEBIAN_FRONTEND=noninteractive # apt-get install -y --force-yes couchdb -ynh_install_extra_app_dependencies \ - --repo="deb https://apache.jfrog.io/artifactory/couchdb-deb/ $(lsb_release -c -s) main" \ - --key="https://couchdb.apache.org/repo/keys.asc" \ - --package="couchdb" +ynh_install_extra_app_dependencies --repo="deb https://apache.jfrog.io/artifactory/couchdb-deb/ $(lsb_release -c -s) main" --package="couchdb" --key="https://couchdb.apache.org/repo/keys.asc" #================================================= # ADD A CONFIGURATION @@ -47,11 +107,11 @@ ynh_install_extra_app_dependencies \ ynh_script_progression --message="Adding a configuration file..." --weight=2 # Customize a bit the couch config -ynh_add_config --template="../conf/couch_ynh.ini" --destination="$install_dir/etc/local.d/couch_ynh.ini" +ynh_add_config --template="../conf/couch_ynh.ini" --destination="$final_path/etc/local.d/couch_ynh.ini" -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" -chown -R "$app:$app" "$install_dir" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:$app "$final_path" #================================================= # GENERIC FINALIZATION @@ -78,6 +138,29 @@ ynh_script_progression --message="Configuring Fail2Ban..." --weight=3 # Create a dedicated Fail2Ban config ynh_add_fail2ban_config --logpath="/var/log/couchdb/couchdb.log" --failregex="[warning] .*couch_httpd_auth: Authentication failed for user .+ from " --max_retry=5 +#================================================= +# SETUP SSOWAT +#================================================= +ynh_script_progression --message="Configuring permissions..." --weight=3 + +# Setup that clicking SSO tile opens fauxton UI +ynh_permission_url --permission="main" --url="/_utils/index.html" --add_url="/" --auth_header=false + +# Make app public if necessary +if [ $is_public -eq 1 ] +then + # Everyone can access the app. + # The "main" permission is automatically created before the install script. + ynh_permission_update --permission="main" --add="visitors" +fi + +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading NGINX web server..." --weight=3 + +ynh_systemd_action --service_name=nginx --action=reload + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/remove b/scripts/remove index 469ef62..a8ba343 100755 --- a/scripts/remove +++ b/scripts/remove @@ -9,12 +9,23 @@ source _common.sh source /usr/share/yunohost/helpers +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." --weight=1 + +app=$YNH_APP_INSTANCE_NAME + +domain=$(ynh_app_setting_get --app=$app --key=domain) +port=$(ynh_app_setting_get --app=$app --key=port) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) + #================================================= # STANDARD REMOVE #================================================= # REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= -ynh_script_progression --message="Removing system configurations related to $app..." --weight=5 # Remove the service from the list of services known by YunoHost (added from `yunohost service add`) if ynh_exec_warn_less yunohost service status $app >/dev/null @@ -23,15 +34,67 @@ then yunohost service remove $app fi +#================================================= +# REMOVE LOGROTATE CONFIGURATION +#================================================= +ynh_script_progression --message="Removing logrotate configuration..." --weight=1 + # Remove the app-specific logrotate config ynh_remove_logrotate +#================================================= +# 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 DATA DIR +#================================================= + +# Remove the data directory if --purge option is used +if [ "${YNH_APP_PURGE:-0}" -eq 1 ] +then + ynh_script_progression --message="Removing app data directory..." --weight=1 + ynh_secure_remove --file="$datadir" +fi + +#================================================= +# REMOVE NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Removing NGINX web server configuration..." --weight=2 + # Remove the dedicated NGINX config ynh_remove_nginx_config +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_script_progression --message="Removing dependencies..." --weight=16 + +# Remove metapackage and its dependencies +ynh_remove_app_dependencies + +#================================================= +# REMOVE FAIL2BAN CONFIGURATION +#================================================= +ynh_script_progression --message="Removing Fail2Ban configuration..." --weight=2 + # Remove the dedicated Fail2Ban config ynh_remove_fail2ban_config +#================================================= +# GENERIC FINALIZATION +#================================================= +# REMOVE DEDICATED USER +#================================================= +ynh_script_progression --message="Removing the dedicated system user..." --weight=2 + +# Delete a system user +ynh_system_user_delete --username=$app + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 82e7cca..8556d62 100755 --- a/scripts/restore +++ b/scripts/restore @@ -10,6 +10,38 @@ 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 installation settings..." --weight=1 + +app=$YNH_APP_INSTANCE_NAME + +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +password=$(ynh_app_setting_get --app=$app --key=password) +port=$(ynh_app_setting_get --app=$app --key=port) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) + +#================================================= +# CHECK IF THE APP CAN BE RESTORED +#================================================= +ynh_script_progression --message="Validating restoration parameters..." --weight=2 + +test ! -d $final_path \ + || ynh_die --message="There is already a directory: $final_path " + #================================================= # STANDARD RESTORATION STEPS #================================================= @@ -17,16 +49,16 @@ source /usr/share/yunohost/helpers #================================================= ynh_script_progression --message="Restoring the app main directory..." --weight=10 -ynh_restore_file --origin_path="$install_dir" +ynh_restore_file --origin_path="$final_path" #================================================= # RESTORE THE DATA DIRECTORY #================================================= ynh_script_progression --message="Restoring the data directory..." --weight=1 -ynh_restore_file --origin_path="$data_dir" --not_mandatory +ynh_restore_file --origin_path="$datadir" --not_mandatory -mkdir -p $data_dir +mkdir -p $datadir #================================================= # RESTORE FAIL2BAN CONFIGURATION @@ -39,6 +71,14 @@ ynh_systemd_action --action=restart --service_name=fail2ban #================================================= # SPECIFIC RESTORATION +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Reinstalling dependencies..." --weight=6 + +# Define and install dependencies +ynh_install_app_dependencies $pkg_dependencies + #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= @@ -51,30 +91,27 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= ynh_script_progression --message="Reinstalling couchdb..." --weight=40 -echo "\ -couchdb couchdb/mode select standalone +COUCHDB_PASSWORD=$password +echo "couchdb couchdb/mode select standalone couchdb couchdb/mode seen true couchdb couchdb/bindaddress string 127.0.0.1 couchdb couchdb/bindaddress seen true -couchdb couchdb/cookie string $password -couchdb couchdb/adminpass password $password +couchdb couchdb/cookie string ${COUCHDB_PASSWORD} +couchdb couchdb/adminpass password ${COUCHDB_PASSWORD} couchdb couchdb/adminpass seen true -couchdb couchdb/adminpass_again password $password +couchdb couchdb/adminpass_again password ${COUCHDB_PASSWORD} couchdb couchdb/adminpass_again seen true" | debconf-set-selections DEBIAN_FRONTEND=noninteractive # apt-get install -y --force-yes couchdb -ynh_install_extra_app_dependencies \ - --repo="deb https://apache.jfrog.io/artifactory/couchdb-deb/ $(lsb_release -c -s) main" \ - --key="https://couchdb.apache.org/repo/keys.asc" \ - --package="couchdb" +ynh_install_extra_app_dependencies --repo="deb https://apache.jfrog.io/artifactory/couchdb-deb/ $(lsb_release -c -s) main" --package="couchdb" --key="https://couchdb.apache.org/repo/keys.asc" -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" -chown -R $app:$app "$install_dir" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:$app "$final_path" -chmod 750 "$data_dir" -chmod -R o-rwx "$data_dir" -chown -R $app:www-data "$data_dir" +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R $app:www-data "$datadir" #================================================= # RESTORE THE LOGROTATE CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index 4ef7419..f61ae1d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,8 +9,47 @@ source _common.sh source /usr/share/yunohost/helpers +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." --weight=1 + +app=$YNH_APP_INSTANCE_NAME + +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +port=$(ynh_app_setting_get --app=$app --key=port) +password=$(ynh_app_setting_get --app=$app --key=password) + +#================================================= +# 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=15 + +# 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 + +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." --weight=15 + +ynh_install_app_dependencies $pkg_dependencies + #================================================= # NGINX CONFIGURATION #================================================= @@ -29,22 +68,19 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading CouchDB..." --weight=50 - echo "\ - couchdb couchdb/mode select standalone + COUCHDB_PASSWORD=$password + echo "couchdb couchdb/mode select standalone couchdb couchdb/mode seen true couchdb couchdb/bindaddress string 127.0.0.1 couchdb couchdb/bindaddress seen true - couchdb couchdb/cookie string $password - couchdb couchdb/adminpass password $password + couchdb couchdb/cookie string ${COUCHDB_PASSWORD} + couchdb couchdb/adminpass password ${COUCHDB_PASSWORD} couchdb couchdb/adminpass seen true - couchdb couchdb/adminpass_again password $password + couchdb couchdb/adminpass_again password ${COUCHDB_PASSWORD} couchdb couchdb/adminpass_again seen true" | debconf-set-selections DEBIAN_FRONTEND=noninteractive # apt-get install -y --force-yes couchdb - ynh_install_extra_app_dependencies \ - --repo="deb https://apache.jfrog.io/artifactory/couchdb-deb/ $(lsb_release -c -s) main" \ - --key="https://couchdb.apache.org/repo/keys.asc" \ - --package="couchdb" + ynh_install_extra_app_dependencies --repo="deb https://apache.jfrog.io/artifactory/couchdb-deb/ $(lsb_release -c -s) main" --package="couchdb" --key="https://couchdb.apache.org/repo/keys.asc" fi #================================================= @@ -52,11 +88,11 @@ fi #================================================= ynh_script_progression --message="Updating a configuration file..." --weight=1 -ynh_add_config --template="../conf/couch_ynh.ini" --destination="$install_dir/etc/local.d/couch_ynh.ini" +ynh_add_config --template="../conf/couch_ynh.ini" --destination="$final_path/etc/local.d/couch_ynh.ini" -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" -chown -R "$app:$app" "$install_dir" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:$app "$final_path" #================================================= # GENERIC FINALIZATION @@ -83,6 +119,13 @@ ynh_script_progression --message="Reconfiguring Fail2Ban..." --weight=3 # Create a dedicated Fail2Ban config ynh_add_fail2ban_config --logpath="/var/log/couchdb/couchdb.log" --failregex="[warning] .*couch_httpd_auth: Authentication failed for user .+ from " --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 c2deb4d..0000000 --- a/tests.toml +++ /dev/null @@ -1,8 +0,0 @@ -#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json - -test_format = 1.0 - -[default] - - [default.test_upgrade_from.0e91958cfd8406e71e9c4e506620c5e9b7110a5f] - name = "3.1.1~ynh3"