diff --git a/check_process b/check_process index 6493356..86b0fb0 100644 --- a/check_process +++ b/check_process @@ -1,9 +1,8 @@ -;; Nom du test - auto_remove=1 +;; Test complet ; Manifest domain="domain.tld" + is_public=1 admin="john" - is_public="1" ; Checks pkg_linter=1 setup_sub_dir=0 @@ -13,9 +12,10 @@ setup_public=1 upgrade=1 #4.10.0 - upgrade=1 from_commit=2a54cd03f90c93b07150a64644ffc7f208110a18 + upgrade=1 from_commit=2a54cd03f90c93b07150a64644ffc7f208110a18 backup_restore=1 multi_instance=0 + port_already_use=0 change_url=1 ;;; Options Email= diff --git a/conf/app.src b/conf/app.src index 1460bbb..c013e89 100644 --- a/conf/app.src +++ b/conf/app.src @@ -4,3 +4,4 @@ SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true SOURCE_FILENAME=cryptpad.tar.gz +SOURCE_EXTRACT=true diff --git a/conf/nginx.conf b/conf/nginx.conf index 1fd74de..c46b37c 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,18 +1,19 @@ -location ^~ / { +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; +location __PATH__/ { - proxy_pass http://127.0.0.1:__PORT__; - proxy_redirect off; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Host $server_name; + proxy_pass http://127.0.0.1:__PORT__; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Host $server_name; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; - # Include SSOWAT user panel. - include conf.d/yunohost_panel.conf.inc; - more_clear_input_headers 'Accept-Encoding'; + # Include SSOWAT user panel. + include conf.d/yunohost_panel.conf.inc; + more_clear_input_headers 'Accept-Encoding'; } diff --git a/manifest.json b/manifest.json index 7f23f82..5b9e795 100644 --- a/manifest.json +++ b/manifest.json @@ -38,10 +38,6 @@ "fr": "CryptPad doit être installé dans un domaine ou sous-domaine dédié." } }, - { - "name": "admin", - "type": "user" - }, { "name": "is_public", "type": "boolean", @@ -50,6 +46,10 @@ "fr": "Si cette case est cochée, CryptPad sera accessible aux personnes n’ayant pas de compte. Vous pourrez changer ceci plus tard via la webadmin." }, "default": true + }, + { + "name": "admin", + "type": "user" } ] } diff --git a/scripts/backup b/scripts/backup index c6c42c3..d72c557 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -14,7 +15,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - ynh_clean_check_starting + true } # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -22,11 +23,12 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) final_path=$(ynh_app_setting_get --app=$app --key=final_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP diff --git a/scripts/change_url b/scripts/change_url index c292b89..f1d87e1 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -30,17 +30,18 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP #================================================= ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=2 # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { + ynh_clean_check_starting # 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 + # Restore it if the upgrade fails ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script @@ -69,7 +70,7 @@ fi #================================================= ynh_script_progression --message="Stopping a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action=stop --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # MODIFY URL IN NGINX CONF @@ -107,7 +108,7 @@ fi #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Serving content" +ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="server available" #================================================= # RELOAD NGINX diff --git a/scripts/install b/scripts/install index eaa37bb..77ad500 100644 --- a/scripts/install +++ b/scripts/install @@ -1,7 +1,7 @@ #!/bin/bash #================================================= -# GENERIC STARTING +# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -10,7 +10,7 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# MANAGE FAILURE OF THE SCRIPT +# MANAGE SCRIPT FAILURE #================================================= ynh_clean_setup () { @@ -24,20 +24,20 @@ ynh_abort_if_errors #================================================= domain=$YNH_APP_ARG_DOMAIN -is_public=$YNH_APP_ARG_IS_PUBLIC path_url="/" +is_public=$YNH_APP_ARG_IS_PUBLIC admin=$YNH_APP_ARG_ADMIN email=$(ynh_user_get_info --username=$admin --key=mail) app=$YNH_APP_INSTANCE_NAME #================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS +# 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 "This path already contains a folder" +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 @@ -45,9 +45,10 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= +ynh_script_progression --message="Storing installation settings..." ynh_app_setting_set --app=$app --key=domain --value=$domain -ynh_app_setting_set --app=$app --key=path_url --value=$path_url +ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=admin --value=$admin #================================================= @@ -66,11 +67,10 @@ porti=$(ynh_find_port --port=$(($port + 1))) ynh_app_setting_set --app=$app --key=porti --value=$porti #================================================= -# INSTALL NODEJS & YARN +# INSTALL DEPENDENCIES #================================================= ynh_script_progression --message="Installing dependencies..." --weight=20 -# Install Nodejs ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version #================================================= @@ -102,22 +102,25 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config +#================================================= +# ADD A CONFIGURATION +#================================================= +ynh_script_progression --message="Adding a configuration file..." + +ynh_add_config --template="../conf/config.js" --destination="$final_path/config/config.js" + +chmod 600 "$final_path/config/config.js" +chown $app "$final_path/config/config.js" + #================================================= # SETUP SYSTEMD #================================================= ynh_script_progression --message="Configuring a systemd service..." --weight=1 env_path="$PATH" +# Create a dedicated systemd config ynh_add_systemd_config -#================================================= -# CONFIGURE CONFIG.JS -#================================================= - -ynh_add_config --template="../conf/config.js" --destination="$final_path/config/config.js" -chmod 600 "$final_path/config/config.js" -chown $app "$final_path/config/config.js" - #================================================= # INSTALL CRYPTPAD #================================================= @@ -131,13 +134,7 @@ pushd "$final_path" popd #================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Configuring log rotation..." --weight=1 - -# Use logrotate to manage application logfile(s) -ynh_use_logrotate - +# GENERIC FINALIZATION #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= @@ -151,7 +148,7 @@ yunohost service add $app --description="Zero Knowledge realtime collaborative e ynh_script_progression --message="Starting a systemd service..." --weight=2 # Start a systemd service -ynh_systemd_action --service_name=$app --action=start --log_path="systemd" --line_match="Serving content" +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="server available" #================================================= # SETUP SSOWAT diff --git a/scripts/remove b/scripts/remove index a9e6f33..e201fda 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,7 +1,7 @@ #!/bin/bash #================================================= -# GENERIC STARTING +# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -16,8 +16,8 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME -port=$(ynh_app_setting_get --app=$app --key=port) 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) #================================================= @@ -29,7 +29,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) # 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 then - ynh_script_progression --message="Removing $app service..." --weight=3 + ynh_script_progression --message="Removing $app service integration..." --weight=3 yunohost service remove $app fi @@ -41,17 +41,10 @@ ynh_script_progression --message="Stopping and removing the systemd service..." # Remove the dedicated systemd config ynh_remove_systemd_config -#================================================= -# REMOVE NODEJS -#================================================= -ynh_script_progression --message="Removing dependencies..." --weight=3 - -ynh_remove_nodejs - #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing $app main directory..." --weight=3 +ynh_script_progression --message="Removing app main directory..." --weight=3 # Remove the app directory securely ynh_secure_remove --file="$final_path" @@ -64,6 +57,13 @@ ynh_script_progression --message="Removing NGINX web server configuration..." -- # Remove the dedicated NGINX config ynh_remove_nginx_config +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_script_progression --message="Removing dependencies..." --weight=3 + +ynh_remove_nodejs + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/restore b/scripts/restore index 6953f35..81c92b5 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -44,6 +44,7 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Restoring the NGINX web server configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" @@ -58,11 +59,10 @@ ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring CryptPad main directory..." --weight=6 +ynh_script_progression --message="Restoring the app main directory..." --weight=6 ynh_restore_file --origin_path="$final_path" -# Restore permissions on app files chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" @@ -73,7 +73,7 @@ chmod 600 "$final_path/config/config.js" #================================================= ynh_script_progression --message="Reinstalling dependencies..." --weight=7 -# Install Nodejs +# Define and install dependencies ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version #================================================= @@ -96,7 +96,7 @@ yunohost service add $app --description="Zero Knowledge realtime collaborative e #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Serving content" +ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="server available" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index 1a70a51..7b46a12 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,7 +1,7 @@ #!/bin/bash #================================================= -# GENERIC STARTING +# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -17,9 +17,9 @@ 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_url) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) +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) email=$(ynh_user_get_info --username=$admin --key=mail) port=$(ynh_app_setting_get --app=$app --key=port) porti=$(ynh_app_setting_get --app=$app --key=porti) @@ -27,9 +27,34 @@ porti=$(ynh_app_setting_get --app=$app --key=porti) #================================================= # CHECK VERSION #================================================= +ynh_script_progression --message="Checking version..." 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 () { + ynh_clean_check_starting + # 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 +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." --weight=1 + +ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" + #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -48,29 +73,6 @@ if ynh_legacy_permissions_exists; then ynh_app_setting_delete --app=$app --key=is_public fi -#================================================= -# 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 -#================================================= -# STOP SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=1 - -ynh_systemd_action --service_name=$app --action=stop --log_path="/var/log/$app/$app.log" - #================================================= # CREATE DEDICATED USER #================================================= @@ -104,19 +106,12 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - ynh_add_nginx_config #================================================= -# INSTALL NODEJS +# UPGRADE DEPENDENCIES #================================================= ynh_script_progression --message="Upgrading dependencies..." --weight=6 -# Install Nodejs ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version -#================================================= -# CONFIGURE CONFIG.JS -#================================================= - -#ynh_add_config --template="../conf/config.js" --destination="$final_path/config/config.js" - #================================================= # INSTALL CRYPTPAD #================================================= @@ -139,13 +134,7 @@ env_path="$PATH" ynh_add_systemd_config #================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 - -# Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append - +# GENERIC FINALIZATION #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= @@ -158,7 +147,7 @@ yunohost service add $app --description="Zero Knowledge realtime collaborative e #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="server available" +ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="server available" #================================================= # RELOAD NGINX