commit
09ce2ea730
13 changed files with 131 additions and 155 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
||||||
*~
|
*~
|
||||||
*.sw[op]
|
*.sw[op]
|
||||||
|
.DS_Store
|
||||||
|
|
|
@ -7,13 +7,13 @@ location __PATH__/ {
|
||||||
### Example PHP configuration (remove it if not used)
|
### Example PHP configuration (remove it if not used)
|
||||||
index index.php;
|
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;
|
# client_max_body_size 50M;
|
||||||
|
|
||||||
try_files $uri $uri/ index.php;
|
try_files $uri $uri/ index.php;
|
||||||
location ~ [^/]\.php(/|$) {
|
location ~ [^/]\.php(/|$) {
|
||||||
fastcgi_split_path_info ^(.+?\.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;
|
fastcgi_index index.php;
|
||||||
include fastcgi_params;
|
include fastcgi_params;
|
||||||
|
|
|
@ -32,7 +32,8 @@ cpe = "???"
|
||||||
fund = "???"
|
fund = "???"
|
||||||
|
|
||||||
[integration]
|
[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"]
|
# 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"
|
architectures = "all"
|
||||||
multi_instance = true
|
multi_instance = true
|
||||||
|
|
|
@ -1,17 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# COMMON VARIABLES
|
# COMMON VARIABLES AND CUSTOM HELPERS
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# PERSONAL HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# EXPERIMENTAL HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# FUTURE OFFICIAL HELPERS
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -8,10 +8,7 @@
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
ynh_print_info "Declaring files to be backed up..."
|
||||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
|
||||||
#=================================================
|
|
||||||
ynh_print_info --message="Declaring files to be backed up..."
|
|
||||||
|
|
||||||
### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs
|
### 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
|
### 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
|
# BACKUP THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="$install_dir"
|
ynh_backup "$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE DATA DIR
|
# BACKUP THE DATA DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
### Only relevant if there is a "data_dir" resource for this app
|
# Only relevant if there is a "data_dir" resource for this app
|
||||||
ynh_backup --src_path="$data_dir" --is_big
|
# 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
|
# SYSTEM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Backup the PHP-FPM 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
|
# Backup the NGINX configuration
|
||||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
# Backup the systemd service unit
|
# 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
|
# Backup the logrotate configuration
|
||||||
ynh_backup --src_path="/etc/logrotate.d/$app"
|
ynh_backup "/etc/logrotate.d/$app"
|
||||||
|
|
||||||
# Backup the Fail2Ban config
|
# Backup the Fail2Ban config
|
||||||
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
|
ynh_backup "/etc/fail2ban/jail.d/$app.conf"
|
||||||
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
|
ynh_backup "/etc/fail2ban/filter.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP VARIOUS FILES
|
# 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,
|
# NB: /var/log is not backuped during safety-backup-before-upgrades, same as $data_dir
|
||||||
### and in restore script, mkdir and pass --not_mandatory to ynh_restore_file.
|
ynh_backup "/var/log/$app/"
|
||||||
ynh_backup --src_path="/var/log/$app/"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE MYSQL DATABASE
|
# 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
|
### (However, things like MySQL dumps *do* take some time to run, though the
|
||||||
### copy of the generated dump to the archive still happens later)
|
### 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
|
# 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)."
|
||||||
|
|
|
@ -14,17 +14,17 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP SYSTEMD SERVICE
|
# 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
|
# 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
|
# this will most likely adjust NGINX config correctly
|
||||||
ynh_change_url_nginx_config
|
ynh_config_change_url_nginx
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC MODIFICATIONS
|
# SPECIFIC MODIFICATIONS
|
||||||
|
@ -35,12 +35,12 @@ ynh_change_url_nginx_config
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# 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
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Change of URL completed for $app" --last
|
ynh_script_progression "Change of URL completed for $app"
|
||||||
|
|
|
@ -20,7 +20,7 @@ ynh_abort_if_errors
|
||||||
# RETRIEVE ARGUMENTS
|
# 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
|
# SPECIFIC GETTERS FOR TOML SHORT KEY
|
||||||
|
@ -59,7 +59,6 @@ get__prices() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC VALIDATORS FOR TOML SHORT KEYS
|
# 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
|
# 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"
|
ynh_app_config_run "$1"
|
||||||
|
|
|
@ -24,7 +24,7 @@ source /usr/share/yunohost/helpers
|
||||||
### ...
|
### ...
|
||||||
###
|
###
|
||||||
### $app is the app id (i.e. 'example' for first install,
|
### $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
|
# INITIALIZE AND STORE SETTINGS
|
||||||
|
@ -33,12 +33,12 @@ source /usr/share/yunohost/helpers
|
||||||
# If you need to, you can define custom settings
|
# If you need to, you can define custom settings
|
||||||
# (or remove this section entirely if not relevant for you)
|
# (or remove this section entirely if not relevant for you)
|
||||||
foo="bar"
|
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
|
# 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,
|
### `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.
|
### downloaded from an upstream source, like a git repository.
|
||||||
|
@ -55,7 +55,7 @@ chown -R "$app:www-data" "$install_dir"
|
||||||
#=================================================
|
#=================================================
|
||||||
# APP INITIAL CONFIGURATION
|
# 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.
|
### 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__,
|
### The template may contain strings such as __FOO__ or __FOO_BAR__,
|
||||||
### which will automatically be replaced by the values of $foo and $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
|
### which later during upgrade may allow to automatically backup the config file
|
||||||
### if it's found that the file was manually modified
|
### 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
|
# FIXME: this should be handled by the core in the future
|
||||||
### You may need to use chmod 600 instead of 400,
|
### 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"
|
chown "$app:$app" "$install_dir/some_config_file"
|
||||||
|
|
||||||
### For more complex cases where you want to replace stuff using regexes,
|
### 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
|
### 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_replace --match="match_string" --replace="replace_string" --file="$install_dir/some_config_file"
|
||||||
### ynh_store_file_checksum --file="$install_dir/some_config_file"
|
### ynh_store_file_checksum "$install_dir/some_config_file"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SYSTEM CONFIGURATION
|
# 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.
|
### 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:
|
### If you're not using these lines:
|
||||||
### - You can remove these files in conf/.
|
### - You can remove these files in conf/.
|
||||||
### - Remove the section "BACKUP THE PHP-FPM CONFIGURATION" in the backup script
|
### - 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
|
### - 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)
|
# 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
|
# 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.
|
### 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.
|
### 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:
|
### If you're not using these lines:
|
||||||
### - You can remove those files in conf/.
|
### - You can remove those files in conf/.
|
||||||
### - Remove the section "BACKUP SYSTEMD" in the backup script
|
### - 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
|
### - And the section "SETUP SYSTEMD" in the upgrade script
|
||||||
|
|
||||||
# Create a dedicated systemd config
|
# Create a dedicated systemd config
|
||||||
ynh_add_systemd_config
|
ynh_config_add_systemd
|
||||||
|
|
||||||
### `yunohost service add` integrates a service in YunoHost. It then gets
|
### `yunohost service add` integrates a service in YunoHost. It then gets
|
||||||
### displayed in the admin interface and through the others `yunohost service` commands.
|
### 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)
|
### 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"
|
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.
|
### Use this helper only if there is effectively a log file for this app.
|
||||||
### If you're not using this helper:
|
### If you're not using this helper:
|
||||||
### - Remove the section "BACKUP LOGROTATE" in the backup script
|
### - 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
|
### - And the section "SETUP LOGROTATE" in the upgrade script
|
||||||
|
|
||||||
# Use logrotate to manage application logfile(s)
|
# Use logrotate to manage application logfile(s)
|
||||||
ynh_use_logrotate
|
ynh_config_add_logrotate
|
||||||
|
|
||||||
# Create a dedicated Fail2Ban config
|
# 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
|
# SETUP APPLICATION WITH CURL
|
||||||
|
@ -170,15 +170,15 @@ ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failreg
|
||||||
### forms.
|
### forms.
|
||||||
|
|
||||||
# Installation with curl
|
# 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"
|
ynh_local_curl "/INSTALL_PATH" "key1=value1" "key2=value2" "key3=value3"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# 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
|
### Only needed if you have configure a systemd service
|
||||||
### If you're not using these lines:
|
### If you're not using these lines:
|
||||||
### - Remove the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the backup script
|
### - 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
|
### - And the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the change_url script
|
||||||
|
|
||||||
# Start a systemd service
|
# 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
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Installation of $app completed" --last
|
|
||||||
|
ynh_script_progression "Installation of $app completed"
|
||||||
|
|
|
@ -23,32 +23,32 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE SYSTEM CONFIGURATIONS
|
# 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
|
### 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`)
|
# 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"
|
yunohost service remove "$app"
|
||||||
fi
|
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
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Removal of $app completed" --last
|
ynh_script_progression "Removal of $app completed"
|
||||||
|
|
|
@ -11,9 +11,9 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE APP MAIN DIR
|
# 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
|
### $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
|
||||||
|
@ -23,9 +23,9 @@ chown -R "$app:www-data" "$install_dir"
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE DATA DIRECTORY
|
# 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)
|
### (Same as for install dir)
|
||||||
chown -R "$app:www-data" "$data_dir"
|
chown -R "$app:www-data" "$data_dir"
|
||||||
|
@ -33,61 +33,62 @@ chown -R "$app:www-data" "$data_dir"
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE MYSQL DATABASE
|
# 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
|
# 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
|
### 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
|
systemctl enable "$app.service" --quiet
|
||||||
|
|
||||||
yunohost service add "$app" --description="A short description of the app" --log="/var/log/$app/$app.log"
|
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 "/etc/fail2ban/jail.d/$app.conf"
|
||||||
ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
|
ynh_restore "/etc/fail2ban/filter.d/$app.conf"
|
||||||
ynh_systemd_action --action=restart --service_name=fail2ban
|
ynh_systemctl --action=restart --service=fail2ban
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE VARIOUS FILES
|
# RESTORE VARIOUS FILES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/cron.d/$app"
|
ynh_restore "/etc/cron.d/$app"
|
||||||
ynh_restore_file --origin_path="/etc/$app/"
|
ynh_restore "/etc/$app/"
|
||||||
|
|
||||||
### For apps with huge logs, you might want to not backup logs every time:
|
### 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.
|
### The mkdir call is just here in case the log directory was not backed up.
|
||||||
### mkdir -p "/var/log/$app"
|
### mkdir -p "/var/log/$app"
|
||||||
### chown $app:www-data "/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:
|
### 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
|
# 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...
|
### 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_systemctl --service="$app" --action="start"
|
||||||
ynh_systemd_action --service_name="php$phpversion-fpm" --action=reload
|
|
||||||
|
|
||||||
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
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Restoration completed for $app" --last
|
ynh_script_progression "Restoration completed for $app"
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -21,48 +20,40 @@ source /usr/share/yunohost/helpers
|
||||||
### - resources are automatically provisioned / updated / deleted (depending on existing resources)
|
### - 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
|
### - 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
|
# 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
|
# 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*
|
### 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
|
### 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)
|
### some legacy installs and you therefore want to initiaze stuff during upgrade)
|
||||||
|
|
||||||
# If db_name doesn't exist, create it
|
# If db_name doesn't exist, create it
|
||||||
# if [ -z "$db_name" ]; then
|
# ynh_app_setting_set_default --key=db_name --value="$(ynh_sanitize_dbid --db_name=$app)"
|
||||||
# db_name=$(ynh_sanitize_dbid --db_name=$app)
|
|
||||||
# ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
|
||||||
# fi
|
|
||||||
|
|
||||||
# If install_dir doesn't exist, create it
|
# If install_dir doesn't exist, create it
|
||||||
# if [ -z "$install_dir" ]; then
|
# ynh_app_setting_set_default --key=install_dir --value="/var/www/$app"
|
||||||
# install_dir=/var/www/$app
|
|
||||||
# ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
|
|
||||||
# fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# 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
|
# 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
|
### $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
|
||||||
|
@ -72,14 +63,14 @@ chown -R "$app:www-data" "$install_dir"
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPDATE A CONFIG FILE
|
# 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
|
### Same as during install
|
||||||
###
|
###
|
||||||
### The file will automatically be backed-up if it's found to be manually modified (because
|
### 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
|
# FIXME: this should be handled by the core in the future
|
||||||
### You may need to use chmod 600 instead of 400,
|
### 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"
|
chown "$app:$app" "$install_dir/some_config_file"
|
||||||
|
|
||||||
### For more complex cases where you want to replace stuff using regexes,
|
### 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
|
### 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_replace --match="match_string" --replace="replace_string" --file="$install_dir/some_config_file"
|
||||||
### ynh_store_file_checksum --file="$install_dir/some_config_file"
|
### ynh_store_file_checksum "$install_dir/some_config_file"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REAPPLY SYSTEM CONFIGURATIONS
|
# 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
|
### 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"
|
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
|
# 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
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Upgrade of $app completed" --last
|
ynh_script_progression "Upgrade of $app completed"
|
||||||
|
|
2
sources/extra_files/app/.gitignore
vendored
2
sources/extra_files/app/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
||||||
*~
|
|
||||||
*.sw[op]
|
|
2
sources/patches/.gitignore
vendored
2
sources/patches/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
||||||
*~
|
|
||||||
*.sw[op]
|
|
Loading…
Reference in a new issue