diff --git a/manifest.toml b/manifest.toml index 048e6d1..28aa2bc 100644 --- a/manifest.toml +++ b/manifest.toml @@ -63,7 +63,7 @@ ram.runtime = "50M" packages = [ "mariadb-server", "mariadb-client", - "redis-server", + # "redis-server", "build-essential", "fonts-open-sans", diff --git a/scripts/backup b/scripts/backup index c07fc93..3a46a5a 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -31,6 +29,12 @@ ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup --src_path="/etc/systemd/system/$app.service" +#================================================= +# BACKUP VARIOUS FILES +#================================================= + +ynh_backup --src_path="/var/log/$app/" + #================================================= # BACKUP THE MYSQL DATABASE #================================================= diff --git a/scripts/change_url b/scripts/change_url index 4cb19cb..475c417 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC STARTING #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -9,14 +7,12 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# STANDARD MODIFICATIONS #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=1 +ynh_script_progression --message="Stopping $app's systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/logfile.log" +ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/logfile.log" #================================================= # MODIFY URL IN NGINX CONF @@ -28,21 +24,19 @@ ynh_change_url_nginx_config #================================================= # SPECIFIC MODIFICATIONS #================================================= -ynh_script_progression --message="Updating a configuration file..." --weight=1 +ynh_script_progression --message="Updating $app's configuration file..." --weight=1 ynh_add_config --template="endi.ini" --destination="$install_dir/endi.ini" chmod 500 "$install_dir/endi.ini" -chown $app:$app "$install_dir/endi.ini" +chown "$app:$app" "$install_dir/endi.ini" -#================================================= -# GENERIC FINALISATION #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression --message="Starting $app's systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/logfile.log" +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/logfile.log" #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 24081f4..fd0bba6 100755 --- a/scripts/install +++ b/scripts/install @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -29,24 +27,24 @@ ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db" #================================================= ynh_script_progression --message="Setting up source files..." --weight=1 -ynh_app_setting_set --app="$app" --key=install_dir --value="$install_dir" ynh_setup_source --dest_dir="$install_dir/endi" -__ynh_endi_patch_src - chmod -R o-rwx "$install_dir" chown -R "$app:www-data" "$install_dir" +# __ynh_endi_patch_src + #================================================= -# SPECIFIC SETUP +# SETUP APPLICATION #================================================= +ynh_script_progression --message="Building $app..." --weight=1 __ynh_endi_build #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." --weight=1 +ynh_script_progression --message="Adding $app's configuration file..." --weight=1 ynh_add_config --template="endi.ini" --destination="$install_dir/endi.ini" @@ -64,7 +62,7 @@ chmod 750 "/var/log/$app" #================================================= # SETUP APPLICATION #================================================= -ynh_script_progression --message="Configuring enDI..." --weight=1 +ynh_script_progression --message="Configuring $app..." --weight=1 __ynh_endi_migratedb __ynh_endi_add_admin @@ -78,20 +76,17 @@ ynh_script_progression --message="Configuring log rotation..." --weight=1 ynh_add_nginx_config -# Create a dedicated systemd config ynh_add_systemd_config +yunohost service add "$app" --description="enDI, logiciel de comptabilité pour CAE" --log="/var/log/$app/logfile.log" -# Use logrotate to manage application logfile(s) -ynh_use_logrotate - -yunohost service add "$app" --description="enDI, logiciel de comptabilité pour CAE" --log="/var/log/$app/$app.log" +ynh_use_logrotate --logfile="/var/log/$app/logfile.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression --message="Starting $app's systemd service..." --weight=1 -ynh_systemd_action --service_name="$app" --action="start" +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/logfile.log" #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index e856b87..2d1fe68 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -10,15 +8,12 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# STANDARD REMOVE -#================================================= -# REMOVE SERVICE INTEGRATION IN YUNOHOST +# REMOVE SYSTEM CONFIGURATIONS #================================================= +ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 # Remove the service from the list of services known by YunoHost (added from `yunohost service add`) -if ynh_exec_warn_less yunohost service status "$app" >/dev/null -then - ynh_script_progression --message="Removing $app service integration..." --weight=1 +if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then yunohost service remove "$app" fi @@ -30,8 +25,6 @@ ynh_redis_remove_db "$redis_db" ynh_remove_nginx_config -ynh_secure_remove --file="/var/log/$app" - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index db03ef6..4750975 100755 --- a/scripts/restore +++ b/scripts/restore @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -18,14 +16,14 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$install_dir" chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" +chown -R "$app:www-data" "$install_dir" #================================================= # RESTORE THE MYSQL DATABASE #================================================= ynh_script_progression --message="Restoring the MySQL database..." --weight=1 -ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql +ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql #================================================= # RESTORE SYSTEMD @@ -35,25 +33,24 @@ ynh_script_progression --message="Restoring the systemd configuration..." --weig ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/systemd/system/$app.service" -systemctl enable $app.service --quiet +systemctl enable "$app.service" --quiet +yunohost service add "$app" --description="enDI, logiciel de comptabilité pour CAE" --log="/var/log/$app/logfile.log" ynh_restore_file --origin_path="/etc/logrotate.d/$app" -yunohost service add $app --description="enDI, logiciel de comptabilité pour CAE" --log="/var/log/$app/$app.log" +#================================================= +# RESTORE VARIOUS FILES +#================================================= + +ynh_restore_file --origin_path="/var/log/$app/" #================================================= -# START SYSTEMD SERVICE +# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" - -#================================================= -# GENERIC FINALIZATION -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1 +### 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/logfile.log" ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index d89b7a3..ee1fa4b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -9,14 +7,12 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# STANDARD UPGRADE STEPS #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=1 +ynh_script_progression --message="Stopping $app's systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/logfile.log" +ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/logfile.log" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -24,28 +20,32 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app ynh_script_progression --message="Upgrading source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$install_dir/endi" -__ynh_endi_patch_src +ynh_setup_source --dest_dir="$install_dir/endi" --full_replace --keep="endi.ini" chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" +chown -R "$app:www-data" "$install_dir" + +# __ynh_endi_patch_src #================================================= # UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Updating a configuration file..." --weight=1 +ynh_script_progression --message="Updating $app's configuration file..." --weight=1 ynh_add_config --template="endi.ini" --destination="$install_dir/endi.ini" chmod 500 "$install_dir/endi.ini" -chown $app:$app "$install_dir/endi.ini" +chown "$app:$app" "$install_dir/endi.ini" #================================================= -# SPECIFIC UPGRADE +# SETUP APPLICATION #================================================= - +ynh_script_progression --message="Building $app..." --weight=1 __ynh_endi_build +#================================================= +# SETUP APPLICATION +#================================================= ynh_script_progression --message="Migrating databases..." --weight=1 __ynh_endi_migratedb @@ -58,18 +58,17 @@ ynh_add_nginx_config # Create a dedicated systemd config ynh_add_systemd_config +yunohost service add "$app" --description="enDI, logiciel de comptabilité pour CAE" --log="/var/log/$app/logfile.log" # Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append - -yunohost service add $app --description="enDI, logiciel de comptabilité pour CAE" --log="/var/log/$app/$app.log" +ynh_use_logrotate --logfile="/var/log/$app/logfile.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression --message="Starting $app's systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/logfile.log" +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/logfile.log" #================================================= # END OF SCRIPT