mirror of
https://github.com/YunoHost-Apps/yunomonitor_ynh.git
synced 2024-09-03 17:46:11 +02:00
76 lines
2.6 KiB
Bash
Executable file
76 lines
2.6 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# STANDARD UPGRADE STEPS
|
|
#=================================================
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
#=================================================
|
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
|
|
|
if ! [ -f "$install_dir/conf/ignore_alert.csv" ]; then
|
|
echo "method level server message target" > "$install_dir/conf/ignore_alert.csv"
|
|
fi
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
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" --full_replace=1
|
|
|
|
chmod 750 "$install_dir"
|
|
chmod -R o-rwx "$install_dir"
|
|
chown -R "$app:www-data" "$install_dir"
|
|
|
|
chmod u+x "$install_dir/yunomonitor.py"
|
|
chmod u+w "$install_dir/conf"
|
|
chmod u+w "$install_dir/well-known"
|
|
|
|
#=================================================
|
|
# BUILD YUNOMONITOR
|
|
#=================================================
|
|
ynh_script_progression --message="Building Yunomonitor..."
|
|
|
|
pushd "$install_dir"
|
|
python3 -m pip install pycryptodome pyyaml
|
|
popd
|
|
|
|
#=================================================
|
|
# STORE THE CONFIG FILE CHECKSUM
|
|
#=================================================
|
|
|
|
ynh_backup_if_checksum_is_different --file="$install_dir/conf/$app.yml"
|
|
# Recalculate and store the checksum of the file for the next upgrade.
|
|
ynh_store_file_checksum --file="$install_dir/conf/$app.yml"
|
|
|
|
#=================================================
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
|
|
|
_yunomonitor_add_nginx_config
|
|
|
|
ynh_add_systemd_config
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Reloading a systemd service..." --weight=1
|
|
|
|
ynh_systemd_action --service_name="$app" --action="reload" --log_path="/var/log/$app/$app.log"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|