From 49d23a6a9f129f7b0fa93ca4e7074cc2c0761333 Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Sat, 31 Aug 2024 03:04:03 +0200 Subject: [PATCH] [autopatch] Automatic patch attempt for helpers 2.1 --- .gitignore | 1 + manifest.toml | 1 + scripts/_common.sh | 6 +----- scripts/backup | 25 ++++++++---------------- scripts/change_url | 20 +++++++------------- scripts/install | 46 ++++++++++++++++++++------------------------- scripts/remove | 24 +++++++++-------------- scripts/restore | 35 ++++++++++++++-------------------- scripts/upgrade | 47 ++++++++++++++++++---------------------------- 9 files changed, 79 insertions(+), 126 deletions(-) diff --git a/.gitignore b/.gitignore index 783a4ae..8f144f3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *~ *.sw[op] +.DS_Store diff --git a/manifest.toml b/manifest.toml index 961a475..07613b2 100644 --- a/manifest.toml +++ b/manifest.toml @@ -20,6 +20,7 @@ code = "https://github.com/apache/superset" [integration] yunohost = '>= 11.2' +helpers_version = "2.1" architectures = "all" multi_instance = true ldap = true diff --git a/scripts/_common.sh b/scripts/_common.sh index c8eee12..3d7f008 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,9 +1,5 @@ #!/bin/bash #================================================= -# COMMON VARIABLES -#================================================= - -#================================================= -# PERSONAL HELPERS +# COMMON VARIABLES AND CUSTOM HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index fbd1410..0faa489 100644 --- a/scripts/backup +++ b/scripts/backup @@ -1,37 +1,28 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# DECLARE DATA AND CONF FILES TO BACKUP -#================================================= -ynh_print_info --message="Declaring files to be backed up..." +ynh_print_info "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 #================================================= -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 #================================================= # 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)." diff --git a/scripts/change_url b/scripts/change_url index 1998d1e..845f0d0 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,27 +1,21 @@ #!/bin/bash -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # 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 #================================================= -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 @@ -32,12 +26,12 @@ ynh_change_url_nginx_config #================================================= # 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 #================================================= -ynh_script_progression --message="Change of URL completed for $app" --last \ No newline at end of file +ynh_script_progression "Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index ae91bba..6e226c2 100644 --- a/scripts/install +++ b/scripts/install @@ -1,10 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= source _common.sh source /usr/share/yunohost/helpers @@ -13,20 +8,20 @@ source /usr/share/yunohost/helpers #================================================= # 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) -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" -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 | 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 | chown $app:$app "$install_dir/superset_config.py" #================================================= # INSTALL APP #================================================= -ynh_script_progression --message="Installing app..." --weight=5 +ynh_script_progression "Installing app..." # Prepare environment python3 -m venv $install_dir/venv @@ -38,15 +33,14 @@ export $environment 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) - ynh_exec_warn_less env $environment superset db upgrade - ynh_exec_warn_less env $environment superset init + ynh_hide_warnings env $environment pip3 install psycopg2 openpyxl python-ldap Pillow sqlalchemy-bigquery apache-superset==$(ynh_app_upstream_version) + ynh_hide_warnings env $environment superset db upgrade + ynh_hide_warnings env $environment superset init deactivate ) 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 #================================================= @@ -56,35 +50,35 @@ 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 +ynh_app_setting_set --key=userdata_db_user --value=$userdata_db_user +ynh_app_setting_set --key=userdata_db_name --value=$userdata_db_name +ynh_app_setting_set --key=userdata_db_pwd --value=$userdata_db_pwd #================================================= # 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 -ynh_add_nginx_config +ynh_config_add_nginx # Create a dedicated systemd config -ynh_add_systemd_config +ynh_config_add_systemd yunohost service add $app --log="/var/log/$app/$app.log" # Use logrotate to manage application logfile(s) -ynh_use_logrotate +ynh_config_add_logrotate #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting app's systemd service..." +ynh_script_progression "Starting app's 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 #================================================= -ynh_script_progression --message="Installation of $app completed" --last +ynh_script_progression "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index bd0b4d3..73d3852 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,45 +1,39 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= source _common.sh source /usr/share/yunohost/helpers #================================================= # 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 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`) -if ynh_exec_warn_less yunohost service status $app >/dev/null +if ynh_hide_warnings yunohost service status $app >/dev/null then - ynh_script_progression --message="Removing $app service integration..." + ynh_script_progression "Removing $app service integration..." yunohost service remove $app 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 : - #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --last +ynh_script_progression "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index dc7b9bc..2fd1c93 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,61 +1,54 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= # 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" - -chown -R $app:$app "$install_dir" +ynh_restore "$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 #================================================= -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_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 #================================================= -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 mkdir -p "/var/log/$app" 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 #================================================= -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 #================================================= -ynh_script_progression --message="Restoration completed for $app" --last +ynh_script_progression "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 9389471..cc7f6f6 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,18 +1,8 @@ #!/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 #================================================= @@ -20,26 +10,26 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= # 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...) #================================================= # 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" -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 | 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 | chown $app:$app "$install_dir/superset_config.py" #================================================= # UPGRADE THE APP APP #================================================= -ynh_script_progression --message="Upgrading app..." --weight=5 +ynh_script_progression "Upgrading app..." # Prepare environment python3 -m venv --upgrade $install_dir/venv @@ -51,37 +41,36 @@ export $environment 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 - ynh_exec_warn_less env $environment superset db upgrade - ynh_exec_warn_less env $environment superset init + ynh_hide_warnings env $environment pip3 install psycopg2 openpyxl python-ldap Pillow sqlalchemy-bigquery apache-superset==$(ynh_app_upstream_version) --upgrade + ynh_hide_warnings env $environment superset db upgrade + ynh_hide_warnings env $environment superset init deactivate ) 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 #================================================= -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" -ynh_use_logrotate --non-append +ynh_config_add_logrotate #================================================= # 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 #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression "Upgrade of $app completed"