1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ifconfig-io_ynh.git synced 2024-09-03 20:36:27 +02:00
ifconfig-io_ynh/scripts/upgrade
2024-01-07 00:43:42 +01:00

77 lines
2.3 KiB
Bash

#!/bin/bash
source _common.sh
source /usr/share/yunohost/helpers
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading go..." --weight=5
ynh_exec_warn_less ynh_install_go --go_version=$GO_VERSION
#=================================================
# 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"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=1
ynh_setup_source --dest_dir="$install_dir"
fi
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
# SPECIFIC UPGRADE
#=================================================
ynh_script_progression --message="Upgrading..." --weight=5
ynh_use_go
export GOPATH="$install_dir/go"
export GOCACHE="$install_dir/go/.cache"
export GO111MODULE=on
pushd "$install_dir"
ynh_exec_warn_less $ynh_go mod download
ynh_exec_warn_less $ynh_go build -tags=jsoniter
popd
#=================================================
# 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"
#=================================================
# 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