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

[autopatch] Automatic patch attempt for helpers 2.1

This commit is contained in:
Yunohost-Bot 2024-08-31 03:04:03 +02:00 committed by Alexandre Aubin
parent 75485e3dee
commit 49d23a6a9f
9 changed files with 79 additions and 126 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
*~ *~
*.sw[op] *.sw[op]
.DS_Store

View file

@ -20,6 +20,7 @@ code = "https://github.com/apache/superset"
[integration] [integration]
yunohost = '>= 11.2' yunohost = '>= 11.2'
helpers_version = "2.1"
architectures = "all" architectures = "all"
multi_instance = true multi_instance = true
ldap = true ldap = true

View file

@ -1,9 +1,5 @@
#!/bin/bash #!/bin/bash
#================================================= #=================================================
# COMMON VARIABLES # COMMON VARIABLES AND CUSTOM HELPERS
#=================================================
#=================================================
# PERSONAL HELPERS
#================================================= #=================================================

View file

@ -1,37 +1,28 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= ynh_print_info "Declaring files to be backed up..."
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
ynh_backup --src_path="$install_dir" ynh_backup "$install_dir"
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup "/etc/logrotate.d/$app"
ynh_backup --src_path="/etc/systemd/system/$app.service" ynh_backup "/etc/systemd/system/$app.service"
#================================================= #=================================================
# BACKUP THE DATABASE # BACKUP THE DATABASE
#================================================= #=================================================
ynh_print_info --message="Backing up the postgresql database..." ynh_print_info "Backing up the postgresql database..."
ynh_psql_dump_db --database=$db_name > ./appdb.sql ynh_psql_dump_db > ./appdb.sql
ynh_psql_dump_db --database=$userdata_db_name > ./userdb.sql ynh_psql_dump_db --database=$userdata_db_name > ./userdb.sql
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -1,27 +1,21 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# STOP SYSTEMD SERVICE # STOP SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping a systemd service..." ynh_script_progression "Stopping $app's systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" ynh_systemctl --service=$app --action="stop"
#================================================= #=================================================
# MODIFY URL IN NGINX CONF # MODIFY URL IN NGINX CONF
#================================================= #=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." ynh_script_progression "Updating NGINX web server configuration..."
ynh_change_url_nginx_config ynh_config_change_url_nginx
#================================================= #=================================================
# SPECIFIC MODIFICATIONS # SPECIFIC MODIFICATIONS
@ -32,12 +26,12 @@ ynh_change_url_nginx_config
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" ynh_systemctl --service=$app --action="start"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Change of URL completed for $app" --last ynh_script_progression "Change of URL completed for $app"

View file

