1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/satdress_ynh.git synced 2024-09-03 20:16:27 +02:00
satdress_ynh/scripts/install
2024-05-20 07:53:49 +02:00

92 lines
3.1 KiB
Bash
Executable file

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
site_name=$YNH_APP_ARG_SITE_NAME
site_owner=$YNH_APP_ARG_SITE_OWNER
site_owner_url=$YNH_APP_ARG_SITE_OWNER_URL
randomstring=$(ynh_string_random --length=12)
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_app_setting_set --app=$app --key=site_name --value=$site_name
ynh_app_setting_set --app=$app --key=site_owner --value=$site_owner
ynh_app_setting_set --app=$app --key=site_owner_url --value=$site_owner_url
ynh_app_setting_set --app=$app --key=randomstring --value=$randomstring
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=3
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir/build"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
# SPECIFIC SETUP
#=================================================
# BUILDING SOURCES AND SETTING UP THE SERVER
#=================================================
ynh_script_progression --message="Building the sources (it will take some time)..." --weight=6
ynh_exec_warn_less ynh_install_go --go_version=$GO_VERSION
pushd "$install_dir/build"
# Build the sources
ynh_use_go
export GOPATH="$install_dir/build/go"
export GOCACHE="$install_dir/build/.cache"
CGO_ENABLED=1 go build -trimpath -v -o "$install_dir/bin/" > /dev/null 2>&1
popd
#REMOVEME? ynh_secure_remove --file="$install_dir/build"
ynh_remove_go
# Set permissions to app files
chown -R $app:root "$install_dir"
chmod 750 "${install_dir}/bin/satdress"
#=================================================
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
# Create a dedicated systemd config
ynh_add_systemd_config
ynh_use_logrotate
yunohost service add $app --description="Federated Lightning addresses server" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=2
# 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