1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/vikunja_ynh.git synced 2024-09-03 18:06:26 +02:00
vikunja_ynh/scripts/upgrade

160 lines
5.1 KiB
Text
Raw Normal View History

2021-08-05 17:28:35 +02:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
2023-03-02 19:24:51 +01:00
2021-08-05 17:28:35 +02:00
timezone="$(cat /etc/timezone)"
secret=$(ynh_string_random --length=32)
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
2022-06-21 15:42:43 +02:00
# If backend_path doesn't exist, create it
2023-04-05 23:55:37 +02:00
if [ -z "${backend_path:-}" ]; then
2022-06-21 15:42:43 +02:00
backend_path=/opt/$app
2023-04-05 23:07:17 +02:00
ynh_app_setting_set --app=$app --key=backend_path --value=$backend_path
2022-06-21 15:42:43 +02:00
fi
2023-04-05 23:07:17 +02:00
if [ -z "${set_motd:-}" ]; then
2022-01-16 16:12:55 +01:00
set_motd=""
ynh_app_setting_set --app=$app --key=set_motd --value=$set_motd
fi
2023-04-05 23:07:17 +02:00
if [ -z "${enable_registration:-}" ]; then
2022-01-16 17:00:45 +01:00
enable_registration="true"
ynh_app_setting_set --app=$app --key=enable_registration --value=$enable_registration
fi
2023-04-05 23:07:17 +02:00
if [ -z "${enable_linksharing:-}" ]; then
2022-08-20 22:21:33 +02:00
enable_linksharing="true"
ynh_app_setting_set --app=$app --key=enable_linksharing --value=$enable_linksharing
fi
2023-04-05 23:07:17 +02:00
if [ -z "${enable_taskattachments:-}" ]; then
2022-08-20 22:21:33 +02:00
enable_taskattachments="true"
ynh_app_setting_set --app=$app --key=enable_taskattachments --value=$enable_taskattachments
fi
2023-04-05 23:07:17 +02:00
if [ -z "${enable_taskcomments:-}" ]; then
2022-08-20 22:21:33 +02:00
enable_taskcomments="true"
ynh_app_setting_set --app=$app --key=enable_taskcomments --value=$enable_taskcomments
fi
2023-04-05 23:07:17 +02:00
if [ -z "${enable_emailreminders:-}" ]; then
2022-08-20 22:21:33 +02:00
enable_emailreminders="true"
ynh_app_setting_set --app=$app --key=enable_emailreminders --value=$enable_emailreminders
fi
2023-04-05 23:07:17 +02:00
if [ -z "${enable_userdeletion:-}" ]; then
2022-08-20 22:21:33 +02:00
enable_userdeletion="true"
ynh_app_setting_set --app=$app --key=enable_userdeletion --value=$enable_userdeletion
fi
2023-04-05 23:07:17 +02:00
if [ -z "${maxavatarsize:-}" ]; then
2022-08-22 21:09:52 +02:00
maxavatarsize=1024
2022-08-20 22:21:33 +02:00
ynh_app_setting_set --app=$app --key=maxavatarsize --value=$maxavatarsize
fi
2023-04-05 23:07:17 +02:00
if [ -z "${maxitemsperpage:-}" ]; then
2022-08-22 21:09:52 +02:00
maxitemsperpage=50
2022-08-20 22:21:33 +02:00
ynh_app_setting_set --app=$app --key=maxitemsperpage --value=$maxitemsperpage
fi
2021-08-05 17:28:35 +02:00
#=================================================
# 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=systemd
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=5
# Download, check integrity, uncompress and patch the source from app.src
# Frontend
2023-03-02 19:15:23 +01:00
ynh_setup_source --dest_dir="$install_dir" --source_id="front"
# Backend
2022-06-21 15:40:04 +02:00
mkdir -p "$backend_path/files"
tempdir="$(mktemp -d)"
2023-04-05 23:07:17 +02:00
ynh_setup_source --dest_dir=$tempdir --source_id="back"
back="$(find $tempdir -name "vikunja-*" \! -name "*.sha256")"
2022-06-21 15:40:04 +02:00
cp "$back" "$backend_path/vikunja"
2021-08-05 17:28:35 +02:00
fi
2023-03-02 19:15:23 +01:00
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
2022-06-21 15:40:04 +02:00
chmod +x "$backend_path/vikunja"
chown -R $app:www-data "$backend_path/files"
2021-08-05 17:28:35 +02:00
2022-08-22 20:55:02 +02:00
#=================================================
# UPGRADE A CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading a configuration file..." --weight=1
redis_db=$(ynh_redis_get_free_db)
ynh_add_config --template="../conf/config.yml" --destination="$backend_path/config.yml"
chmod 400 "$backend_path/config.yml"
chown $app:$app "$backend_path/config.yml"
2021-08-05 17:28:35 +02:00
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=2
ynh_add_systemd_config
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="Self-hosted To-Do list application" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="server started on"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last