2022-08-06 19:00:44 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD UPGRADE STEPS
|
|
|
|
#=================================================
|
|
|
|
# STOP SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2022-08-07 20:41:00 +02:00
|
|
|
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
2022-08-06 19:00:44 +02:00
|
|
|
|
2024-01-27 17:00:52 +01:00
|
|
|
ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log"
|
2022-08-06 19:00:44 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# UPGRADE DEPENDENCIES
|
|
|
|
#=================================================
|
2024-01-27 17:00:52 +01:00
|
|
|
ynh_script_progression --message="Updating NodeJS..." --weight=1
|
2022-08-06 19:00:44 +02:00
|
|
|
|
2024-01-27 17:00:52 +01:00
|
|
|
ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version"
|
2022-08-06 19:00:44 +02:00
|
|
|
|
|
|
|
#=================================================
|
2024-01-27 17:00:52 +01:00
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
2022-08-06 19:00:44 +02:00
|
|
|
#=================================================
|
2024-01-27 17:00:52 +01:00
|
|
|
ynh_script_progression --message="Upgrading source files..." --weight=1
|
2022-08-06 19:00:44 +02:00
|
|
|
|
2024-01-27 17:00:52 +01:00
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
|
|
ynh_setup_source --dest_dir="$install_dir/source" --full_replace=1
|
|
|
|
|
|
|
|
chmod 750 "$install_dir"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R "$app:www-data" "$install_dir"
|
2022-08-06 19:00:44 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# UPDATE A CONFIG FILE
|
|
|
|
#=================================================
|
2022-08-07 20:41:00 +02:00
|
|
|
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
2022-08-06 19:00:44 +02:00
|
|
|
|
2024-01-28 12:04:27 +01:00
|
|
|
ynh_add_config --template="dot_env" --destination="$install_dir/.env"
|
2022-08-06 19:00:44 +02:00
|
|
|
|
2024-01-27 15:12:48 +01:00
|
|
|
chmod 400 "$install_dir/.env"
|
2024-01-27 17:00:52 +01:00
|
|
|
chown "$app:$app" "$install_dir/.env"
|
2022-08-06 19:00:44 +02:00
|
|
|
|
2022-08-10 00:43:15 +02:00
|
|
|
version=$(ynh_app_upstream_version)
|
|
|
|
|
2024-01-27 17:00:52 +01:00
|
|
|
ynh_add_config --template="version.py" --destination="$install_dir/source/recipes/version.py"
|
|
|
|
chmod 400 "$install_dir/source/recipes/version.py"
|
|
|
|
chown "$app:$app" "$install_dir/source/recipes/version.py"
|
2022-08-10 00:43:15 +02:00
|
|
|
|
2022-08-07 20:38:59 +02:00
|
|
|
#=================================================
|
2024-01-27 17:00:52 +01:00
|
|
|
# SPECIFIC SETUP
|
2022-08-07 20:38:59 +02:00
|
|
|
#=================================================
|
2024-01-27 17:00:52 +01:00
|
|
|
ynh_script_progression --message="Building frontend..." --weight=5
|
|
|
|
_tandoor_build_frontend
|
2022-08-07 20:38:59 +02:00
|
|
|
|
2024-01-27 17:00:52 +01:00
|
|
|
ynh_script_progression --message="Installing Tandoor and its python dependencies..." --weight=1
|
|
|
|
_tandoor_venv_install
|
2022-08-07 20:38:59 +02:00
|
|
|
|
2024-01-27 17:00:52 +01:00
|
|
|
ynh_script_progression --message="Running migrations and generating static files..." --weight=2
|
|
|
|
pushd "$install_dir/source"
|
|
|
|
(
|
|
|
|
source "$install_dir/.env"
|
2022-12-27 19:40:50 +01:00
|
|
|
|
2024-01-27 17:00:52 +01:00
|
|
|
ynh_exec_as "$app" "$venvpy" manage.py migrate
|
|
|
|
ynh_psql_execute_as_root --sql="ALTER USER $app WITH NOSUPERUSER;"
|
|
|
|
ynh_exec_as "$app" "$venvpy" manage.py collectstatic --no-input
|
|
|
|
ynh_exec_as "$app" "$venvpy" manage.py collectstatic_js_reverse
|
|
|
|
)
|
|
|
|
popd
|
2022-08-06 19:00:44 +02:00
|
|
|
|
|
|
|
#=================================================
|
2024-01-27 17:00:52 +01:00
|
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
2022-08-06 19:00:44 +02:00
|
|
|
#=================================================
|
2024-01-27 17:00:52 +01:00
|
|
|
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
|
|
|
|
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
2022-08-06 19:00:44 +02:00
|
|
|
|
|
|
|
# Create a dedicated systemd config
|
|
|
|
ynh_add_systemd_config
|
2024-01-27 17:00:52 +01:00
|
|
|
yunohost service add "$app" --description="Smart recipe management" --log="/var/log/$app/$app.log"
|
2022-08-06 19:00:44 +02:00
|
|
|
|
|
|
|
# Use logrotate to manage app-specific logfile(s)
|
|
|
|
ynh_use_logrotate --non-append
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2022-08-07 20:41:00 +02:00
|
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
2022-08-06 19:00:44 +02:00
|
|
|
|
|
|
|
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2022-08-07 20:41:00 +02:00
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|