mirror of
https://github.com/YunoHost-Apps/fittrackee_ynh.git
synced 2024-09-03 18:36:16 +02:00
122 lines
4.6 KiB
Bash
122 lines
4.6 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# CHECK VERSION
|
|
#=================================================
|
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
|
|
|
#=================================================
|
|
# STANDARD UPGRADE STEPS
|
|
#=================================================
|
|
# STOP SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
|
|
|
ynh_systemd_action --action="stop" --service_name="${app}-beat" --log_path="systemd" --line_match="Stopped"
|
|
ynh_systemd_action --action="stop" --service_name="${app}-server" --log_path="systemd" --line_match="Stopped"
|
|
ynh_systemd_action --action="stop" --service_name="${app}-worker" --log_path="systemd" --line_match="Stopped"
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
then
|
|
ynh_script_progression --message="Upgrading source files..." --weight=1
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
ynh_setup_source --dest_dir="$install_dir" --keep=".env"
|
|
fi
|
|
|
|
chmod 750 "$install_dir"
|
|
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_secure_remove --file="$install_dir/venv"
|
|
mkdir "$install_dir/venv"
|
|
python3 -m venv "$install_dir/venv"
|
|
$install_dir/venv/bin/pip3 install -r "$install_dir/requirements.txt"
|
|
|
|
#=================================================
|
|
# Update DATABASE
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading database..." --weight=1
|
|
|
|
$install_dir/venv/bin/python3 "$install_dir/manage.py" migrate
|
|
$install_dir/venv/bin/python3 "$install_dir/manage.py" collectstatic --no-input
|
|
$install_dir/venv/bin/python3 "$install_dir/manage.py" populate_streams
|
|
|
|
#=================================================
|
|
# SET PERMISSIONS ON BOOKWYRM DIRECTORY
|
|
#=================================================
|
|
|
|
chown -R $app:www-data $install_dir
|
|
|
|
#=================================================
|
|
# NGINX CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
|
|
|
|
# Create a dedicated NGINX config
|
|
ynh_add_nginx_config
|
|
|
|
#=================================================
|
|
# SETUP SYSTEMD
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading systemd configuration..." --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
|
|
|
|
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"
|
|
|
|
#=================================================
|
|
# RELOAD NGINX
|
|
#=================================================
|
|
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|