@ -1,10 +1,5 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -13,20 +8,20 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# ADD A CONFIGURATION # ADD A CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Adding app's configuration file..." ynh_script_progression "Adding app's configuration file..."
secret_key=$(ynh_string_random --length=42) secret_key=$(ynh_string_random --length=42)
ynh_app_setting_set --app=$app --key=secret_key --value=$secret_key ynh_app_setting_set --key=secret_key --value=$secret_key
ynh_add_config --template="superset_config.py" --destination="$install_dir/superset_config.py" ynh_config_add --template="superset_config.py" --destination="$install_dir/superset_config.py"
chmod 400 "$install_dir/superset_config.py" #REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/superset_config.py"
chown $app:$app "$install_dir/superset_config.py" #REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app:$app "$install_dir/superset_config.py"
#================================================= #=================================================
# INSTALL APP # INSTALL APP
#================================================= #=================================================
ynh_script_progression --message="Installing app..." --weight=5 ynh_script_progression "Installing app..."
# Prepare environment # Prepare environment
python3 -m venv $install_dir/venv python3 -m venv $install_dir/venv
@ -38,15 +33,14 @@ export $environment
pushd $install_dir pushd $install_dir
( (
source venv/bin/activate 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) ynh_hide_warnings env $environment pip3 install psycopg2 openpyxl python-ldap Pillow sqlalchemy-bigquery apache-superset==$(ynh_app_upstream_version)
ynh_exec_warn_less env $environment superset db upgrade ynh_hide_warnings env $environment superset db upgrade
ynh_exec_warn_less env $environment superset init ynh_hide_warnings env $environment superset init
deactivate deactivate
) )
popd popd
chown -R $app:$app "$install_dir" #REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:$app "$install_dir"
#================================================= #=================================================
# CREATE AN ADDITIONAL DATABASE FOR USER DATA # CREATE AN ADDITIONAL DATABASE FOR USER DATA
#================================================= #=================================================
@ -56,35 +50,35 @@ userdata_db_name=$userdata_db_user
userdata_db_pwd=$(ynh_string_random) userdata_db_pwd=$(ynh_string_random)
ynh_psql_create_user "$userdata_db_user" "$userdata_db_pwd" ynh_psql_create_user "$userdata_db_user" "$userdata_db_pwd"
ynh_psql_create_db "$userdata_db_name" "$userdata_db_user" 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 --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 --key=userdata_db_name --value=$userdata_db_name
ynh_app_setting_set --app=$app --key=userdata_db_pwd --value=$userdata_db_pwd ynh_app_setting_set --key=userdata_db_pwd --value=$userdata_db_pwd
#================================================= #=================================================
# SYSTEM CONFIGURATION # SYSTEM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Adding system configurations related to $app..." ynh_script_progression "Adding system configurations related to $app..."
# Create a dedicated NGINX config using the conf/nginx.conf template # Create a dedicated NGINX config using the conf/nginx.conf template
ynh_add_nginx_config ynh_config_add_nginx
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_config_add_systemd
yunohost service add $app --log="/var/log/$app/$app.log" yunohost service add $app --log="/var/log/$app/$app.log"
# Use logrotate to manage application logfile(s) # Use logrotate to manage application logfile(s)
ynh_use_logrotate ynh_config_add_logrotate
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting app's systemd service..." ynh_script_progression "Starting app's systemd service..."
# Start a systemd service # Start 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 ynh_systemctl --service=$app --action="start" --wait_until="Running on http" --timeout=30
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Installation of $app completed" --last ynh_script_progression "Installation of $app completed"

View file

@ -1,45 +1,39 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# REMOVE USER DATABASE # REMOVE USER DATABASE
#================================================= #=================================================
ynh_script_progression --message="Removing user database for $app..." ynh_script_progression "Removing user database for $app..."
ynh_psql_remove_db --db_user=$userdata_db_user --db_name=$userdata_db_name # FIXMEhelpers2.1 ynh_psql_drop_db && ynh_psql_drop_user --db_user=$userdata_db_user --db_name=$userdata_db_name
#================================================= #=================================================
# REMOVE SYSTEM CONFIGURATIONS # REMOVE SYSTEM CONFIGURATIONS
#================================================= #=================================================
# REMOVE SYSTEMD SERVICE # REMOVE SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Removing system configurations related to $app..." ynh_script_progression "Removing system configurations related to $app..."
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) # Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null if ynh_hide_warnings yunohost service status $app >/dev/null
then then
ynh_script_progression --message="Removing $app service integration..." ynh_script_progression "Removing $app service integration..."
yunohost service remove $app yunohost service remove $app
fi fi
ynh_remove_systemd_config ynh_config_remove_systemd
ynh_remove_nginx_config ynh_config_remove_nginx
ynh_remove_logrotate ynh_config_remove_logrotate
# Remove other various files specific to the app... such as : # Remove other various files specific to the app... such as :
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Removal of $app completed" --last ynh_script_progression "Removal of $app completed"

View file

