diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..2729a6b --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,55 @@ +--- +name: Bug report +about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently. + +--- + +**How to post a meaningful bug report** +1. *Read this whole template first.* +2. *Determine if you are on the right place:* + - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!* + - *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.* + - *When in doubt, post here and we will figure it out together.* +3. *Delete the italic comments as you write over them below, and remove this guide.* +--- + +### Describe the bug + +*A clear and concise description of what the bug is.* + +### Context + +- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...* +- YunoHost version: x.x.x +- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...* +- Are you in a special context or did you perform some particular tweaking on your YunoHost instance?: *no / yes* + - If yes, please explain: +- Using, or trying to install package version/branch: +- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`* + +### Steps to reproduce + +- *If you performed a command from the CLI, the command itself is enough. For example:* + ```sh + sudo yunohost app install the_app + ``` +- *If you used the webadmin, please perform the equivalent command from the CLI first.* +- *If the error occurs in your browser, explain what you did:* + 1. *Go to '...'* + 2. *Click on '...'* + 3. *Scroll down to '...'* + 4. *See error* + +### Expected behavior + +*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.* + +### Logs + +*When an operation fails, YunoHost provides a simple way to share the logs.* +- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.* +- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.* + +*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)* + +*If applicable and useful, add screenshots to help explain your problem.* diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..ef70e18 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,16 @@ +## Problem + +- *Description of why you made this PR* + +## Solution + +- *And how do you fix that problem* + +## PR Status + +- [ ] Code finished and ready to be reviewed/tested +- [ ] The fix/enhancement were manually tested (if applicable) + +## Automatic tests + +Automatic tests can be triggered on https://ci-apps-dev.yunohost.org/ *after creating the PR*, by commenting "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!". (N.B. : for this to work you need to be a member of the Yunohost-Apps organization) diff --git a/check_process b/check_process index a3c2682..653c634 100644 --- a/check_process +++ b/check_process @@ -2,9 +2,9 @@ ; Manifest domain="domain.tld" path="/path" - admin="john" infcloud=1 language="French" + admin="john" ; Checks pkg_linter=1 setup_sub_dir=1 @@ -15,7 +15,6 @@ upgrade=1 backup_restore=1 multi_instance=0 - incorrect_path=1 port_already_use=0 # Because of the modification of the path for InfCloud, we can't try the change_url script here. change_url=0 @@ -23,9 +22,9 @@ ; Manifest domain="domain.tld" path="/path" - admin="john" infcloud=0 language="French" + admin="john" ; Checks setup_sub_dir=1 setup_root=1 diff --git a/doc/.gitkeep b/doc/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md new file mode 100644 index 0000000..28d3633 --- /dev/null +++ b/doc/DESCRIPTION.md @@ -0,0 +1,3 @@ +Radicale is a small but powerful CalDAV (calendars, todo-lists) and CardDAV (contacts) server. + +* This package bring a web interface for Radicale named InfCloud. diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md new file mode 100644 index 0000000..286321a --- /dev/null +++ b/doc/DISCLAIMER.md @@ -0,0 +1,12 @@ +## Configuration + +Use the file `/etc/radicale/config` to change the main configuration of radicale. +The file `/etc/radicale/logging` to change the level of logging. +And the file `/etc/radicale/rights` to edit the way the calendars will be sharing. + +InfCloud has its own config file, at /var/www/radicale/infcloud/config.js + +## Limitations + +* The version 1.1.6 is relatively old. There's a version 2 of radicale, but this new version dos not support LDAP yet. + diff --git a/doc/screenshots/.gitkeep b/doc/screenshots/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/manifest.json b/manifest.json index 576430a..ec564fd 100644 --- a/manifest.json +++ b/manifest.json @@ -8,6 +8,11 @@ }, "version": "1.1.6~ynh5", "url": "http://radicale.org", + "upstream": { + "license": "GPL-3.0,AGPL-3.0", + "website": "http://radicale.org", + "admindoc": "https://github.com/Kozea/Radicale/blob/website/pages/user_documentation.rst" + }, "license": "GPL-3.0,AGPL-3.0", "maintainer": { "name": "", @@ -37,10 +42,6 @@ "example": "/radicale", "default": "/radicale" }, - { - "name": "admin", - "type": "user" - }, { "name": "infcloud", "type": "boolean", @@ -54,11 +55,15 @@ "name": "language", "type": "string", "ask": { - "en": "Choose your interface language", - "fr": "Choisissez la langue de l'interface" + "en": "Choose the application language", + "fr": "Choisissez la langue de l'application" }, "choices" : ["Czech", "Danish", "German", "English/US", "Spanish", "French", "Italian", "Japan", "Hungarian", "Dutch", "Slovak", "Turkish", "Russian", "Ukrainian", "Chinese"], "default" : "English/US" + }, + { + "name": "admin", + "type": "user" } ] } diff --git a/scripts/_common.sh b/scripts/_common.sh index 0b9a9c9..98b60e1 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -9,15 +9,7 @@ YNH_PHP_VERSION="7.3" pkg_dependencies="python-pip python-virtualenv virtualenv python-dev libldap2-dev libsasl2-dev libssl-dev uwsgi uwsgi-plugin-python" #================================================= -# PACKAGE CHECK BYPASSING... -#================================================= - -IS_PACKAGE_CHECK () { - return $(env | grep -c container=lxc) -} - -#================================================= -# BOOLEAN CONVERTER +# PERSONAL HELPERS #================================================= bool_to_01 () { @@ -34,11 +26,6 @@ bool_to_true_false () { echo "$var" } -#================================================= -# FUTUR OFFICIAL HELPERS -#================================================= - - #================================================= # EXPERIMENTAL HELPERS #================================================= @@ -388,3 +375,7 @@ ynh_app_changelog () { sed -in-place "s@\*(\([[:alnum:]]*\)) -> \(.*\)@* __URL_TAG1__\2__URL_TAG2__${repo}/commit/\1__URL_TAG3__@g" changelog fi } + +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= diff --git a/scripts/backup b/scripts/backup index 8761868..e0cf4cf 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 @@ -13,6 +14,9 @@ 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 @@ -37,47 +41,42 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP THE APP MAIN DIR #================================================= -ynh_backup "$final_path" +ynh_backup --src_path="$final_path" -ynh_backup "/opt/yunohost/$app" #================================================= -# BACKUP NGINX CONFIGURATION +# BACKUP THE NGINX CONFIGURATION #================================================= -ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= -# BACKUP PHP-FPM CONFIGURATION +# BACKUP THE PHP-FPM CONFIGURATION #================================================= if [ $infcloud -eq 1 ] then - ynh_backup "/etc/php/$phpversion/fpm/pool.d/$app.conf" + ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" fi #================================================= # SPECIFIC BACKUP #================================================= -# BACKUP UWSGI CONFIG -#================================================= - -ynh_backup "/etc/uwsgi/apps-available/radicale.ini" - -#================================================= -# BACKUP RADICALE CONFIGURATION -#================================================= - -ynh_backup "/etc/$app" - -#================================================= -# BACKUP LOGROTATE CONFIGURATION +# BACKUP LOGROTATE #================================================= ynh_backup "/etc/logrotate.d/$app" +#================================================= +# BACKUP VARIOUS FILES +#================================================= + +ynh_backup --src_path="/etc/$app" +ynh_backup --src_path="/opt/yunohost/$app" +ynh_backup --src_path="/etc/uwsgi/apps-available/radicale.ini" + #================================================= # END OF SCRIPT #================================================= -ynh_print_info --message="Backup script completed. Please wait for YunoHost to create the backup." +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index 2a1781a..ee5548c 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -12,7 +12,6 @@ source /usr/share/yunohost/helpers #================================================= # RETRIEVE ARGUMENTS #================================================= -ynh_script_progression --message="Retrieve arguments from the manifest" old_domain=$YNH_APP_OLD_DOMAIN old_path=$YNH_APP_OLD_PATH @@ -25,10 +24,38 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Load settings" --weight=2 +ynh_script_progression --message="Loading installation settings..." --weight=2 -infcloud=$(ynh_app_setting_get $app infcloud) -final_path=$(ynh_app_setting_get $app final_path) +# Needed for helper "ynh_add_nginx_config" +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +infcloud=$(ynh_app_setting_get --app=$app --key=infcloud) + +#================================================= +# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." + +# 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 + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# ACTIVATE MAINTENANCE MODE +#================================================= +ynh_script_progression --message="Activate maintenance mode" + +path_url=$old_path +domain=$old_domain +ynh_maintenance_mode_ON #================================================= # CHECK THE SYNTAX OF THE PATHS @@ -46,15 +73,6 @@ test -n "$new_path" || new_path="/" new_path=$(ynh_normalize_url_path $new_path) old_path=$(ynh_normalize_url_path $old_path) -#================================================= -# ACTIVATE MAINTENANCE MODE -#================================================= -ynh_script_progression --message="Activate maintenance mode" - -path_url=$old_path -domain=$old_domain -ynh_maintenance_mode_ON - #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED #================================================= @@ -71,48 +89,35 @@ then change_path=1 fi -#================================================= -# MANAGE FAILURE OF THE SCRIPT -#================================================= - -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - #================================================= # STANDARD MODIFICATIONS #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Modify url in nginx configuration" --weight=2 +ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2 nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf -# Change the path in the nginx config file +# 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 "$nginx_conf_path" - - # Set global variables for nginx helper + # 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" - - # Store path_url setting - ynh_app_setting_set $app path_url "$path_url" - - # Create a dedicated nginx config + # Create a dedicated NGINX config ynh_add_nginx_config fi -# Change the domain for nginx +# Change the domain for NGINX if [ $change_domain -eq 1 ] then # Delete file checksum for the old conf file location - ynh_delete_file_checksum "$nginx_conf_path" + 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 "/etc/nginx/conf.d/$new_domain.d/$app.conf" + ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi #================================================= @@ -141,6 +146,8 @@ then ynh_app_setting_set $app skipped_regex "$domain_regex$new_path" fi +#================================================= +# GENERIC FINALISATION #================================================= # RESTART UWSGI #================================================= @@ -148,14 +155,12 @@ ynh_script_progression --message="Restart Radicale" --weight=2 ynh_systemd_action --action=restart --service_name=uwsgi -#================================================= -# GENERIC FINALISATION #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reload nginx" +ynh_script_progression --message="Reloading NGINX web server..." -ynh_systemd_action --action=reload --service_name=nginx +ynh_systemd_action --service_name=nginx --action=reload #================================================= # DEACTIVE MAINTENANCE MODE @@ -170,4 +175,4 @@ ynh_maintenance_mode_OFF # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed" --last +ynh_script_progression --message="Change of URL completed for $app" --last diff --git a/scripts/install b/scripts/install index d980224..ff71fe8 100755 --- a/scripts/install +++ b/scripts/install @@ -1,7 +1,7 @@ #!/bin/bash #================================================= -# GENERIC STARTING +# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -10,10 +10,12 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# MANAGE FAILURE OF THE SCRIPT +# MANAGE SCRIPT FAILURE #================================================= -# Exit if an error occurs during the execution of the script +ynh_clean_setup () { + ynh_clean_check_starting +}# Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= @@ -23,9 +25,9 @@ ynh_script_progression --message="Retrieve arguments from the manifest" domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH -admin=$YNH_APP_ARG_ADMIN infcloud=$YNH_APP_ARG_INFCLOUD language=$YNH_APP_ARG_LANGUAGE +admin=$YNH_APP_ARG_ADMIN app=$YNH_APP_INSTANCE_NAME @@ -33,47 +35,56 @@ app=$YNH_APP_INSTANCE_NAME version=$(ynh_app_upstream_version) #================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS +# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression --message="Check if the app can be installed" +ynh_script_progression --message="Validating installation parameters..." 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 $domain $path_url +ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= ynh_script_progression --message="Store settings from manifest" --weight=4 -ynh_app_setting_set $app domain $domain -ynh_app_setting_set $app path $path_url -ynh_app_setting_set $app admin $admin -ynh_app_setting_set $app infcloud $infcloud -ynh_app_setting_set $app version $version +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=language --value=$language +ynh_app_setting_set --app=$app --key=admin --value=$admin +ynh_app_setting_set --app=$app --key=infcloud --value=$infcloud +ynh_app_setting_set --app=$app --key=version --value=$version -ynh_app_setting_set $app overwrite_logging "1" -ynh_app_setting_set $app overwrite_config "1" -ynh_app_setting_set $app overwrite_infcloud "1" -ynh_app_setting_set $app overwrite_nginx "1" -ynh_app_setting_set $app overwrite_phpfpm "1" -ynh_app_setting_set $app admin_mail_html "1" +ynh_app_setting_set --app=$app --key=overwrite_logging --value="1" +ynh_app_setting_set --app=$app --key=overwrite_config --value="1" +ynh_app_setting_set --app=$app --key=overwrite_infcloud --value="1" +ynh_app_setting_set --app=$app --key=overwrite_nginx --value="1" +ynh_app_setting_set --app=$app --key=overwrite_phpfpm --value="1" +ynh_app_setting_set --app=$app --key=admin_mail_html --value="1" #================================================= # STANDARD MODIFICATIONS #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Install dependencies" --weight=25 +ynh_script_progression --message="Installing dependencies..." --weight=25 ynh_install_app_dependencies $pkg_dependencies +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." --weight=2 + +# Create a system user +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configure NGINX" --weight=2 +ynh_script_progression --message="Configuring NGINX web server..." --weight=2 ynh_add_nginx_config if [ $infcloud -eq 1 ] @@ -84,13 +95,19 @@ fi ynh_store_file_checksum "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= -# CREATE DEDICATED USER +# PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Create a dedicated user" --weight=2 -# Create a dedicated system user -ynh_system_user_create $app +if [ $infcloud -eq 1 ] +then + ynh_script_progression --message="Configure PHP-FPM" --weight=4 + # Create a dedicated php-fpm config + ynh_add_fpm_config + phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +fi +#================================================= +# SPECIFIC SETUP #================================================= # SPECIFIC SETUP #================================================= @@ -235,14 +252,6 @@ do # List all users and remove the space after username done <<< "$(yunohost user list | grep username | cut -d ":" -f 2 | cut -c 2-)" -#================================================= -# ADVERTISE SERVICE IN ADMIN PANEL -#================================================= -ynh_script_progression --message="Restart Radicale" --weight=2 - -ynh_systemd_action --action=restart --service_name=uwsgi -yunohost service add uwsgi --log="/var/log/uwsgi/app/radicale.log" - #================================================= # PREPARE THE HOOKS #================================================= @@ -252,11 +261,34 @@ ynh_replace_string "__FINALPATH__" "$final_path" ../hooks/post_user_create ynh_replace_string "__FINALPATH__" "$final_path" ../hooks/post_user_delete #================================================= -# GENERIC FINALISATION +# GENERIC FINALIZATION +#================================================= +# SETUP LOGROTATE +#================================================= +ynh_script_progression --message="Configuring log rotation..." --weight=2 + +# Use logrotate to manage application logfile(s) +ynh_use_logrotate + +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." --weight=2 + +yunohost service add uwsgi --log="/var/log/uwsgi/app/radicale.log" + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." + +# Start a systemd service +ynh_systemd_action --action=restart --service_name=uwsgi + #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Setup SSOwat" --weight=3 +ynh_script_progression --message="Configuring permissions..." --weight=3 if [ $infcloud -eq 1 ] then @@ -274,32 +306,12 @@ else ynh_app_setting_set $app unprotected_uris "/" fi -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Configure logrotate" --weight=2 - -# Use logrotate to manage application logfile(s) -ynh_use_logrotate - -#================================================= -# PHP-FPM CONFIGURATION -#================================================= - -if [ $infcloud -eq 1 ] -then - ynh_script_progression --message="Configure PHP-FPM" --weight=4 - # Create a dedicated php-fpm config - ynh_add_fpm_config - phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) -fi - #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reload NGINX" --weight=4 +ynh_script_progression --message="Reloading NGINX web server..." --weight=4 -ynh_systemd_action --action=reload --service_name=nginx +ynh_systemd_action --service_name=nginx --action=reload #================================================= # SEND A README FOR THE ADMIN diff --git a/scripts/remove b/scripts/remove index 40f77f2..0a54bd0 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,7 +1,7 @@ #!/bin/bash #================================================= -# GENERIC STARTING +# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -12,18 +12,19 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Load settings" +ynh_script_progression --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) #================================================= # STANDARD REMOVE #================================================= # STOP AND REMOVE SERVICE #================================================= -ynh_script_progression --message="Stop and remove the service" --weight=3 +ynh_script_progression --message="Stopping and removing the systemd service..." --weight=3 # Delete uwsgi configuration ynh_systemd_action --action=stop --service_name=uwsgi @@ -34,25 +35,25 @@ fi ynh_secure_remove "/etc/uwsgi/apps-available/radicale.ini" #================================================= -# REMOVE DEPENDENCIES +# REMOVE LOGROTATE CONFIGURATION #================================================= -ynh_script_progression --message="Remove dependencies" --weight=10 +ynh_script_progression --message="Removing logrotate configuration..." --weight=3 -# Remove metapackage and its dependencies -ynh_remove_app_dependencies +# Remove the app-specific logrotate config +ynh_remove_logrotate #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Remove app main directory" +ynh_script_progression --message="Removing app main directory..." -ynh_secure_remove "/var/www/$app" -ynh_secure_remove "/opt/yunohost/$app" +# Remove the app directory securely +ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Remove NGINX configuration" +ynh_script_progression --message="Removing NGINX web server configuration..." # Remove the dedicated NGINX config ynh_remove_nginx_config @@ -60,26 +61,28 @@ ynh_remove_nginx_config #================================================= # REMOVE PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Remove PHP-FPM configuration" --weight=3 +ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=3 -# Remove the dedicated php-fpm config +# Remove the dedicated PHP-FPM config ynh_remove_fpm_config #================================================= -# REMOVE LOGROTATE CONFIG +# REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Remove logrotate configuration" --weight=3 +ynh_script_progression --message="Removing dependencies..." --weight=10 -# Remove the app-specific logrotate config -ynh_remove_logrotate +# Remove metapackage and its dependencies +ynh_remove_app_dependencies #================================================= # SPECIFIC REMOVE #================================================= -# REMOVE RADICALE CONFIG +# REMOVE VARIOUS FILES #================================================= +ynh_script_progression --message="Removing various files..." ynh_secure_remove "/etc/$app" +ynh_secure_remove "/opt/yunohost/$app" #================================================= # REMOVE SERVICE FROM ADMIN PANEL @@ -99,16 +102,17 @@ else fi #================================================= -# GENERIC FINALISATION +# GENERIC FINALIZATION #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Remove the dedicated user" +ynh_script_progression --message="Removing the dedicated system user..." -ynh_system_user_delete $app +# Delete a system user +ynh_system_user_delete --username=$app #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Deletion completed" --last +ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore index 6d981e5..4609d56 100644 --- a/scripts/restore +++ b/scripts/restore @@ -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 @@ -13,26 +14,30 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + ynh_clean_check_starting +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Load settings" --weight=2 +ynh_script_progression --message="Loading installation settings..." --weight=2 app=$YNH_APP_INSTANCE_NAME -final_path=$(ynh_app_setting_get $app final_path) -domain=$(ynh_app_setting_get $app domain) -infcloud=$(ynh_app_setting_get $app infcloud) -path_url=$(ynh_app_setting_get $app path) -admin=$(ynh_app_setting_get $app admin) +domain=$(ynh_app_setting_get --app=$app --key=domain) +infcloud=$(ynh_app_setting_get --app=$app --key=infcloud) +path_url=$(ynh_app_setting_get --app=$app --key=path) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +admin=$(ynh_app_setting_get --app=$app --key=admin) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= +ynh_script_progression --message="Validating restoration parameters..." test ! -d $final_path \ || ynh_die "There is already a directory: $final_path " @@ -47,19 +52,21 @@ ynh_script_progression --message="Activate maintenance mode" --weight=2 ynh_maintenance_mode_ON #================================================= -# STANDARD RESTORE STEPS +# STANDARD RESTORATION STEPS #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Restoring the NGINX web server configuration..." -ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= -# REINSTALL DEPENDENCIES +# RECREATE THE DEDICATED USER #================================================= -ynh_script_progression --message="Reinstall dependencies" --weight=25 +ynh_script_progression --message="Recreating the dedicated system user..." --weight=3 -ynh_install_app_dependencies $pkg_dependencies +# Create the dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # RESTORE THE APP MAIN DIR @@ -70,27 +77,26 @@ ynh_restore_file "$final_path" mkdir -p /opt/yunohost ynh_restore_file "/opt/yunohost/$app" -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreate the dedicated user" --weight=3 - -# Create the dedicated user (if not existing) -ynh_system_user_create $app - #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= if [ $infcloud -eq 1 ] then - ynh_script_progression --message="Reload PHP-FPM" --weight=2 - ynh_restore_file "/etc/php/$phpversion/fpm/pool.d/$app.conf" - ynh_systemd_action --action=reload --service_name=php$phpversion-fpm + ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weight=2 + ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" fi #================================================= -# SPECIFIC RESTORE +# SPECIFIC RESTORATION +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Reinstalling dependencies..." --weight=25 + +# Define and install dependencies +ynh_install_app_dependencies $pkg_dependencies + #================================================= # RESTORE USER RIGHTS #================================================= @@ -102,6 +108,13 @@ mkdir -p /var/log/$app touch /var/log/$app/$app.log chown radicale -R /var/log/$app +#================================================= +# RESTORE VARIOUS FILES +#================================================= +ynh_script_progression --message="Restoring various files..." + +ynh_restore_file --origin_path="/etc/$app" + #================================================= # RESTORE THE UWSGI CONFIG #================================================= @@ -109,30 +122,36 @@ chown radicale -R /var/log/$app ynh_restore_file "/etc/uwsgi/apps-available/radicale.ini" ln -s /etc/uwsgi/apps-available/radicale.ini /etc/uwsgi/apps-enabled/ -# Advertise service in admin panel +#================================================= +# RESTORE THE LOGROTATE CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the logrotate configuration..." + +ynh_restore_file --origin_path="/etc/logrotate.d/$app" + +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." + yunohost service add uwsgi --log="/var/log/uwsgi/app/radicale.log" #================================================= -# RESTORE THE RADICALE CONFIGURATION +# START SYSTEMD SERVICE #================================================= - -ynh_restore_file "/etc/$app" - -#================================================= -# BACKUP OF THE LOGROTATE CONFIGURATION -#================================================= - -ynh_restore_file "/etc/logrotate.d/$app" - -#================================================= -# GENERIC FINALISATION -#================================================= -# RELOAD NGINX AND UWSGI -#================================================= -ynh_script_progression --message="Reload nginx and restart Radicale" +ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --action=restart --service_name=uwsgi -ynh_systemd_action --action=reload --service_name=nginx + +#================================================= +# GENERIC FINALIZATION +#================================================= +# RELOAD NGINX AND PHP-FPM +#================================================= +ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." + +ynh_systemd_action --service_name=php$phpversion-fpm --action=reload +ynh_systemd_action --service_name=nginx --action=reload #================================================= # DEACTIVE MAINTENANCE MODE @@ -172,4 +191,4 @@ ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="$admin" --ty # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed" --last +ynh_script_progression --message="Restoration completed for $app" --last diff --git a/scripts/upgrade b/scripts/upgrade index 769b081..1703d1c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -18,9 +18,9 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) +language=$(ynh_app_setting_get --app=$app --key=language) admin=$(ynh_app_setting_get --app=$app --key=admin) infcloud=$(ynh_app_setting_get --app=$app --key=infcloud) -language=$(ynh_app_setting_get --app=$app --key=language) final_path=$(ynh_app_setting_get --app=$app --key=final_path) version=$(ynh_app_setting_get --app=$app --key=version) overwrite_logging=$(ynh_app_setting_get --app=$app --key=overwrite_logging) @@ -40,27 +40,38 @@ defaulteventduration=$(ynh_app_setting_get --app=$app --key=defaulteventduration #================================================= # 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="Backup the app before upgrading" +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { - # restore it if the upgrade fails + 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 +#================================================= +# ACTIVATE MAINTENANCE MODE +#================================================= +ynh_script_progression --message="Activate maintenance mode" --weight=1 + +ynh_maintenance_mode_ON + +#================================================= +# STANDARD UPGRADE STEPS #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensure downward compatibility" +ynh_script_progression --message="Ensuring downward compatibility..." ynh_app_setting_delete $app unprotected_regex @@ -116,40 +127,41 @@ if [ -z "$overwrite_phpfpm" ]; then ynh_app_setting_set $app overwrite_phpfpm $overwrite_phpfpm fi -#================================================= -# Migrate legacy permissions to new system -#================================================= -if ynh_legacy_permissions_exists -then - ynh_legacy_permissions_delete_all - - ynh_app_setting_delete --app=$app --key=is_public -fi - -#================================================= -# CHECK THE PATH -#================================================= - if [ $infcloud -eq 1 ]; then # Remove /infcloud to deal with the path only. path_url=$(echo $path_url | sed "s@/infcloud@@") fi -#================================================= -# ACTIVATE MAINTENANCE MODE -#================================================= -ynh_script_progression --message="Activate maintenance mode" --weight=1 +# Cleaning legacy permissions +if ynh_legacy_permissions_exists; then + ynh_legacy_permissions_delete_all -ynh_maintenance_mode_ON + ynh_app_setting_delete --app=$app --key=is_public +fi + +if [ $infcloud -eq 1 ] +then + # Add /infcloud to the path of radicale to access it from the portal + # Replace radicale by InfCloud into YunoHost portal + ynh_app_setting_set $app path ${path_url%/}/infcloud + # Protect InfCloud access + ynh_app_setting_set $app protected_uris "/" + domain_regex=$(echo "$domain" | sed 's@-@.@g') + # Radicale is always accessible (For access to ressources) + ynh_app_setting_set $app skipped_regex "$domain_regex$path_url" +else + # If only radicale is installed + # Radicale is always accessible (For access to ressources) + ynh_app_setting_set $app unprotected_uris "/" +fi #================================================= -# STANDARD UPGRADE STEPS +# CREATE DEDICATED USER #================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrade dependencies" --weight=5 +ynh_script_progression --message="Making sure dedicated system user exists..." -ynh_install_app_dependencies $pkg_dependencies +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # NGINX CONFIGURATION @@ -158,7 +170,7 @@ ynh_install_app_dependencies $pkg_dependencies # Overwrite the NGINX configuration only if it's allowed if [ $overwrite_nginx -eq 1 ] then - ynh_script_progression --message="Reconfigure nginx" --weight=2 + ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2 ynh_add_nginx_config if [ $infcloud -eq 1 ] then @@ -169,24 +181,23 @@ then fi #================================================= -# CREATE DEDICATED USER +# UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Create a dedicated user" --weight=2 +ynh_script_progression --message="Upgrading dependencies..." --weight=5 -# Create a dedicated user (if not existing) -ynh_system_user_create $app +ynh_install_app_dependencies $pkg_dependencies + +#================================================= +# PHP-FPM CONFIGURATION +#================================================= if [ $infcloud -eq 1 ] then - #================================================= - # PHP-FPM CONFIGURATION - #================================================= - # Overwrite the php-fpm configuration only if it's allowed if [ $overwrite_phpfpm -eq 1 ] then - ynh_script_progression --message="Reconfigure PHP-FPM" --weight=2 - # Create a dedicated php-fpm config + ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2 + # Create a dedicated PHP-FPM config ynh_add_fpm_config fi fi @@ -367,14 +378,6 @@ chmod 777 $final_path/default_collections $final_path/default_collections/USER cp ../conf/radicale.ini /etc/uwsgi/apps-available/ -#================================================= -# ADVERTISE SERVICE IN ADMIN PANEL -#================================================= -ynh_script_progression --message="Restart Radicale" --weight=2 - -ynh_systemd_action --action=restart --service_name=uwsgi -yunohost service add uwsgi --log="/var/log/uwsgi/app/radicale.log" - #================================================= # PREPARE THE HOOKS #================================================= @@ -383,42 +386,36 @@ yunohost service add uwsgi --log="/var/log/uwsgi/app/radicale.log" ynh_replace_string "__FINALPATH__" "$final_path" ../hooks/post_user_create ynh_replace_string "__FINALPATH__" "$final_path" ../hooks/post_user_delete +#================================================= +# GENERIC FINALIZATION #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Reconfigure logrotate" --weight=3 +ynh_script_progression --message="Upgrading logrotate configuration..." --weight=3 +# Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append #================================================= -# GENERIC FINALISATION +# INTEGRATE SERVICE IN YUNOHOST #================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Reconfigure SSOwat" --weight=2 +ynh_script_progression --message="Integrating service in YunoHost..." --weight=2 -if [ $infcloud -eq 1 ] -then - # Add /infcloud to the path of radicale to access it from the portal - # Replace radicale by InfCloud into YunoHost portal - ynh_app_setting_set $app path ${path_url%/}/infcloud - # Protect InfCloud access - ynh_app_setting_set $app protected_uris "/" - domain_regex=$(echo "$domain" | sed 's@-@.@g') - # Radicale is always accessible (For access to ressources) - ynh_app_setting_set $app skipped_regex "$domain_regex$path_url" -else - # If only radicale is installed - # Radicale is always accessible (For access to ressources) - ynh_app_setting_set $app unprotected_uris "/" -fi +yunohost service add uwsgi --log="/var/log/uwsgi/app/radicale.log" + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." + +ynh_systemd_action --action=restart --service_name=uwsgi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reload NGINX" +ynh_script_progression --message="Reloading NGINX web server..." -ynh_systemd_action --action=reload --service_name=nginx +ynh_systemd_action --service_name=nginx --action=reload #================================================= # DEACTIVE MAINTENANCE MODE @@ -466,4 +463,4 @@ ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="$admin" --ty # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade completed" --last +ynh_script_progression --message="Upgrade of $app completed" --last