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

129 lines
4.1 KiB
Text
Raw Normal View History

2022-03-23 09:15:13 +01:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
2022-03-29 18:03:40 +02:00
source ynh_install_go
2022-03-23 09:15:13 +01:00
source /usr/share/yunohost/helpers
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
2022-03-30 05:36:46 +02:00
ynh_script_progression --message="Stopping a systemd service..." --weight=1
2022-03-23 09:15:13 +01:00
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
2024-01-09 11:50:34 +01:00
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
if [ -z "${name:-}" ]; then
2024-01-09 13:04:00 +01:00
name=$oidc_name
2024-01-09 11:50:34 +01:00
ynh_app_setting_set --app=$app --key=name --value=$name
2024-01-09 13:04:00 +01:00
ynh_app_setting_delete --app=$app --key=oidc_name
2024-01-09 11:50:34 +01:00
fi
if [ -z "${secret:-}" ]; then
2024-01-09 13:04:00 +01:00
secret=$oidc_secret
2024-01-09 11:50:34 +01:00
ynh_app_setting_set --app=$app --key=secret --value=$secret
2024-01-09 13:04:00 +01:00
ynh_app_setting_delete --app=$app --key=oidc_secret
2024-01-09 11:50:34 +01:00
fi
if [ -z "${callback:-}" ]; then
2024-01-09 13:04:00 +01:00
callback=$oidc_callback
2024-01-09 11:50:34 +01:00
ynh_app_setting_set --app=$app --key=callback --value=$callback
2024-01-09 13:04:00 +01:00
ynh_app_setting_delete --app=$app --key=oidc_callback
2024-01-09 11:50:34 +01:00
fi
2022-03-23 09:15:13 +01:00
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
2022-03-30 05:36:46 +02:00
ynh_script_progression --message="Upgrading source files..." --weight=1
2022-03-23 09:15:13 +01:00
# Download, check integrity, uncompress and patch the source from app.src
2024-01-09 11:42:42 +01:00
ynh_setup_source --dest_dir="$install_dir" --keep="config.yaml"
2022-03-23 09:15:13 +01:00
fi
2024-01-09 09:09:27 +01:00
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
2022-03-23 09:15:13 +01:00
#=================================================
# SPECIFIC UPGRADE
#=================================================
2022-03-23 11:09:33 +01:00
# BUILDING SOURCES AND SETTING UP THE SERVER
2022-03-23 09:15:13 +01:00
#=================================================
2022-03-23 11:09:33 +01:00
ynh_script_progression --message="Building the sources (it will take some time)..." --weight=6
ynh_exec_warn_less ynh_install_go --go_version=$GO_VERSION
2024-01-09 09:09:27 +01:00
pushd "$install_dir"
2022-03-25 02:31:25 +01:00
# Setup go exe and environnement
2022-03-23 11:09:33 +01:00
ynh_use_go
2024-01-09 09:09:27 +01:00
export GOPATH="$install_dir/go"
export GOCACHE="$install_dir/go/.cache"
2022-03-25 02:31:25 +01:00
# Build server from source
make build 2>&1
2024-01-09 09:09:27 +01:00
ynh_secure_remove --file="$install_dir/go"
2022-03-23 11:09:33 +01:00
popd
ynh_remove_go
2022-11-12 11:18:22 +01:00
# Setup a nice Yunohost logo
2024-01-09 09:09:27 +01:00
cp ../sources/logo_dark.png "$install_dir/web/themes/dark/logo.png"
cp ../sources/logo_light.png "$install_dir/web/themes/light/logo.png"
2022-11-12 11:18:22 +01:00
2022-03-23 09:15:13 +01:00
#=================================================
# UPDATE A CONFIG FILE
#=================================================
2024-01-09 11:50:34 +01:00
ynh_script_progression --message="Updating a configuration file..." --weight=1
2022-03-23 09:15:13 +01:00
2024-01-09 11:50:34 +01:00
ynh_add_config --template="config.yaml" --destination="$install_dir/config.yaml"
2022-03-23 09:15:13 +01:00
2024-01-09 11:50:34 +01:00
chmod 400 "$install_dir/config.yaml"
chown $app:$app "$install_dir/config.yaml"
2022-03-23 09:15:13 +01:00
#=================================================
# SETUP SYSTEMD
#=================================================
2024-01-09 09:37:02 +01:00
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
2022-03-23 09:15:13 +01:00
2024-01-09 09:09:27 +01:00
# Create a dedicated NGINX config
ynh_add_nginx_config
2022-03-23 09:15:13 +01:00
# Create a dedicated systemd config
ynh_add_systemd_config
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
2022-03-25 15:01:26 +01:00
yunohost service add $app --description="OpenID Connect Provider" --log="/var/log/$app/$app.log"
2022-03-23 09:15:13 +01:00
#=================================================
# START SYSTEMD SERVICE
#=================================================
2022-03-30 05:36:46 +02:00
ynh_script_progression --message="Starting a systemd service..." --weight=1
2022-03-23 09:15:13 +01:00
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# END OF SCRIPT
#=================================================
2022-03-30 05:36:46 +02:00
ynh_script_progression --message="Upgrade of $app completed" --last