mirror of
https://github.com/YunoHost-Apps/fittrackee_ynh.git
synced 2024-09-03 18:36:16 +02:00
119 lines
3.9 KiB
Bash
Executable file
119 lines
3.9 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
admin_mail=$(ynh_user_get_info --username=$admin --key=username)
|
|
|
|
#=================================================
|
|
# LOGROTATE
|
|
ynh_script_progression --message="Configuring logrotate to manage application logfiles" --weight=1
|
|
|
|
# Use logrotate to manage application logfile(s)
|
|
ynh_use_logrotate --specific_user=$app
|
|
touch /var/log/$app/$app.log
|
|
chown -R $app:www-data /var/log/$app/
|
|
|
|
|
|
|
|
#=================================================
|
|
# INSTALL DEPENDENCIES
|
|
#=================================================
|
|
ynh_script_progression --message="Installing dependencies..." --weight=23
|
|
|
|
ynh_exec_warn_less python3 -m pip install pipenv
|
|
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
#=================================================
|
|
# CONFIGURE THE INSTALL SCRIPT
|
|
#=================================================
|
|
|
|
# key for the .env __KEY__
|
|
key=$(ynh_string_random --length=45 | base64)
|
|
ynh_app_setting_set --app=$app --key=key --value=$key
|
|
|
|
ynh_script_progression --message="Setting up source files..." --weight=64
|
|
|
|
ynh_add_config --template="../conf/.env.production" --destination="$install_dir/.env"
|
|
chmod 600 $install_dir/.env
|
|
|
|
|
|
|
|
chown -R $app:www-data "$install_dir"
|
|
|
|
|
|
set -a; source "$install_dir/.env"; set +a
|
|
|
|
pushd $install_dir
|
|
mkdir -p .venv
|
|
PIPENV_VENV_IN_PROJECT="enabled" PIPENV_SKIP_LOCK=true ynh_exec_warn_less python3 -m pipenv install fittrackee==$fittrackee_version python-dotenv
|
|
pipenv shell
|
|
ftcli db upgrade
|
|
popd
|
|
|
|
|
|
|
|
|
|
#=================================================
|
|
# INITIALIZE DATABASE
|
|
#=================================================
|
|
# ynh_script_progression --message="Initializing database..." --weight=1
|
|
|
|
# ynh_exec_warn_less $install_dir/.venv/bin/ftcli db upgrade
|
|
|
|
|
|
#=================================================
|
|
# System Configuration
|
|
#=================================================
|
|
ynh_script_progression --message="Adding system configurations related to $app ..." --weight=1
|
|
|
|
#=================================================
|
|
# NGINX CONFIGURATION
|
|
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
|
|
|
|
# Create a dedicated NGINX config
|
|
ynh_add_nginx_config
|
|
|
|
#=================================================
|
|
# SETUP SYSTEMD
|
|
ynh_script_progression --message="Configuring a systemd service..." --weight=1
|
|
|
|
# Create a dedicated systemd config
|
|
ynh_add_systemd_config --service="${app}" --template="fittrackee.service"
|
|
ynh_add_systemd_config --service="${app}_workers" --template="fittrackee_workers.service"
|
|
|
|
#=================================================
|
|
# INTEGRATE SERVICE IN YUNOHOST
|
|
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
|
|
|
yunohost service add "${app}" --description="Fittrackee main service" --log="/var/log/$app/$app.log"
|
|
yunohost service add "${app}_workers" --description="Fittrackee task queue service" --log="var/log/$app/$app.log"
|
|
|
|
|
|
#=================================================
|
|
# GENERIC FINALIZATION
|
|
#=================================================
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Starting the systemd services..." --weight=15
|
|
|
|
# Start a systemd service
|
|
ynh_systemd_action --service_name="${app}" --action="start" --log_path="/var/log/$app/$app.log" --line_match="Booting worker with pid"
|
|
ynh_systemd_action --service_name="${app}_workers" --action="start" --log_path="/var/log/$app/$app.log" --line_match="Started"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|