1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/scrutiny_ynh.git synced 2024-09-03 20:16:24 +02:00
scrutiny_ynh/scripts/upgrade

113 lines
4.8 KiB
Text
Raw Normal View History

2023-03-03 10:07:36 +01:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
2024-02-25 18:08:35 +01:00
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
ynh_secure_remove --file="$install_dir/bin/scrutiny-web-linux-$YNH_ARCH"
ynh_secure_remove --file="$install_dir/bin/scrutiny-collector-metrics-linux-$YNH_ARCH"
2023-03-03 10:07:36 +01:00
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
2023-03-06 21:25:34 +01:00
ynh_systemd_action --service_name="influxdb" --action="stop"
2023-03-07 22:33:13 +01:00
ynh_systemd_action --service_name="scrutiny-web-server.service" --action="stop" --log_path="/var/log/$app/web-server.log"
if [ $collector -eq 1 ]
then
ynh_systemd_action --service_name="scrutiny-collector.timer" --action="stop" --log_path="/var/log/$app/collector.log"
2023-03-06 21:25:34 +01:00
fi
2023-03-03 10:07:36 +01:00
#=================================================
# "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD, ETC...)
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
2024-02-28 18:26:31 +01:00
ynh_script_progression --message="Upgrading source files..." --weight=1
2023-03-03 10:07:36 +01:00
2024-02-28 18:26:31 +01:00
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --source_id="scrutiny-web-linux" --dest_dir="$install_dir/bin"
ynh_setup_source --source_id="scrutiny-collector-metrics-linux" --dest_dir="$install_dir/bin"
ynh_setup_source --source_id="scrutiny-web-frontend" --dest_dir="$install_dir/web"
2023-03-03 10:07:36 +01:00
#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
ynh_add_nginx_config
2023-03-06 21:25:34 +01:00
ynh_add_systemd_config --service="scrutiny-web-server" --template="systemd-scrutiny-web-server.service"
2023-04-03 11:59:03 +02:00
yunohost service add "scrutiny-web-server" --description="WebUI for smartd S.M.A.R.T monitoring" --log="/var/log/$app/web-server.log" --test_status="systemctl show scrutiny-web-server.service -p ActiveState --value | grep -v failed"
2023-03-03 10:07:36 +01:00
2023-03-06 21:25:34 +01:00
ynh_add_config --template="systemd-scrutiny-collector.service" --destination="/etc/systemd/system/scrutiny-collector.service"
2023-03-07 22:33:13 +01:00
if [ $collector -eq 1 ]
then
2023-03-08 22:24:16 +01:00
yunohost service add "scrutiny-collector" --description="Collector running on timer (daily) for smartd S.M.A.R.T monitoring" --log="/var/log/$app/collector.log" --test_status="systemctl show scrutiny-collector.service -p ActiveState --value | grep -v failed"
2023-03-06 21:25:34 +01:00
fi
2023-03-03 10:07:36 +01:00
2023-03-06 21:25:34 +01:00
ynh_use_logrotate --specific_user="$app" --non-append
2023-03-03 10:07:36 +01:00
#=================================================
# RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS, ...)
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=1
2023-03-07 22:33:13 +01:00
if [ "${path}" == "/" ]
then
base_path=""
else
base_path="${path}"
fi
2023-03-06 21:25:34 +01:00
ynh_add_config --template="config/scrutiny.yaml" --destination="$install_dir/config/scrutiny.yaml"
2023-03-03 10:07:36 +01:00
2023-03-06 21:25:34 +01:00
ynh_add_config --template="systemd-scrutiny-collector.timer" --destination="/etc/systemd/system/scrutiny-collector.timer"
ynh_add_config --template="config/collector.yaml" --destination="$install_dir/config/collector.yaml"
2023-03-03 10:07:36 +01:00
2023-03-06 21:25:34 +01:00
#=================================================
# SET FILE OWNERSHIP / PERMISSIONS
#=================================================
2023-03-03 10:07:36 +01:00
2023-03-06 21:25:34 +01:00
myynh_set_permissions
2023-03-03 10:07:36 +01:00
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
2023-04-03 09:08:54 +02:00
systemctl daemon-reload
2023-03-06 21:25:34 +01:00
ynh_systemd_action --service_name="influxdb" --action="enable"
ynh_systemd_action --service_name="influxdb" --action="start"
2023-04-03 09:08:54 +02:00
ynh_systemd_action --service_name="scrutiny-web-server.service" --action="enable"
2023-03-07 22:33:13 +01:00
ynh_systemd_action --service_name="scrutiny-web-server.service" --action="start" --log_path="/var/log/$app/web-server.log"
if [ $collector -eq 1 ]
then
2023-03-06 21:25:34 +01:00
ynh_systemd_action --service_name="scrutiny-collector.timer" --action="enable"
2023-03-07 22:33:13 +01:00
ynh_systemd_action --service_name="scrutiny-collector.timer" --action="start" --log_path="/var/log/$app/collector.log"
2023-03-06 21:25:34 +01:00
fi
2023-03-03 10:07:36 +01:00
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last