mirror of
https://github.com/YunoHost-Apps/fittrackee_ynh.git
synced 2024-09-03 18:36:16 +02:00
95 lines
3.6 KiB
Bash
Executable file
95 lines
3.6 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
ynh_script_progression --message="Setting up source files..." --weight=1
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
ynh_setup_source --dest_dir="$install_dir"
|
|
|
|
# Set permissions to app files
|
|
chmod -R o-rwx "$install_dir"
|
|
chown -R $app:www-data "$install_dir"
|
|
|
|
#=================================================
|
|
# CONFIGURE THEN INSTALL SCRIPT AND DEPENDENCIES
|
|
#=================================================
|
|
ynh_script_progression --message="Installing service script..." --weight=1
|
|
|
|
ynh_add_config --template="../conf/.env.production" --destination="$install_dir/.env"
|
|
chmod 600 $install_dir/.env
|
|
chown $app:www-data "$install_dir/.env"
|
|
|
|
set -a; source "$install_dir/.env"; set +a
|
|
|
|
mkdir "$install_dir/venv"
|
|
python3 -m venv "$install_dir/venv"
|
|
$install_dir/venv/bin/pip3 install -r "$install_dir/requirements.txt"
|
|
|
|
#=================================================
|
|
# INITIALIZE DATABASE
|
|
#=================================================
|
|
ynh_script_progression --message="Initializing database..." --weight=1
|
|
|
|
$install_dir/venv/bin/python3 "$install_dir/manage.py" migrate
|
|
$install_dir/venv/bin/python3 "$install_dir/manage.py" initdb
|
|
$install_dir/venv/bin/python3 "$install_dir/manage.py" collectstatic --no-input
|
|
|
|
|
|
#=================================================
|
|
# 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
|
|
|
|
ynh_add_config --template="../conf/${app}.target" --destination="/etc/systemd/system/$app.target"
|
|
|
|
# Create a dedicated systemd config
|
|
ynh_add_systemd_config --service="${app}-server" --template="${app}-server.service"
|
|
ynh_add_systemd_config --service="${app}-worker" --template="${app}-worker.service"
|
|
ynh_add_systemd_config --service="${app}-beat" --template="${app}-beat.service"
|
|
|
|
#=================================================
|
|
# GENERIC FINALIZATION
|
|
#=================================================
|
|
# INTEGRATE SERVICE IN YUNOHOST
|
|
#=================================================
|
|
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
|
|
|
yunohost service add "${app}-beat"
|
|
yunohost service add "${app}-server"
|
|
yunohost service add "${app}-worker"
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
|
|
|
# Start a systemd service
|
|
ynh_systemd_action --service_name="${app}-beat" --action="start" --log_path="systemd" --line_match="Started"
|
|
ynh_systemd_action --service_name="${app}-server" --action="start" --log_path="systemd" --line_match="Booting worker with pid"
|
|
ynh_systemd_action --service_name="${app}-worker" --action="start" --log_path="systemd" --line_match="ready"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|