mirror of
https://github.com/YunoHost-Apps/zeroui_ynh.git
synced 2024-09-03 18:05:57 +02:00
97 lines
3.3 KiB
Bash
Executable file
97 lines
3.3 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# CHECK IF THE APP CAN BE INSTALLED
|
|
#=================================================
|
|
|
|
# Testing if ZeroTier is installed
|
|
yunohost app list | grep -q "id: zerotier" || ynh_die "ZeroTier is needed, but it is not installed. There is a package for that!"
|
|
|
|
#=================================================
|
|
# INSTALL DEPENDENCIES
|
|
#=================================================
|
|
ynh_script_progression --message="Installing dependencies..." --weight=2
|
|
|
|
# Prevent ERR_OSSL_EVP_UNSUPPORTED error
|
|
export NODE_OPTIONS=--openssl-legacy-provider
|
|
# Prevent yet another Node and Corepack madness
|
|
export COREPACK_ENABLE_DOWNLOAD_PROMPT=0
|
|
|
|
ynh_install_nodejs --nodejs_version=$nodejs_version
|
|
ynh_use_nodejs
|
|
$nodejs_path/corepack enable
|
|
$nodejs_path/corepack prepare yarn@stable --activate
|
|
|
|
#=================================================
|
|
# APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC)
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
ynh_script_progression --message="Setting up source files..." --weight=1
|
|
ynh_setup_source --dest_dir="$install_dir"
|
|
|
|
ynh_script_progression --message="Building the backend..." --weight=3
|
|
pushd $install_dir/backend
|
|
$nodejs_path/yarn install
|
|
popd
|
|
|
|
ynh_script_progression --message="Building the frontend..." --weight=3
|
|
pushd $install_dir/frontend
|
|
$nodejs_path/yarn install
|
|
$nodejs_path/yarn build
|
|
popd
|
|
|
|
chown -R $app:$app "$install_dir"
|
|
chown $app:www-data "$install_dir"
|
|
chown $app:www-data "$install_dir/frontend"
|
|
chown -R $app:www-data "$install_dir/frontend/public"
|
|
|
|
#=================================================
|
|
# SYSTEM CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
|
|
|
ynh_add_nginx_config
|
|
|
|
ynh_add_systemd_config
|
|
|
|
yunohost service add $app --description="ZeroTier Controller Web UI"
|
|
|
|
#=================================================
|
|
# APP INITIAL CONFIGURATION
|
|
#=================================================
|
|
# ADD A CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
|
|
|
# Let's retrieve information on the ZeroTier installation
|
|
zt_token="$(</var/lib/zerotier-one/authtoken.secret)"
|
|
zt_addr="localhost:$(</var/lib/zerotier-one/zerotier-one.port)"
|
|
|
|
ynh_add_config --template="env" --destination="$install_dir/.env"
|
|
|
|
chmod 400 "$install_dir/.env"
|
|
chown $app:$app "$install_dir/.env"
|
|
|
|
#=================================================
|
|
# GENERIC FINALIZATION
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
|
|
|
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
ynh_script_progression --message="Installation of $app completed" --last
|