2022-04-16 22:59:26 +02:00
|
|
|
#!/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
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
#=================================================
|
2024-01-23 23:44:36 +01:00
|
|
|
# STOP SYSTEMD SERVICE
|
2022-04-16 22:59:26 +02:00
|
|
|
#=================================================
|
2024-01-23 23:44:36 +01:00
|
|
|
ynh_script_progression --message="Stopping a systemd service..."
|
2022-04-16 22:59:26 +02:00
|
|
|
|
2024-01-23 23:44:36 +01:00
|
|
|
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
2022-04-16 22:59:26 +02:00
|
|
|
|
|
|
|
#=================================================
|
2024-01-23 23:44:36 +01:00
|
|
|
# RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...)
|
2022-04-16 22:59:26 +02:00
|
|
|
#=================================================
|
2024-01-23 23:44:36 +01:00
|
|
|
# UPDATE A CONFIG FILE
|
2022-04-16 22:59:26 +02:00
|
|
|
#=================================================
|
2024-01-23 23:44:36 +01:00
|
|
|
ynh_script_progression --message="Updating a configuration file..."
|
2022-04-16 22:59:26 +02:00
|
|
|
|
2024-01-23 23:44:36 +01:00
|
|
|
ynh_add_config --template="superset_config.py" --destination="$install_dir/superset_config.py"
|
2022-04-16 22:59:26 +02:00
|
|
|
|
2024-01-23 23:44:36 +01:00
|
|
|
chmod 400 "$install_dir/superset_config.py"
|
|
|
|
chown $app:$app "$install_dir/superset_config.py"
|
2022-04-16 22:59:26 +02:00
|
|
|
|
|
|
|
#=================================================
|
2024-01-23 23:44:36 +01:00
|
|
|
# UPGRADE THE APP APP
|
2022-04-16 22:59:26 +02:00
|
|
|
#=================================================
|
2024-01-23 23:44:36 +01:00
|
|
|
ynh_script_progression --message="Upgrading app..." --weight=5
|
2022-04-16 22:59:26 +02:00
|
|
|
|
2024-01-23 23:44:36 +01:00
|
|
|
# Prepare environment
|
|
|
|
python3.9 -m venv --upgrade $install_dir/venv
|
|
|
|
localpath=$install_dir/venv/bin:$PATH
|
|
|
|
environment="FLASK_APP=$app SUPERSET_CONFIG_PATH=$install_dir/superset_config.py SUPERSET_SECRET_KEY=$secret_key"
|
|
|
|
export $environment
|
2022-04-16 22:59:26 +02:00
|
|
|
|
2024-01-23 23:44:36 +01:00
|
|
|
# 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
|
2022-04-16 22:59:26 +02:00
|
|
|
|
2024-01-23 23:44:36 +01:00
|
|
|
chown -R $app:$app "$install_dir"
|
2022-04-16 22:59:26 +02:00
|
|
|
|
|
|
|
#=================================================
|
2024-01-23 23:44:36 +01:00
|
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
2022-04-16 22:59:26 +02:00
|
|
|
#=================================================
|
2024-01-23 23:44:36 +01:00
|
|
|
ynh_script_progression --message="Upgrading system configurations related to $app..."
|
|
|
|
|
|
|
|
ynh_add_nginx_config
|
2022-04-16 22:59:26 +02:00
|
|
|
|
|
|
|
ynh_add_systemd_config
|
|
|
|
|
2024-01-23 23:44:36 +01:00
|
|
|
yunohost service add $app --log="/var/log/$app/$app.log"
|
2022-04-16 22:59:26 +02:00
|
|
|
|
|
|
|
ynh_use_logrotate --non-append
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2024-01-23 23:44:36 +01:00
|
|
|
ynh_script_progression --message="Starting a systemd service..."
|
2022-04-16 22:59:26 +02:00
|
|
|
|
|
|
|
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2024-01-23 23:44:36 +01:00
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|