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/install
2024-01-06 19:50:38 +01:00

68 lines
2.1 KiB
Bash
Executable file

#!/bin/bash
source _common.sh
source /usr/share/yunohost/helpers
app_path="$install_dir/go/src/github.com/georgyo/ifconfig.io"
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing go..." --weight=5
ynh_exec_warn_less ynh_install_go --go_version=$GO_VERSION
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=1
ynh_setup_source --dest_dir="$app_path"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
# SPECIFIC SETUP
#=================================================
ynh_script_progression --message="Building..." --weight=5
# Setup go environnement
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_go mod download
ynh_exec_warn_less $ynh_go build -tags=jsoniter
popd
#=================================================
# SETUP SYSTEM CONFS
#=================================================
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
ynh_add_nginx_config
# Create a dedicated systemd config
ynh_add_systemd_config
# Use logrotate to manage application logfile(s)
ynh_use_logrotate --logfile="/var/log/$app/$app.log"
yunohost service add $app --description="IP address API" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting service..." --weight=1
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last