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
2024-01-05 15:28:04 +01:00

106 lines
3.4 KiB
Bash

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# 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"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# If is_signup doesn't exist, create it
if [ -z "$is_signup" ]; then
is_signup="true"
ynh_app_setting_set --app="$app" --key=is_signup --value=$is_signup
fi
# Remove old log file
ynh_secure_remove --file="/var/log/$app/"
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading NodeJS..." --weight=4
ynh_install_nodejs --nodejs_version="$NODEJS_VERSION"
ynh_use_nodejs
#=================================================
# SPECIFIC UPGRADE
#=================================================
# UPGRADE ARMADIETTO
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]; then
ynh_script_progression --message="Upgrade armadietto with npm..." --weight=1
pushd "$install_dir"
upstream_version=$(ynh_app_upstream_version)
ynh_npm -g i "armadietto@$upstream_version"
popd
fi
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"
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=2
# Define armadietto module path
module_path="$node_version_path/$nodejs_version/lib/node_modules/armadietto/lib"
ynh_add_config --template="../conf/server.js" --destination="$install_dir/server.js"
chmod 400 "$install_dir/server.js"
chown $app:$app "$install_dir/server.js"
#=================================================
# 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="Armadietto run a remotestorage server as service" --log="/var/log/$app/$app.log"
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
#=================================================
# 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