mirror of
https://github.com/YunoHost-Apps/fider_ynh.git
synced 2024-09-03 18:36:11 +02:00
Fix restore, cleanup, apply template
This commit is contained in:
parent
86798e12b8
commit
b22a397e7a
8 changed files with 84 additions and 89 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
|
||||||
|
|
||||||
packaging_format = 2
|
packaging_format = 2
|
||||||
|
|
||||||
id = "fider"
|
id = "fider"
|
||||||
|
@ -51,10 +53,11 @@ ram.runtime = "50M"
|
||||||
|
|
||||||
[resources]
|
[resources]
|
||||||
[resources.sources]
|
[resources.sources]
|
||||||
[resources.sources.main]
|
[resources.sources.main]
|
||||||
url = "https://github.com/getfider/fider/archive/refs/tags/v0.21.1.tar.gz"
|
url = "https://github.com/getfider/fider/archive/refs/tags/v0.21.1.tar.gz"
|
||||||
sha256 = "b981360d7017849e1efd0ae0970df6239a32ebdca2be35785b1208f1552fe99e"
|
sha256 = "b981360d7017849e1efd0ae0970df6239a32ebdca2be35785b1208f1552fe99e"
|
||||||
autoupdate.strategy = "latest_github_release"
|
|
||||||
|
autoupdate.strategy = "latest_github_release"
|
||||||
|
|
||||||
[resources.system_user]
|
[resources.system_user]
|
||||||
allow_email = true
|
allow_email = true
|
||||||
|
@ -67,7 +70,7 @@ ram.runtime = "50M"
|
||||||
[resources.ports]
|
[resources.ports]
|
||||||
|
|
||||||
[resources.apt]
|
[resources.apt]
|
||||||
packages = "postgresql"
|
packages = ["postgresql"]
|
||||||
|
|
||||||
[resources.database]
|
[resources.database]
|
||||||
type = "postgresql"
|
type = "postgresql"
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
nodejs_version=18
|
nodejs_version=18
|
||||||
|
|
||||||
go_version=1.20
|
go_version=1.20
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -31,6 +29,12 @@ ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||||
|
|
||||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP VARIOUS FILES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_backup --src_path="/var/log/$app/"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE POSTGRESQL DATABASE
|
# BACKUP THE POSTGRESQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC STARTING
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -9,14 +7,12 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# STANDARD MODIFICATIONS
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP SYSTEMD SERVICE
|
# 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
|
# MODIFY URL IN NGINX CONF
|
||||||
|
@ -26,13 +22,18 @@ ynh_script_progression --message="Updating NGINX web server configuration..." --
|
||||||
ynh_change_url_nginx_config
|
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
|
# 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
|
# END OF SCRIPT
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -9,6 +7,13 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
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
|
# INSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -28,7 +33,7 @@ ynh_script_progression --message="Setting up source files..." --weight=1
|
||||||
ynh_setup_source --dest_dir="$install_dir/sources"
|
ynh_setup_source --dest_dir="$install_dir/sources"
|
||||||
|
|
||||||
chmod -R o-rwx "$install_dir"
|
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
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
|
@ -37,6 +42,15 @@ ynh_script_progression --message="Compiling Fider application..." --weight=1
|
||||||
|
|
||||||
ynh_exec_warn_less build_fider
|
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
|
# SYSTEM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -47,33 +61,18 @@ ynh_add_nginx_config
|
||||||
|
|
||||||
# Create a dedicated systemd config
|
# Create a dedicated systemd config
|
||||||
ynh_add_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)
|
# Use logrotate to manage application logfile(s)
|
||||||
ynh_use_logrotate --nonappend
|
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
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||||
|
|
||||||
# Start a systemd service
|
# 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
|
# END OF SCRIPT
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -10,16 +8,13 @@ source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD REMOVE
|
# REMOVE SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
|
||||||
# REMOVE SERVICE INTEGRATION IN YUNOHOST
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
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`)
|
# 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
|
if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then
|
||||||
then
|
yunohost service remove "$app"
|
||||||
ynh_script_progression --message="Removing $app service integration..." --weight=1
|
|
||||||
yunohost service remove $app
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove the dedicated systemd config
|
# Remove the dedicated systemd config
|
||||||
|
@ -33,9 +28,6 @@ ynh_remove_nginx_config
|
||||||
|
|
||||||
ynh_remove_nodejs
|
ynh_remove_nodejs
|
||||||
|
|
||||||
# Remove the log files
|
|
||||||
ynh_secure_remove --file="/var/log/$app"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -26,7 +24,7 @@ chmod 744 "$install_dir/run_fider"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1
|
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
|
# 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/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
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"
|
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
|
# END OF SCRIPT
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -9,14 +7,12 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# STANDARD UPGRADE STEPS
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP SYSTEMD SERVICE
|
# 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
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
|
@ -25,13 +21,13 @@ ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||||
|
|
||||||
# Moved fron /opt to /var/www
|
# Moved fron /opt to /var/www
|
||||||
if [ -d "/opt/yunohost/$app" ]; then
|
if [ -d "/opt/yunohost/$app" ]; then
|
||||||
# Changing install_dir...
|
# Changing install_dir...
|
||||||
install_dir=/var/www/$app
|
install_dir=/var/www/$app
|
||||||
ynh_app_setting_set --app="$app" --key=install_dir --value="$install_dir"
|
ynh_app_setting_set --app="$app" --key=install_dir --value="$install_dir"
|
||||||
|
|
||||||
# Moving old install_dir to new install_dir...
|
# Moving old install_dir to new install_dir...
|
||||||
ynh_secure_remove "$install_dir"
|
ynh_secure_remove "$install_dir"
|
||||||
mv "/opt/yunohost/$app" "$install_dir"
|
mv "/opt/yunohost/$app" "$install_dir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -40,10 +36,20 @@ fi
|
||||||
ynh_script_progression --message="Upgrading source files..." --weight=1
|
ynh_script_progression --message="Upgrading source files..." --weight=1
|
||||||
|
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
# 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"
|
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
|
# REAPPLY SYSTEM CONFIGURATIONS
|
||||||
|
@ -55,28 +61,17 @@ ynh_add_nginx_config
|
||||||
|
|
||||||
# Create a dedicated systemd config
|
# Create a dedicated systemd config
|
||||||
ynh_add_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)
|
# Use logrotate to manage app-specific logfile(s)
|
||||||
ynh_use_logrotate --non-append
|
ynh_use_logrotate
|
||||||
|
|
||||||
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"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# 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
|
# END OF SCRIPT
|
||||||
|
|
Loading…
Reference in a new issue