diff --git a/.gitignore b/.gitignore index 783a4ae..8f144f3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *~ *.sw[op] +.DS_Store diff --git a/conf/nginx.conf b/conf/nginx.conf index 1e6eee0..1f14638 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -7,13 +7,13 @@ location __PATH__/ { ### Example PHP configuration (remove it if not used) index index.php; - # Common parameter to increase upload size limit in conjunction with dedicated php-fpm file + # Common parameter to increase upload size limit in conjunction with dedicated PHP-FPM file # client_max_body_size 50M; try_files $uri $uri/ index.php; location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; + fastcgi_pass unix:/var/run/php/php__PHP_VERSION__-fpm-__APP__.sock; fastcgi_index index.php; include fastcgi_params; diff --git a/manifest.toml b/manifest.toml index e8754ce..ac4bde3 100644 --- a/manifest.toml +++ b/manifest.toml @@ -32,7 +32,8 @@ cpe = "???" fund = "???" [integration] -yunohost = ">= 11.2" +yunohost = ">= 11.2.30" +helpers_version = "2.1" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"] architectures = "all" multi_instance = true diff --git a/scripts/_common.sh b/scripts/_common.sh index 944a65e..3d7f008 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,17 +1,5 @@ #!/bin/bash #================================================= -# COMMON VARIABLES -#================================================= - -#================================================= -# PERSONAL HELPERS -#================================================= - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - -#================================================= -# FUTURE OFFICIAL HELPERS +# COMMON VARIABLES AND CUSTOM HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index 87926d7..c288a49 100755 --- a/scripts/backup +++ b/scripts/backup @@ -8,10 +8,7 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# DECLARE DATA AND CONF FILES TO BACKUP -#================================================= -ynh_print_info --message="Declaring files to be backed up..." +ynh_print_info "Declaring files to be backed up..." ### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs ### to be backuped and not an actual copy of any file. The actual backup that @@ -22,59 +19,62 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$install_dir" +ynh_backup "$install_dir" #================================================= # BACKUP THE DATA DIR #================================================= -### Only relevant if there is a "data_dir" resource for this app -ynh_backup --src_path="$data_dir" --is_big +# Only relevant if there is a "data_dir" resource for this app +# NB: $data_dir is not backuped during safety-backup-before-upgrades, +# because the data dir may be huge and we don't want to just yolo-create a 10+ GB archive just for upgrades. +# On the other hand, $data_dir is also *not* removed by default in the "app remove" step unless --purge is used +# This means that even if the upgrade fails and the backup is restored, the data are still there. +ynh_backup "$data_dir" #================================================= # SYSTEM CONFIGURATION #================================================= # Backup the PHP-FPM configuration -ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" +ynh_backup "/etc/php/$php_version/fpm/pool.d/$app.conf" -# Backup the nginx configuration -ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +# Backup the NGINX configuration +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" # Backup the systemd service unit -ynh_backup --src_path="/etc/systemd/system/$app.service" +ynh_backup "/etc/systemd/system/$app.service" # Backup the logrotate configuration -ynh_backup --src_path="/etc/logrotate.d/$app" +ynh_backup "/etc/logrotate.d/$app" # Backup the Fail2Ban config -ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf" -ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" +ynh_backup "/etc/fail2ban/jail.d/$app.conf" +ynh_backup "/etc/fail2ban/filter.d/$app.conf" #================================================= # BACKUP VARIOUS FILES #================================================= -ynh_backup --src_path="/etc/cron.d/$app" +ynh_backup "/etc/cron.d/$app" -ynh_backup --src_path="/etc/$app/" +ynh_backup "/etc/$app/" -### For apps with huge logs, you might want to pass --is_big, -### and in restore script, mkdir and pass --not_mandatory to ynh_restore_file. -ynh_backup --src_path="/var/log/$app/" +# NB: /var/log is not backuped during safety-backup-before-upgrades, same as $data_dir +ynh_backup "/var/log/$app/" #================================================= # BACKUP THE MYSQL DATABASE #================================================= -ynh_print_info --message="Backing up the MySQL database..." +ynh_print_info "Backing up the MySQL database..." ### (However, things like MySQL dumps *do* take some time to run, though the ### copy of the generated dump to the archive still happens later) -ynh_mysql_dump_db --database="$db_name" > db.sql +ynh_mysql_dump_db > db.sql #================================================= # END OF SCRIPT #================================================= -ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." +ynh_print_info "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 f009a85..25e55b5 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -14,17 +14,17 @@ source /usr/share/yunohost/helpers #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping $app's systemd service..." --weight=1 +ynh_script_progression "Stopping $app's systemd service..." -ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemctl --service="$app" --action="stop" #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 +ynh_script_progression "Updating NGINX web server configuration..." # this will most likely adjust NGINX config correctly -ynh_change_url_nginx_config +ynh_config_change_url_nginx #================================================= # SPECIFIC MODIFICATIONS @@ -35,12 +35,12 @@ ynh_change_url_nginx_config #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting $app's systemd service..." --weight=1 +ynh_script_progression "Starting $app's systemd service..." -ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemctl --service="$app" --action="start" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --last +ynh_script_progression "Change of URL completed for $app" diff --git a/scripts/config b/scripts/config index 48be2ff..9c4c1c1 100644 --- a/scripts/config +++ b/scripts/config @@ -20,7 +20,7 @@ ynh_abort_if_errors # RETRIEVE ARGUMENTS #================================================= -install_dir=$(ynh_app_setting_get --app="$app" --key=install_dir) +install_dir=$(ynh_app_setting_get --key=install_dir) #================================================= # SPECIFIC GETTERS FOR TOML SHORT KEY @@ -59,7 +59,6 @@ get__prices() { fi } - #================================================= # SPECIFIC VALIDATORS FOR TOML SHORT KEYS #================================================= @@ -90,10 +89,8 @@ set__prices() { #--------------------------------------------- # IMPORTANT: to be able to upgrade properly, you have to save the value in settings too #--------------------------------------------- - ynh_app_setting_set --app="$app" --key=prices --value="$prices" + ynh_app_setting_set --key=prices --value="$prices" } -#================================================= -# GENERIC FINALIZATION #================================================= ynh_app_config_run "$1" diff --git a/scripts/install b/scripts/install index 5e20de5..ebb82ea 100755 --- a/scripts/install +++ b/scripts/install @@ -24,7 +24,7 @@ source /usr/share/yunohost/helpers ### ... ### ### $app is the app id (i.e. 'example' for first install, -### or 'example__2', '__3', ... for multi-instance installs) +### or 'example__2', '__3'... for multi-instance installs) #================================================= # INITIALIZE AND STORE SETTINGS @@ -33,12 +33,12 @@ source /usr/share/yunohost/helpers # If you need to, you can define custom settings # (or remove this section entirely if not relevant for you) foo="bar" -ynh_app_setting_set --app=$app --key=foo --value=$foo +ynh_app_setting_set --key=foo --value=$foo #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --weight=1 +ynh_script_progression "Setting up source files..." ### `ynh_setup_source` is used to install an app from a zip or tar.gz file, ### downloaded from an upstream source, like a git repository. @@ -48,14 +48,14 @@ ynh_script_progression --message="Setting up source files..." --weight=1 ynh_setup_source --dest_dir="$install_dir" ### $install_dir will automatically be initialized with some decent -### permission by default ... however, you may need to recursively reapply +### permission by default... however, you may need to recursively reapply ### ownership to all files such as after the ynh_setup_source step chown -R "$app:www-data" "$install_dir" #================================================= # APP INITIAL CONFIGURATION #================================================= -ynh_script_progression --message="Adding $app's configuration files..." --weight=1 +ynh_script_progression "Adding $app's configuration files..." ### You can add specific configuration files. ### @@ -63,13 +63,13 @@ ynh_script_progression --message="Adding $app's configuration files..." --weight ### The template may contain strings such as __FOO__ or __FOO_BAR__, ### which will automatically be replaced by the values of $foo and $foo_bar ### -### ynh_add_config will also keep track of the config file's checksum, +### ynh_config_add will also keep track of the config file's checksum, ### which later during upgrade may allow to automatically backup the config file ### if it's found that the file was manually modified ### -### Check the documentation of `ynh_add_config` for more info. +### Check the documentation of `ynh_config_add` for more info. -ynh_add_config --template="some_config_file" --destination="$install_dir/some_config_file" +ynh_config_add --template="some_config_file" --destination="$install_dir/some_config_file" # FIXME: this should be handled by the core in the future ### You may need to use chmod 600 instead of 400, @@ -78,20 +78,20 @@ chmod 400 "$install_dir/some_config_file" chown "$app:$app" "$install_dir/some_config_file" ### For more complex cases where you want to replace stuff using regexes, -### you shoud rely on ynh_replace_string (which is basically a wrapper for sed) +### you shoud rely on ynh_replace (which is basically a wrapper for sed) ### When doing so, you also need to manually call ynh_store_file_checksum ### -### ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$install_dir/some_config_file" -### ynh_store_file_checksum --file="$install_dir/some_config_file" +### ynh_replace --match="match_string" --replace="replace_string" --file="$install_dir/some_config_file" +### ynh_store_file_checksum "$install_dir/some_config_file" #================================================= # SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 +ynh_script_progression "Adding system configurations related to $app..." -### `ynh_add_fpm_config` is used to set up a PHP config. +### `ynh_config_add_phpfpm` is used to set up a PHP config. ### You can remove it if your app doesn't use PHP. -### `ynh_add_fpm_config` will use the files conf/extra_php-fpm.conf +### `ynh_config_add_phpfpm` will use the files conf/extra_php-fpm.conf ### If you're not using these lines: ### - You can remove these files in conf/. ### - Remove the section "BACKUP THE PHP-FPM CONFIGURATION" in the backup script @@ -101,15 +101,15 @@ ynh_script_progression --message="Adding system configurations related to $app.. ### - And the section "PHP-FPM CONFIGURATION" in the upgrade script # Create a PHP-FPM config (with conf/extra_php-fpm.conf being appended to it) -ynh_add_fpm_config +ynh_config_add_phpfpm # Create a dedicated NGINX config using the conf/nginx.conf template -ynh_add_nginx_config +ynh_config_add_nginx -### `ynh_systemd_config` is used to configure a systemd script for an app. +### `ynh_config_add_systemd` is used to configure a systemd script for an app. ### It can be used for apps that use sysvinit (with adaptation) or systemd. ### Have a look at the app to be sure this app needs a systemd script. -### `ynh_systemd_config` will use the file conf/systemd.service +### `ynh_config_add_systemd` will use the file conf/systemd.service ### If you're not using these lines: ### - You can remove those files in conf/. ### - Remove the section "BACKUP SYSTEMD" in the backup script @@ -118,7 +118,7 @@ ynh_add_nginx_config ### - And the section "SETUP SYSTEMD" in the upgrade script # Create a dedicated systemd config -ynh_add_systemd_config +ynh_config_add_systemd ### `yunohost service add` integrates a service in YunoHost. It then gets ### displayed in the admin interface and through the others `yunohost service` commands. @@ -146,7 +146,7 @@ ynh_add_systemd_config ### service though so you should re-provide all relevant flags when doing so) yunohost service add "$app" --description="A short description of the app" --log="/var/log/$app/$app.log" -### `ynh_use_logrotate` is used to configure a logrotate configuration for the logs of this app. +### `ynh_config_add_logrotate` is used to configure a logrotate configuration for the logs of this app. ### Use this helper only if there is effectively a log file for this app. ### If you're not using this helper: ### - Remove the section "BACKUP LOGROTATE" in the backup script @@ -155,10 +155,10 @@ yunohost service add "$app" --description="A short description of the app" --log ### - And the section "SETUP LOGROTATE" in the upgrade script # Use logrotate to manage application logfile(s) -ynh_use_logrotate +ynh_config_add_logrotate # Create a dedicated Fail2Ban config -ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login" +ynh_config_add_fail2ban --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login" #================================================= # SETUP APPLICATION WITH CURL @@ -170,15 +170,15 @@ ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failreg ### forms. # Installation with curl -ynh_script_progression --message="Finalizing installation..." --weight=1 +ynh_script_progression "Finalizing installation..." ynh_local_curl "/INSTALL_PATH" "key1=value1" "key2=value2" "key3=value3" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting $app's systemd service..." --weight=1 +ynh_script_progression "Starting $app's systemd service..." -### `ynh_systemd_action` is used to start a systemd service for an app. +### `ynh_systemctl` is used to start a systemd service for an app. ### Only needed if you have configure a systemd service ### If you're not using these lines: ### - Remove the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the backup script @@ -187,9 +187,10 @@ ynh_script_progression --message="Starting $app's systemd service..." --weight=1 ### - And the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the change_url script # Start a systemd service -ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemctl --service="$app" --action="start" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --last + +ynh_script_progression "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index c636704..85ffd78 100755 --- a/scripts/remove +++ b/scripts/remove @@ -16,39 +16,39 @@ source /usr/share/yunohost/helpers ### - $port ### ... -### For remove operations : +### For remove operations: ### - the core will deprovision every resource defined in the manifest **after** this script is ran ### this includes removing the install directory, and data directory (if --purge was used) #================================================= # REMOVE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 +ynh_script_progression "Removing system configurations related to $app..." ### This should be a symetric version of what happens in the install script -ynh_remove_fail2ban_config +ynh_config_remove_fail2ban -ynh_remove_logrotate +ynh_config_remove_logrotate # 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 +if ynh_hide_warnings yunohost service status "$app" >/dev/null; then yunohost service remove "$app" fi -ynh_remove_systemd_config +ynh_config_remove_systemd -ynh_remove_nginx_config +ynh_config_remove_nginx -ynh_remove_fpm_config +ynh_config_remove_phpfpm -# Remove other various files specific to the app... such as : +# Remove other various files specific to the app... such as: -ynh_secure_remove --file="/etc/cron.d/$app" +ynh_safe_rm "/etc/cron.d/$app" -ynh_secure_remove --file="/etc/$app" +ynh_safe_rm "/etc/$app" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --last +ynh_script_progression "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index c4c090a..e2f541a 100755 --- a/scripts/restore +++ b/scripts/restore @@ -11,21 +11,21 @@ source /usr/share/yunohost/helpers #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=1 +ynh_script_progression "Restoring the app main directory..." -ynh_restore_file --origin_path="$install_dir" +ynh_restore "$install_dir" ### $install_dir will automatically be initialized with some decent -### permissions by default ... however, you may need to recursively reapply +### permissions by default... however, you may need to recursively reapply ### ownership to all files such as after the ynh_setup_source step chown -R "$app:www-data" "$install_dir" #================================================= # RESTORE THE DATA DIRECTORY #================================================= -ynh_script_progression --message="Restoring the data directory..." --weight=1 +ynh_script_progression "Restoring the data directory..." -ynh_restore_file --origin_path="$data_dir" --not_mandatory +ynh_restore "$data_dir" ### (Same as for install dir) chown -R "$app:www-data" "$data_dir" @@ -33,61 +33,62 @@ chown -R "$app:www-data" "$data_dir" #================================================= # RESTORE THE MYSQL DATABASE #================================================= -ynh_script_progression --message="Restoring the MySQL database..." --weight=1 +ynh_script_progression "Restoring the MySQL database..." -ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql +ynh_mysql_db_shell < ./db.sql #================================================= # RESTORE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 +ynh_script_progression "Restoring system configurations related to $app..." ### This should be a symetric version of what happens in the install script -ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" +ynh_restore "/etc/php/$php_version/fpm/pool.d/$app.conf" -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf" -ynh_restore_file --origin_path="/etc/systemd/system/$app.service" +ynh_restore "/etc/systemd/system/$app.service" systemctl enable "$app.service" --quiet yunohost service add "$app" --description="A short description of the app" --log="/var/log/$app/$app.log" -ynh_restore_file --origin_path="/etc/logrotate.d/$app" +ynh_restore "/etc/logrotate.d/$app" -ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf" -ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf" -ynh_systemd_action --action=restart --service_name=fail2ban +ynh_restore "/etc/fail2ban/jail.d/$app.conf" +ynh_restore "/etc/fail2ban/filter.d/$app.conf" +ynh_systemctl --action=restart --service=fail2ban #================================================= # RESTORE VARIOUS FILES #================================================= -ynh_restore_file --origin_path="/etc/cron.d/$app" -ynh_restore_file --origin_path="/etc/$app/" +ynh_restore "/etc/cron.d/$app" +ynh_restore "/etc/$app/" ### For apps with huge logs, you might want to not backup logs every time: ### The mkdir call is just here in case the log directory was not backed up. ### mkdir -p "/var/log/$app" ### chown $app:www-data "/var/log/$app" -### ynh_restore_file --src_path="/var/log/$app/" --not_mandatory +### ynh_restore "/var/log/$app/" || true ### ### For other apps, the simple way is better: -ynh_restore_file --origin_path="/var/log/$app/" +ynh_restore "/var/log/$app/" #================================================= # RELOAD NGINX AND PHP-FPM OR THE APP SERVICE #================================================= -ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 +ynh_script_progression "Reloading NGINX web server and $app's service..." -### Typically you only have either $app or php-fpm but not both at the same time... -ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name="php$phpversion-fpm" --action=reload +### Typically you only have either $app or PHP-FPM but not both at the same time... +ynh_systemctl --service="$app" --action="start" -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemctl --service="php$php_version-fpm" --action=reload + +ynh_systemctl --service=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --last +ynh_script_progression "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index fab8a9a..957e129 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,6 +1,5 @@ #!/bin/bash - #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -21,65 +20,57 @@ source /usr/share/yunohost/helpers ### - resources are automatically provisioned / updated / deleted (depending on existing resources) ### - a safety backup is automatically created by the core and will be restored if the upgrade fails -### This variable describes which upgrade type is occurring, allowing the script to handle different modes: -### - UPGRADE_PACKAGE if only the YunoHost package has changed -### - UPGRADE_APP if the upstream app version has changed -### If your package needs to handle other things, like same-version upgrades or downgrades, please -### check out the $YNH_APP_UPGRADE_TYPE variable that can contain DOWNGRADE and UPGRADE_SAME too. -# upgrade_type=$(ynh_check_app_version_changed) - #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping $app's systemd service..." --weight=1 +ynh_script_progression "Stopping $app's systemd service..." -ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemctl --service="$app" --action="stop" #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -#ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 +#ynh_script_progression "Ensuring downward compatibility..." ### N.B. : the following setting migration snippets are provided as *EXAMPLES* ### of what you may want to do in some cases (e.g. a setting was not defined on ### some legacy installs and you therefore want to initiaze stuff during upgrade) # If db_name doesn't exist, create it -# if [ -z "$db_name" ]; then -# db_name=$(ynh_sanitize_dbid --db_name=$app) -# ynh_app_setting_set --app=$app --key=db_name --value=$db_name -# fi +# ynh_app_setting_set_default --key=db_name --value="$(ynh_sanitize_dbid --db_name=$app)" # If install_dir doesn't exist, create it -# if [ -z "$install_dir" ]; then -# install_dir=/var/www/$app -# ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir -# fi +# ynh_app_setting_set_default --key=install_dir --value="/var/www/$app" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Upgrading source files..." --weight=1 +ynh_script_progression "Upgrading source files..." +### ynh_setup_source can wipe the destination dir if called with --full_replace. +### On upgrade, that is certainly what you want, to remove any old source file that +### does not exist in the new version of the software. +### You can list with --keep every file/directory to *not* wipe or overwrite, +### useful for configuration files, data directories, or plugins. # Download, check integrity, uncompress and patch the source from manifest.toml -ynh_setup_source --dest_dir="$install_dir" +ynh_setup_source --dest_dir="$install_dir" --full_replace --keep=".env data" ### $install_dir will automatically be initialized with some decent -### permissions by default ... however, you may need to recursively reapply +### permissions by default... however, you may need to recursively reapply ### ownership to all files such as after the ynh_setup_source step chown -R "$app:www-data" "$install_dir" #================================================= # UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Updating $app's configuration files..." --weight=1 +ynh_script_progression "Updating $app's configuration files..." ### Same as during install ### ### The file will automatically be backed-up if it's found to be manually modified (because -### ynh_add_config keeps track of the file's checksum) +### ynh_config_add keeps track of the file's checksum) -ynh_add_config --template="some_config_file" --destination="$install_dir/some_config_file" +ynh_config_add --template="some_config_file" --destination="$install_dir/some_config_file" # FIXME: this should be handled by the core in the future ### You may need to use chmod 600 instead of 400, @@ -88,40 +79,40 @@ chmod 400 "$install_dir/some_config_file" chown "$app:$app" "$install_dir/some_config_file" ### For more complex cases where you want to replace stuff using regexes, -### you shoud rely on ynh_replace_string (which is basically a wrapper for sed) +### you shoud rely on ynh_replace (which is basically a wrapper for sed) ### When doing so, you also need to manually call ynh_store_file_checksum ### -### ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$install_dir/some_config_file" -### ynh_store_file_checksum --file="$install_dir/some_config_file" +### ynh_replace --match="match_string" --replace="replace_string" --file="$install_dir/some_config_file" +### ynh_store_file_checksum "$install_dir/some_config_file" #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 +ynh_script_progression "Upgrading system configurations related to $app..." ### This should be a literal copypaste of what happened in the install's "System configuration" section -ynh_add_fpm_config +ynh_config_add_phpfpm -ynh_add_nginx_config +ynh_config_add_nginx -ynh_add_systemd_config +ynh_config_add_systemd yunohost service add "$app" --description="A short description of the app" --log="/var/log/$app/$app.log" -ynh_use_logrotate --non-append +ynh_config_add_logrotate -ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login" +ynh_config_add_fail2ban --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting $app's systemd service..." --weight=1 +ynh_script_progression "Starting $app's systemd service..." -ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemctl --service="$app" --action="start" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression "Upgrade of $app completed" diff --git a/sources/extra_files/app/.gitignore b/sources/extra_files/app/.gitignore deleted file mode 100644 index 783a4ae..0000000 --- a/sources/extra_files/app/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*~ -*.sw[op] diff --git a/sources/patches/.gitignore b/sources/patches/.gitignore deleted file mode 100644 index 783a4ae..0000000 --- a/sources/patches/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*~ -*.sw[op]