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

88 lines
3 KiB
Text
Raw Normal View History

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
2024-05-02 23:06:58 +02:00
python3 -m venv --upgrade $install_dir/venv
2024-01-23 23:44:36 +01:00
localpath=$install_dir/venv/bin:$PATH
2024-01-26 19:48:32 +01:00
environment="FLASK_APP=superset SUPERSET_CONFIG_PATH=$install_dir/superset_config.py SUPERSET_SECRET_KEY=$secret_key"
2024-01-23 23:44:36 +01:00
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 sqlalchemy-bigquery apache-superset==$(ynh_app_upstream_version) --upgrade
2024-01-23 23:44:36 +01:00
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
2024-01-26 00:13:43 +01:00
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="Running on http" --timeout=30
2022-04-16 22:59:26 +02:00
#=================================================
# END OF SCRIPT
#=================================================
2024-01-23 23:44:36 +01:00
ynh_script_progression --message="Upgrade of $app completed" --last