2022-01-15 20:47:26 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2024-01-06 19:53:25 +01:00
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
|
|
|
|
2022-01-15 20:47:26 +01:00
|
|
|
#=================================================
|
2024-01-06 19:53:25 +01:00
|
|
|
# UPGRADE DEPENDENCIES
|
2022-01-15 20:47:26 +01:00
|
|
|
#=================================================
|
2024-01-06 19:53:25 +01:00
|
|
|
ynh_script_progression --message="Upgrading go..." --weight=5
|
2022-01-15 20:47:26 +01:00
|
|
|
|
2024-01-06 19:53:25 +01:00
|
|
|
ynh_exec_warn_less ynh_install_go --go_version=$GO_VERSION
|
2022-01-15 20:47:26 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD UPGRADE STEPS
|
|
|
|
#=================================================
|
|
|
|
# STOP SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2022-04-30 20:12:00 +02:00
|
|
|
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
2022-01-15 20:47:26 +01:00
|
|
|
|
|
|
|
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
|
|
then
|
2022-04-30 20:12:00 +02:00
|
|
|
ynh_script_progression --message="Upgrading source files..." --weight=1
|
2022-01-15 20:47:26 +01:00
|
|
|
|
2023-12-15 19:49:14 +01:00
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
2022-01-15 20:47:26 +01:00
|
|
|
fi
|
|
|
|
|
2023-12-15 19:49:14 +01:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:www-data "$install_dir"
|
2022-01-15 20:47:26 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC UPGRADE
|
|
|
|
#=================================================
|
2022-04-30 20:12:00 +02:00
|
|
|
ynh_script_progression --message="Upgrading..." --weight=5
|
2022-04-30 16:24:05 +02:00
|
|
|
|
2022-05-27 23:24:23 +02:00
|
|
|
ynh_use_go
|
2023-12-15 19:49:14 +01:00
|
|
|
export GOPATH="$install_dir/go"
|
|
|
|
export GOCACHE="$install_dir/go/.cache"
|
2022-05-27 17:03:57 +02:00
|
|
|
export GO111MODULE=on
|
|
|
|
|
2024-01-07 00:43:42 +01:00
|
|
|
pushd "$install_dir"
|
2022-05-27 23:24:23 +02:00
|
|
|
ynh_exec_warn_less $ynh_go mod download
|
|
|
|
ynh_exec_warn_less $ynh_go build -tags=jsoniter
|
2022-04-30 16:24:05 +02:00
|
|
|
popd
|
|
|
|
|
2024-01-06 19:53:25 +01:00
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
|
|
|
|
|
|
|
|
ynh_add_nginx_config
|
|
|
|
|
|
|
|
ynh_add_systemd_config
|
|
|
|
|
|
|
|
ynh_use_logrotate --non-append
|
|
|
|
|
|
|
|
yunohost service add $app --description="IP address API" --log="/var/log/$app/$app.log"
|
|
|
|
|
2022-01-15 20:47:26 +01:00
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2022-04-30 20:12:00 +02:00
|
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
2022-01-15 20:47:26 +01:00
|
|
|
|
|
|
|
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2022-04-30 20:12:00 +02:00
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|