1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/dex_ynh.git synced 2024-09-03 18:26:22 +02:00
dex_ynh/scripts/install

86 lines
2.7 KiB
Text
Raw Normal View History

2022-03-23 09:15:13 +01:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
2022-03-23 11:03:13 +01:00
source ynh_install_go
2022-03-23 09:15:13 +01:00
source /usr/share/yunohost/helpers
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
2022-03-30 05:36:46 +02:00
ynh_script_progression --message="Setting up source files..." --weight=1
2022-03-23 09:15:13 +01:00
2024-01-09 09:09:27 +01:00
ynh_setup_source --dest_dir="$install_dir"
2022-03-23 09:15:13 +01:00
2024-01-09 09:09:27 +01:00
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
2022-03-23 09:15:13 +01:00
#=================================================
# SPECIFIC SETUP
#=================================================
2022-03-23 11:03:13 +01:00
# BUILDING SOURCES AND SETTING UP THE SERVER
2022-03-23 09:15:13 +01:00
#=================================================
2022-03-23 11:03:13 +01:00
ynh_script_progression --message="Building the sources (it will take some time)..." --weight=6
2022-03-23 09:15:13 +01:00
2022-03-23 11:03:13 +01:00
ynh_exec_warn_less ynh_install_go --go_version=$GO_VERSION
2022-03-23 09:15:13 +01:00
2024-01-09 09:09:27 +01:00
pushd "$install_dir"
2022-03-24 09:58:09 +01:00
# Setup go exe and environnement
2022-03-23 11:03:13 +01:00
ynh_use_go
2024-01-09 09:09:27 +01:00
export GOPATH="$install_dir/go"
export GOCACHE="$install_dir/go/.cache"
2022-03-24 09:58:09 +01:00
# Build server from source
2022-03-25 02:31:25 +01:00
make build 2>&1
2024-01-09 09:09:27 +01:00
ynh_secure_remove --file="$install_dir/go"
2022-03-23 11:03:13 +01:00
popd
2022-03-23 09:15:13 +01:00
2022-03-23 11:03:13 +01:00
ynh_remove_go
2022-03-23 09:15:13 +01:00
2024-01-09 09:09:27 +01:00
# Setup a nice YunoHost logo
cp ../sources/logo_dark.png "$install_dir/web/themes/dark/logo.png"
cp ../sources/logo_light.png "$install_dir/web/themes/light/logo.png"
2022-11-12 11:18:22 +01:00
2022-03-23 09:15:13 +01:00
#=================================================
# ADD A CONFIGURATION
#=================================================
2022-03-30 05:36:46 +02:00
ynh_script_progression --message="Adding a configuration file..." --weight=1
2022-03-23 09:15:13 +01:00
2024-01-09 09:09:27 +01:00
ynh_add_config --template="config.yaml" --destination="$install_dir/config.yaml"
2022-03-23 11:03:13 +01:00
2024-01-09 09:09:27 +01:00
chmod 400 "$install_dir/config.yaml"
chown $app:$app "$install_dir/config.yaml"
2022-03-23 09:15:13 +01:00
#=================================================
# SETUP SYSTEMD
#=================================================
2022-03-30 05:36:46 +02:00
ynh_script_progression --message="Configuring a systemd service..." --weight=1
2022-03-23 09:15:13 +01:00
2024-01-09 09:09:27 +01:00
# Create a dedicated NGINX config
ynh_add_nginx_config
2022-03-23 09:15:13 +01:00
2024-01-09 09:09:27 +01:00
ynh_add_systemd_config
2022-03-23 09:15:13 +01:00
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
2022-03-23 11:03:13 +01:00
yunohost service add $app --description="OpenID Connect Provider" --log="/var/log/$app/$app.log"
2022-03-23 09:15:13 +01:00
#=================================================
# START SYSTEMD SERVICE
#=================================================
2022-03-30 05:36:46 +02:00
ynh_script_progression --message="Starting a systemd service..." --weight=1
2022-03-23 09:15:13 +01:00
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# END OF SCRIPT
#=================================================
2022-03-30 05:36:46 +02:00
ynh_script_progression --message="Installation of $app completed" --last