@ -1,61 +1,54 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1 ynh_script_progression "Restoring the app main directory..."
ynh_restore_file --origin_path="$install_dir" ynh_restore "$install_dir"
chown -R $app:$app "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:$app "$install_dir"
#================================================= #=================================================
# RESTORE THE MYSQL DATABASE # RESTORE THE MYSQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1 ynh_script_progression "Restoring the PostgreSQL database..."
ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./appdb.sql ynh_psql_db_shell < ./appdb.sql
ynh_psql_create_user "$userdata_db_user" "$userdata_db_pwd" ynh_psql_create_user "$userdata_db_user" "$userdata_db_pwd"
ynh_psql_create_db "$userdata_db_name" "$userdata_db_user" ynh_psql_create_db "$userdata_db_name" "$userdata_db_user"
ynh_psql_connect_as --user=$userdata_db_user --password=$userdata_db_pwd --database=$userdata_db_name < ./userdb.sql ynh_psql_db_shell < ./userdb.sql
#================================================= #=================================================
# RESTORE SYSTEM CONFIGURATIONS # RESTORE SYSTEM CONFIGURATIONS
#================================================= #=================================================
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 ynh_script_progression "Restoring system configurations related to $app..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file --origin_path="/etc/systemd/system/$app.service" ynh_restore "/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet systemctl enable $app.service --quiet
mkdir -p "/var/log/$app" mkdir -p "/var/log/$app"
yunohost service add $app --log="/var/log/$app/$app.log" yunohost service add $app --log="/var/log/$app/$app.log"
ynh_restore_file --origin_path="/etc/logrotate.d/$app" ynh_restore "/etc/logrotate.d/$app"
#================================================= #=================================================
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE # RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 ynh_script_progression "Reloading NGINX web server and $app's service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" ynh_systemctl --service=$app --action="start"
ynh_systemd_action --service_name=nginx --action=reload ynh_systemctl --service=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Restoration completed for $app" --last ynh_script_progression "Restoration completed for $app"

View file

@ -1,18 +1,8 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
@ -20,26 +10,26 @@ upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
# STOP SYSTEMD SERVICE # STOP SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping a systemd service..." ynh_script_progression "Stopping $app's systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" ynh_systemctl --service=$app --action="stop"
#================================================= #=================================================
# RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...) # RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...)
#================================================= #=================================================
# UPDATE A CONFIG FILE # UPDATE A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Updating a configuration file..." ynh_script_progression "Updating configuration..."
ynh_add_config --template="superset_config.py" --destination="$install_dir/superset_config.py" ynh_config_add --template="superset_config.py" --destination="$install_dir/superset_config.py"
chmod 400 "$install_dir/superset_config.py" #REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/superset_config.py"
chown $app:$app "$install_dir/superset_config.py" #REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app:$app "$install_dir/superset_config.py"
#================================================= #=================================================
# UPGRADE THE APP APP # UPGRADE THE APP APP
#================================================= #=================================================
ynh_script_progression --message="Upgrading app..." --weight=5 ynh_script_progression "Upgrading app..."
# Prepare environment # Prepare environment
python3 -m venv --upgrade $install_dir/venv python3 -m venv --upgrade $install_dir/venv
@ -51,37 +41,36 @@ export $environment
pushd $install_dir pushd $install_dir
( (
source venv/bin/activate 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 ynh_hide_warnings env $environment pip3 install psycopg2 openpyxl python-ldap Pillow sqlalchemy-bigquery apache-superset==$(ynh_app_upstream_version) --upgrade
ynh_exec_warn_less env $environment superset db upgrade ynh_hide_warnings env $environment superset db upgrade
ynh_exec_warn_less env $environment superset init ynh_hide_warnings env $environment superset init
deactivate deactivate
) )
popd popd
chown -R $app:$app "$install_dir" #REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:$app "$install_dir"
#================================================= #=================================================
# REAPPLY SYSTEM CONFIGURATIONS # REAPPLY SYSTEM CONFIGURATIONS
#================================================= #=================================================
ynh_script_progression --message="Upgrading system configurations related to $app..." ynh_script_progression "Upgrading system configurations related to $app..."
ynh_add_nginx_config ynh_config_add_nginx
ynh_add_systemd_config ynh_config_add_systemd
yunohost service add $app --log="/var/log/$app/$app.log" yunohost service add $app --log="/var/log/$app/$app.log"
ynh_use_logrotate --non-append ynh_config_add_logrotate
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="Running on http" --timeout=30 ynh_systemctl --service=$app --action="start" --wait_until="Running on http" --timeout=30
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Upgrade of $app completed" --last ynh_script_progression "Upgrade of $app completed"