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/install

91 lines
3.2 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
#=================================================
2024-01-23 23:44:36 +01:00
# APP INITIAL CONFIGURATION
2022-04-16 22:59:26 +02:00
#=================================================
2024-01-23 23:44:36 +01:00
# ADD A CONFIGURATION
2022-04-16 22:59:26 +02:00
#=================================================
2024-01-23 23:44:36 +01:00
ynh_script_progression --message="Adding app's configuration file..."
2022-04-16 22:59:26 +02:00
2024-01-23 23:44:36 +01:00
secret_key=$(ynh_string_random --length=42)
ynh_app_setting_set --app=$app --key=secret_key --value=$secret_key
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
# INSTALL APP
2022-04-16 22:59:26 +02:00
#=================================================
2024-01-23 23:44:36 +01:00
ynh_script_progression --message="Installing 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 $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)
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
# CREATE AN ADDITIONAL DATABASE FOR USER DATA
2022-04-16 22:59:26 +02:00
#=================================================
2024-01-23 23:44:36 +01:00
userdata_db_user=${app}_userdata
userdata_db_name=$userdata_db_user
userdata_db_pwd=$(ynh_string_random)
ynh_psql_create_user "$userdata_db_user" "$userdata_db_pwd"
ynh_psql_create_db "$userdata_db_name" "$userdata_db_user"
ynh_app_setting_set --app=$app --key=userdata_db_user --value=$userdata_db_user
ynh_app_setting_set --app=$app --key=userdata_db_name --value=$userdata_db_name
ynh_app_setting_set --app=$app --key=userdata_db_pwd --value=$userdata_db_pwd
2022-04-16 22:59:26 +02:00
#=================================================
2024-01-23 23:44:36 +01:00
# SYSTEM CONFIGURATION
2022-04-16 22:59:26 +02:00
#=================================================
2024-01-23 23:44:36 +01:00
ynh_script_progression --message="Adding system configurations related to $app..."
2022-04-16 22:59:26 +02:00
2024-01-23 23:44:36 +01:00
# Create a dedicated NGINX config using the conf/nginx.conf template
2022-04-16 22:59:26 +02:00
ynh_add_nginx_config
# Create a dedicated systemd config
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
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
#=================================================
# START SYSTEMD SERVICE
#=================================================
2024-01-23 23:44:36 +01:00
ynh_script_progression --message="Starting app's systemd service..."
2022-04-16 22:59:26 +02:00
# Start a systemd service
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="Installation of $app completed" --last