1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/focalboard_ynh.git synced 2024-09-03 18:36:19 +02:00
focalboard_ynh/scripts/upgrade
Éric Gaspar 448a890e43 Cleaning
2023-03-14 09:27:26 +01:00

100 lines
3.3 KiB
Bash
Executable file

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
if [ -z "${enable_public_boards:-}" ]; then
enable_public_boards="false"
ynh_app_setting_set --app=$app --key=enable_public_boards --value=$enable_public_boards
fi
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action=stop --log_path="/var/log/$app/$app.log"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=1
# Create a temporary directory
tmpdir="$(mktemp -d)"
# Backup the config file in the temp dir
cp -a "$install_dir/config.json" "$tmpdir/config.json"
# Remove the app directory securely
ynh_secure_remove --file="$install_dir"
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir" #--keep="config.json"
# Copy the admin saved settings from tmp directory to final path
cp -a "$tmpdir/config.json" "$install_dir/config.json"
# Remove the tmp directory securely
ynh_secure_remove --file="$tmpdir"
fi
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
# Create a dedicated systemd config
ynh_add_systemd_config
yunohost service add $app --description="Self-hosted kanban board" --log="/var/log/$app/$app.log"
#=================================================
# MODIFY A CONFIG FILE
#=================================================
ynh_script_progression --message="Modifying a config file..." --weight=1
ynh_add_config --template="../conf/config.json" --destination="$install_dir/config.json"
chmod 600 "$install_dir/config.json"
chown $app:$app "$install_dir/config.json"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action=start --log_path="/var/log/$app/$app.log"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last