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

91 lines
3.1 KiB
Text
Raw Normal View History

2023-09-23 16:49:01 +02:00
#!/bin/bash
2023-10-06 13:52:35 +02:00
2023-09-23 16:49:01 +02:00
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
2023-10-06 13:52:35 +02:00
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
2023-09-23 16:49:01 +02:00
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=1
# Download, check integrity, uncompress and patch the source from app.src
2023-10-06 13:52:35 +02:00
ynh_setup_source --dest_dir="$install_dir" --keep="config.json"
2023-09-23 16:49:01 +02:00
fi
chown -R $app:www-data "$install_dir"
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=10
# Install Nodejs
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
2023-09-23 16:49:01 +02:00
#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
# This should be a literal copypasta of what happened in the install's "System configuration" section
ynh_add_nginx_config
ynh_add_systemd_config
ynh_use_logrotate --non-append
2023-10-06 08:52:55 +02:00
2023-10-06 13:52:35 +02:00
yunohost service add $app --description="Federated shared agenda for local communities" --log="/var/log/$app/$app.log"
2023-09-23 16:49:01 +02:00
#=================================================
# RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...)
#=================================================
# UPDATE A CONFIG FILE
#=================================================
2023-10-06 13:52:35 +02:00
#ynh_script_progression --message="Updating a configuration file..." --weight=1
2023-09-23 16:49:01 +02:00
2023-10-06 13:52:35 +02:00
#ynh_add_config --template="config.json" --destination="$install_dir/config.json"
2023-09-23 16:49:01 +02:00
2023-10-06 13:52:35 +02:00
#chmod 400 "$install_dir/config.json"
#chown $app:$app "$install_dir/config.json"
2023-09-23 16:49:01 +02:00
#=================================================
# CONFIGURE THE APP
#=================================================
ynh_script_progression --message="Updating app dependencies..." --weight=15
pushd $install_dir
ynh_use_nodejs
2023-10-07 08:06:23 +02:00
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH yarn install # Install/upgrade dependencies
popd
2023-09-23 16:49:01 +02:00
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
2023-10-06 13:52:35 +02:00
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd"
2023-09-23 16:49:01 +02:00
#=================================================
# END OF SCRIPT
#=================================================
2023-10-06 08:52:55 +02:00
ynh_script_progression --message="Upgrade of $app completed" --last