diff --git a/conf/systemd.service b/conf/systemd.service index 75e39f5..2048f92 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -10,6 +10,7 @@ Environment=PORT=__PORT__ Environment=HOSTNAME=__DOMAIN__ Environment=GIN_MODE=release Environment=FORWARD_IP_HEADER=X-Forwarded-For +Environment="__YNH_GO_LOAD_PATH__" WorkingDirectory=__APP_PATH__/ ExecStart=__APP_PATH__/ifconfig.io StandardOutput=append:/var/log/__APP__/__APP__.log diff --git a/scripts/_common.sh b/scripts/_common.sh index c59394e..76cbbab 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,9 @@ #================================================= # dependencies used by the app -pkg_dependencies="golang" +pkg_dependencies="" + +GO_VERSION="1.18" #================================================= # PERSONAL HELPERS diff --git a/scripts/install b/scripts/install index a468a3b..1eeb3cb 100755 --- a/scripts/install +++ b/scripts/install @@ -7,6 +7,7 @@ #================================================= source _common.sh +source ynh_install_go source /usr/share/yunohost/helpers #================================================= @@ -66,6 +67,7 @@ ynh_app_setting_set --app=$app --key=port --value=$port ynh_script_progression --message="Installing dependencies..." --weight=5 ynh_install_app_dependencies $pkg_dependencies +ynh_exec_warn_less ynh_install_go --go_version=$GO_VERSION #================================================= # CREATE DEDICATED USER @@ -100,11 +102,15 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Installing..." --weight=5 +# Setup go environnement +ynh_use_go +export GOPATH="$final_path/go" +export GOCACHE="$final_path/go/.cache" export GO111MODULE=on pushd "$app_path" - ynh_exec_warn_less go mod download - ynh_exec_warn_less go build + ynh_exec_warn_less $ynh_go mod download + ynh_exec_warn_less $ynh_go build -tags=jsoniter popd #================================================= diff --git a/scripts/remove b/scripts/remove index 8184c37..bc90bba 100755 --- a/scripts/remove +++ b/scripts/remove @@ -7,6 +7,7 @@ #================================================= source _common.sh +source ynh_install_go source /usr/share/yunohost/helpers #================================================= @@ -72,6 +73,7 @@ ynh_script_progression --message="Removing dependencies..." --weight=5 # Remove metapackage and its dependencies ynh_remove_app_dependencies +ynh_remove_go #================================================= # CLOSE A PORT diff --git a/scripts/restore b/scripts/restore index 24de3d0..11d2772 100755 --- a/scripts/restore +++ b/scripts/restore @@ -8,6 +8,7 @@ # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh +source ../settings/scripts/ynh_install_go source /usr/share/yunohost/helpers #================================================= @@ -79,6 +80,7 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=5 # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies +ynh_exec_warn_less ynh_install_go --go_version=$GO_VERSION #================================================= # RESTORE SYSTEMD diff --git a/scripts/upgrade b/scripts/upgrade index 448ba8e..6b38e8e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -7,6 +7,7 @@ #================================================= source _common.sh +source ynh_install_go source /usr/share/yunohost/helpers #================================================= @@ -100,17 +101,22 @@ ynh_add_nginx_config ynh_script_progression --message="Upgrading dependencies..." --weight=5 ynh_install_app_dependencies $pkg_dependencies +ynh_exec_warn_less ynh_install_go --go_version=$GO_VERSION #================================================= # SPECIFIC UPGRADE #================================================= ynh_script_progression --message="Upgrading..." --weight=5 +# Setup go environnement +ynh_use_go +export GOPATH="$final_path/go" +export GOCACHE="$final_path/go/.cache" export GO111MODULE=on pushd "$app_path" - ynh_exec_warn_less go mod download - ynh_exec_warn_less go build + ynh_exec_warn_less $ynh_go mod download + ynh_exec_warn_less $ynh_go build -tags=jsoniter popd #=================================================