1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/superset_ynh.git synced 2024-09-03 20:26:31 +02:00
superset_ynh/scripts/upgrade
2024-01-26 19:48:32 +01:00

87 lines
2.9 KiB
Bash

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
#=================================================
# RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...)
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..."
ynh_add_config --template="superset_config.py" --destination="$install_dir/superset_config.py"
chmod 400 "$install_dir/superset_config.py"
chown $app:$app "$install_dir/superset_config.py"
#=================================================
# UPGRADE THE APP APP
#=================================================
ynh_script_progression --message="Upgrading app..." --weight=5
# Prepare environment
python3.9 -m venv --upgrade $install_dir/venv
localpath=$install_dir/venv/bin:$PATH
environment="FLASK_APP=superset SUPERSET_CONFIG_PATH=$install_dir/superset_config.py SUPERSET_SECRET_KEY=$secret_key"
export $environment
# Install and initialize Superset
pushd $install_dir
(
source venv/bin/activate
ynh_exec_warn_less env $environment pip3 install psycopg2 openpyxl python-ldap Pillow apache-superset==$(ynh_app_upstream_version) --upgrade
ynh_exec_warn_less env $environment superset db upgrade
ynh_exec_warn_less env $environment superset init
deactivate
)
popd
chown -R $app:$app "$install_dir"
#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Upgrading system configurations related to $app..."
ynh_add_nginx_config
ynh_add_systemd_config
yunohost service add $app --log="/var/log/$app/$app.log"
ynh_use_logrotate --non-append
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="Running on http" --timeout=30
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last