diff --git a/manifest.toml b/manifest.toml index 05876bb..f02e3a4 100644 --- a/manifest.toml +++ b/manifest.toml @@ -1,3 +1,5 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json + packaging_format = 2 id = "fider" @@ -51,10 +53,11 @@ ram.runtime = "50M" [resources] [resources.sources] - [resources.sources.main] - url = "https://github.com/getfider/fider/archive/refs/tags/v0.21.1.tar.gz" - sha256 = "b981360d7017849e1efd0ae0970df6239a32ebdca2be35785b1208f1552fe99e" - autoupdate.strategy = "latest_github_release" + [resources.sources.main] + url = "https://github.com/getfider/fider/archive/refs/tags/v0.21.1.tar.gz" + sha256 = "b981360d7017849e1efd0ae0970df6239a32ebdca2be35785b1208f1552fe99e" + + autoupdate.strategy = "latest_github_release" [resources.system_user] allow_email = true @@ -67,7 +70,7 @@ ram.runtime = "50M" [resources.ports] [resources.apt] - packages = "postgresql" + packages = ["postgresql"] [resources.database] type = "postgresql" diff --git a/scripts/_common.sh b/scripts/_common.sh index 8364e4c..5355db2 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,6 @@ #================================================= nodejs_version=18 - go_version=1.20 #================================================= diff --git a/scripts/backup b/scripts/backup index 9ab520f..f0c673c 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 POSTGRESQL DATABASE #================================================= diff --git a/scripts/change_url b/scripts/change_url index ae914ad..107a7c6 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/$app.log" +ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # MODIFY URL IN NGINX CONF @@ -26,13 +22,18 @@ ynh_script_progression --message="Updating NGINX web server configuration..." -- ynh_change_url_nginx_config #================================================= -# GENERIC FINALISATION +# SPECIFIC MODIFICATIONS +#================================================= +ynh_script_progression --message="Updating $app's configuration..." --weight=1 + +ynh_replace_string --match_string="https://$old_domain$old_path" --replace_string="https://$domain$path" --target_file="$install_dir/run_fider" + #================================================= # 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/$app.log" +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 7fcc9fd..bafefa6 100755 --- a/scripts/install +++ b/scripts/install @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -9,6 +7,13 @@ source _common.sh source /usr/share/yunohost/helpers +#================================================= +# INITIALIZE AND STORE SETTINGS +#================================================= + +secret=$(ynh_string_random --length 64) +ynh_app_setting_set --app="$app" --key="secret" --value="$secret" + #================================================= # INSTALL DEPENDENCIES #================================================= @@ -28,7 +33,7 @@ ynh_script_progression --message="Setting up source files..." --weight=1 ynh_setup_source --dest_dir="$install_dir/sources" chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" +chown -R "$app:www-data" "$install_dir" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -37,6 +42,15 @@ ynh_script_progression --message="Compiling Fider application..." --weight=1 ynh_exec_warn_less build_fider +#================================================= +# APP INITIAL CONFIGURATION +#================================================= +ynh_script_progression --message="Adding $app's configuration files..." --weight=1 + +ynh_add_config --template="run_fider" --destination="$install_dir/run_fider" +chown "$app:www-data" "$install_dir/run_fider" +chmod 744 "$install_dir/run_fider" + #================================================= # SYSTEM CONFIGURATION #================================================= @@ -47,33 +61,18 @@ ynh_add_nginx_config # Create a dedicated systemd config ynh_add_systemd_config +yunohost service add "$app" --description="Fider Feedback platform" --log="/var/log/$app/$app.log" # Use logrotate to manage application logfile(s) ynh_use_logrotate --nonappend -yunohost service add $app --description="Fider Feedback platform" --log="/var/log/$app/$app.log" - -#================================================= -# SPECIFIC SETUP -#================================================= -# ADD A CONFIGURATION -#================================================= -ynh_script_progression --message="Adding the configuration file..." --weight=1 - -secret=$(ynh_string_random --length 64) -ynh_app_setting_set --app=$app --key=secret --value=$secret - -ynh_add_config --template="run_fider" --destination="$install_dir/run_fider" -chown $app:www-data "$install_dir/run_fider" -chmod 744 "$install_dir/run_fider" - #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index 5276f2b..05971e7 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -10,16 +8,13 @@ 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 - yunohost service remove $app +if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then + yunohost service remove "$app" fi # Remove the dedicated systemd config @@ -33,9 +28,6 @@ ynh_remove_nginx_config ynh_remove_nodejs -# Remove the log files -ynh_secure_remove --file="/var/log/$app" - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index a81d41a..66afd77 100755 --- a/scripts/restore +++ b/scripts/restore @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -26,7 +24,7 @@ chmod 744 "$install_dir/run_fider" #================================================= ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1 -ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql +ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql #================================================= # RESTORE SYSTEM CONFIGURATIONS @@ -36,21 +34,25 @@ ynh_script_progression --message="Restoring system configurations related to $ap 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="Fider Feedback platform" --log="/var/log/$app/$app.log" -mkdir -p "/var/log/$app/" -touch "/var/log/$app/$app.log" -chown -R $app:$app "/var/log/$app/" ynh_restore_file --origin_path="/etc/logrotate.d/$app" -yunohost service add $app --description="Fider Feedback platform" --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" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" + +ynh_systemd_action --service_name="nginx" --action="reload" #================================================= # END OF SCRIPT diff --git a/scripts/upgrade b/scripts/upgrade index 33a3799..20d9a3c 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/$app.log" +ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -25,13 +21,13 @@ ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 # Moved fron /opt to /var/www if [ -d "/opt/yunohost/$app" ]; then - # Changing install_dir... - install_dir=/var/www/$app - ynh_app_setting_set --app="$app" --key=install_dir --value="$install_dir" + # Changing install_dir... + install_dir=/var/www/$app + ynh_app_setting_set --app="$app" --key=install_dir --value="$install_dir" - # Moving old install_dir to new install_dir... - ynh_secure_remove "$install_dir" - mv "/opt/yunohost/$app" "$install_dir" + # Moving old install_dir to new install_dir... + ynh_secure_remove "$install_dir" + mv "/opt/yunohost/$app" "$install_dir" fi #================================================= @@ -40,10 +36,20 @@ fi 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" +ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep="run_fider" chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" +chown -R "$app:www-data" "$install_dir" + +#================================================= +# UPDATE A CONFIG FILE +#================================================= +ynh_script_progression --message="Updating $app's configuration file..." --weight=1 + +ynh_add_config --template="run_fider" --destination="$install_dir/run_fider" + +chown "$app:www-data" "$install_dir/run_fider" +chmod 744 "$install_dir/run_fider" #================================================= # REAPPLY SYSTEM CONFIGURATIONS @@ -55,28 +61,17 @@ ynh_add_nginx_config # Create a dedicated systemd config ynh_add_systemd_config +yunohost service add "$app" --description="Fider Feedback platform" --log="/var/log/$app/$app.log" # Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append - -yunohost service add $app --description="Fider Feedback platform" --log="/var/log/$app/$app.log" - -#================================================= -# UPDATE A CONFIG FILE -#================================================= -ynh_script_progression --message="Updating a configuration file..." --weight=1 - -ynh_add_config --template="run_fider" --destination="$install_dir/run_fider" - -chown $app:www-data "$install_dir/run_fider" -chmod 744 "$install_dir/run_fider" +ynh_use_logrotate #================================================= # 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/$app.log" +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" #================================================= # END OF SCRIPT