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

96 lines
3.6 KiB
Text
Raw Normal View History

2022-04-29 12:18:34 +02:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
2022-12-12 13:56:12 +01:00
ynh_script_progression --message="Setting up source files..." --weight=1
2022-04-29 12:18:34 +02:00
2023-01-30 22:41:47 +01:00
# Download, check integrity, uncompress and patch the source from app.src
2023-02-17 18:52:53 +01:00
ynh_setup_source --dest_dir="$install_dir"
2022-04-29 12:18:34 +02:00
2023-02-17 18:52:53 +01:00
# Set permissions to app files
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
2022-04-29 12:18:34 +02:00
2022-12-29 22:41:34 +01:00
#=================================================
2022-12-29 23:14:40 +01:00
# CONFIGURE THEN INSTALL SCRIPT AND DEPENDENCIES
2022-12-29 22:41:34 +01:00
#=================================================
ynh_script_progression --message="Installing service script..." --weight=1
2023-02-17 18:52:53 +01:00
ynh_add_config --template="../conf/.env.production" --destination="$install_dir/.env"
chmod 600 $install_dir/.env
chown $app:www-data "$install_dir/.env"
2022-12-29 23:14:40 +01:00
2023-02-17 18:52:53 +01:00
set -a; source "$install_dir/.env"; set +a
2022-12-29 23:14:40 +01:00
2023-02-17 18:52:53 +01:00
mkdir "$install_dir/venv"
python3 -m venv "$install_dir/venv"
$install_dir/venv/bin/pip3 install -r "$install_dir/requirements.txt"
2022-04-29 12:18:34 +02:00
2022-12-29 23:06:31 +01:00
#=================================================
# INITIALIZE DATABASE
#=================================================
ynh_script_progression --message="Initializing database..." --weight=1
2023-02-17 18:52:53 +01:00
$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
2023-01-17 21:22:40 +01:00
2023-01-17 21:56:48 +01:00
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
2022-04-29 12:18:34 +02:00
#=================================================
# SETUP SYSTEMD
#=================================================
2022-12-12 13:56:12 +01:00
ynh_script_progression --message="Configuring a systemd service..." --weight=1
2022-04-29 12:18:34 +02:00
ynh_add_config --template="../conf/${app}.target" --destination="/etc/systemd/system/$app.target"
2022-04-29 12:18:34 +02:00
# 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"
2022-04-29 12:18:34 +02:00
#=================================================
# GENERIC FINALIZATION
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
2022-12-12 13:56:12 +01:00
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
2022-04-29 12:18:34 +02:00
yunohost service add "${app}-beat"
yunohost service add "${app}-server"
yunohost service add "${app}-worker"
2022-04-29 12:18:34 +02:00
#=================================================
# START SYSTEMD SERVICE
#=================================================
2022-12-12 13:56:12 +01:00
ynh_script_progression --message="Starting a systemd service..." --weight=1
2022-04-29 12:18:34 +02:00
# 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"
2022-04-29 12:18:34 +02:00
#=================================================
# END OF SCRIPT
#=================================================
2022-12-12 13:56:12 +01:00
ynh_script_progression --message="Installation of $app completed" --last