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

107 lines
3.4 KiB
Text
Raw Normal View History

2021-12-17 11:38:57 +01:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
2022-01-01 16:14:00 +01:00
upgrade_type=$(ynh_check_app_version_changed)
2021-12-17 11:38:57 +01:00
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
2021-12-17 11:38:57 +01:00
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
2021-12-21 01:17:31 +01:00
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
2021-12-17 11:38:57 +01:00
# If is_signup doesn't exist, create it
if [ -z "$is_signup" ]; then
2024-01-05 15:28:04 +01:00
is_signup="true"
ynh_app_setting_set --app="$app" --key=is_signup --value=$is_signup
2022-01-01 16:14:00 +01:00
fi
# Remove old log file
ynh_secure_remove --file="/var/log/$app/"
2021-12-17 11:38:57 +01:00
#=================================================
2021-12-21 01:17:31 +01:00
# UPGRADE DEPENDENCIES
2021-12-17 11:38:57 +01:00
#=================================================
2024-01-05 15:28:04 +01:00
ynh_script_progression --message="Upgrading NodeJS..." --weight=4
2021-12-17 11:38:57 +01:00
2024-01-05 15:28:04 +01:00
ynh_install_nodejs --nodejs_version="$NODEJS_VERSION"
2021-12-21 01:17:31 +01:00
ynh_use_nodejs
2021-12-17 11:38:57 +01:00
#=================================================
2021-12-21 01:17:31 +01:00
# SPECIFIC UPGRADE
2022-01-01 16:14:00 +01:00
#=================================================
2022-05-27 17:03:32 +02:00
# UPGRADE ARMADIETTO
2022-01-01 16:14:00 +01:00
#=================================================
2024-01-05 15:28:04 +01:00
if [ "$upgrade_type" == "UPGRADE_APP" ]; then
ynh_script_progression --message="Upgrade armadietto with npm..." --weight=1
2022-01-01 16:14:00 +01:00
2024-01-05 15:28:04 +01:00
pushd "$install_dir"
upstream_version=$(ynh_app_upstream_version)
ynh_npm -g i "armadietto@$upstream_version"
popd
2022-01-01 16:14:00 +01:00
fi
2024-01-05 15:28:04 +01:00
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:$app "$install_dir"
chmod -R o-rwx "$data_dir"
chown -R "$app:$app" "$data_dir"
2021-12-17 11:38:57 +01:00
#=================================================
2022-05-27 17:03:32 +02:00
# UPDATE A CONFIG FILE
2021-12-21 01:17:31 +01:00
#=================================================
2022-05-27 17:03:32 +02:00
ynh_script_progression --message="Updating a configuration file..." --weight=2
2021-12-21 01:17:31 +01:00
# Define armadietto module path
2022-01-01 16:14:00 +01:00
module_path="$node_version_path/$nodejs_version/lib/node_modules/armadietto/lib"
2021-12-21 01:17:31 +01:00
2024-01-05 15:28:04 +01:00
ynh_add_config --template="../conf/server.js" --destination="$install_dir/server.js"
2021-12-21 01:17:31 +01:00
2024-01-05 15:28:04 +01:00
chmod 400 "$install_dir/server.js"
chown $app:$app "$install_dir/server.js"
2021-12-21 01:17:31 +01:00
2021-12-17 11:38:57 +01:00
#=================================================
2024-01-05 15:28:04 +01:00
# REAPPLY SYSTEM CONFIGURATIONS
2021-12-17 11:38:57 +01:00
#=================================================
2024-01-05 15:28:04 +01:00
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
2021-12-17 11:38:57 +01:00
# Create a dedicated systemd config
ynh_add_systemd_config
2024-01-05 15:28:04 +01:00
yunohost service add $app --description="Armadietto run a remotestorage server as service" --log="/var/log/$app/$app.log"
2021-12-21 01:17:31 +01:00
2022-05-27 17:03:32 +02:00
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
2021-12-21 01:17:31 +01:00
2021-12-17 11:38:57 +01:00
#=================================================
2022-05-27 17:03:32 +02:00
# START SYSTEMD SERVICE
2021-12-17 11:38:57 +01:00
#=================================================
2022-05-27 17:03:32 +02:00
ynh_script_progression --message="Starting a systemd service..." --weight=1
2021-12-17 11:38:57 +01:00
2022-05-27 17:03:32 +02:00
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
2021-12-17 11:38:57 +01:00
#=================================================
# END OF SCRIPT
#=================================================
2022-05-27 17:03:32 +02:00
ynh_script_progression --message="Upgrade of $app completed" --last