#!/bin/bash source _common.sh source /usr/share/yunohost/helpers #================================================= # UPGRADE DEPENDENCIES #================================================= ynh_script_progression --message="Upgrading go..." --weight=5 ynh_exec_warn_less ynh_install_go --go_version="$GO_VERSION" #================================================= # 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 #================================================= ynh_script_progression --message="Upgrading source files..." --weight=1 ynh_setup_source --dest_dir="$app_path" --full_replace=1 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 "$app_path" ynh_exec_warn_less ynh_exec_as "$app" "$ynh_go" mod download ynh_exec_warn_less ynh_exec_as "$app" "$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 $app's 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