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

137 lines
4.4 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)
2023-10-27 09:20:57 +02:00
redis_db=$(ynh_redis_get_free_db)
2021-08-05 17:28:35 +02:00
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
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"
2022-01-16 16:12:55 +01:00
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"
2022-01-16 17:00:45 +01:00
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"
2022-08-20 22:21:33 +02:00
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"
2022-08-20 22:21:33 +02:00
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"
2022-08-20 22:21:33 +02:00
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"
2022-08-20 22:21:33 +02:00
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"
2022-08-20 22:21:33 +02:00
fi
2023-04-05 23:07:17 +02:00
if [ -z "${maxavatarsize:-}" ]; then
2022-08-22 21:09:52 +02:00
maxavatarsize=1024
ynh_app_setting_set --app="$app" --key="maxavatarsize" --value="$maxavatarsize"
2022-08-20 22:21:33 +02:00
fi
2023-04-05 23:07:17 +02:00
if [ -z "${maxitemsperpage:-}" ]; then
2022-08-22 21:09:52 +02:00
maxitemsperpage=50
ynh_app_setting_set --app="$app" --key="maxitemsperpage" --value="$maxitemsperpage"
2022-08-20 22:21:33 +02:00
fi
2023-09-05 14:04:20 +02:00
if [ -z "${language:-}" ]; then
2023-10-27 11:08:21 +02:00
language="en"
ynh_app_setting_set --app="$app" --key="language" --value="$language"
fi
if ynh_compare_current_package_version --comparison lt --version "0.23.0~ynh1"; then
mv "$backend_path/config.yml" "$install_dir/config.yml"
ynh_secure_remove "$backend_path"
ynh_app_setting_delete --app="$app" --key="backend_path"
2023-09-05 14:04:20 +02:00
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
#=================================================
ynh_script_progression --message="Upgrading source files..." --weight=5
2021-08-05 17:28:35 +02:00
ynh_setup_source --dest_dir="$install_dir"
executable="$(find $tempdir -name "vikunja-*" \! -name "*.sha256")"
ln -s "$executable" "$install_dir/vikunja"
2021-08-05 17:28:35 +02:00
chmod +x "$install_dir/vikunja"
2021-08-05 17:28:35 +02:00
2023-03-02 19:15:23 +01:00
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
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
ynh_add_config --template="config.yml" --destination="$install_dir/config.yml"
2022-08-22 20:55:02 +02:00
chmod 400 "$install_dir/config.yml"
chown $app:$app "$install_dir/config.yml"
2022-08-22 20:55:02 +02:00
2021-08-05 17:28:35 +02:00
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
ynh_add_nginx_config
ynh_add_systemd_config
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