From e4702b0b6365d4d457f8cad3986f0854e8adc50e Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sun, 22 Jan 2023 10:54:32 +0100 Subject: [PATCH] Fix linter --- manifest.json | 5 ++--- scripts/backup | 19 +++++++++---------- scripts/install | 13 +++++++------ scripts/restore | 8 +++++--- scripts/upgrade | 14 ++++++-------- 5 files changed, 29 insertions(+), 30 deletions(-) diff --git a/manifest.json b/manifest.json index 46146c9..7658d31 100644 --- a/manifest.json +++ b/manifest.json @@ -21,7 +21,7 @@ "email": "jean-baptiste@holcroft.fr" }], "requirements": { - "yunohost": ">= 4.1.2" + "yunohost": ">= 11.0.9" }, "multi_instance": true, "services": [ @@ -31,8 +31,7 @@ "install" : [ { "name": "domain", - "type": "domain", - "example": "domain.org" + "type": "domain" }, { "name": "path", diff --git a/scripts/backup b/scripts/backup index 5a22674..24fb748 100644 --- a/scripts/backup +++ b/scripts/backup @@ -32,29 +32,28 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_print_info --message="Backing up the main app directory..." + ynh_backup --src_path="$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_print_info --message="Backing up nginx web server configuration..." -ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# BACKUP THE MYSQL DATABASE -#================================================= -ynh_print_info --message="Backing up the MySQL database..." -ynh_mysql_dump_db --database="$db_name" > db.sql +ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # SPECIFIC BACKUP #================================================= -# BACKUP THE systemd FILES -ynh_print_info --message="Backing up systemd..." ynh_backup --src_path="/etc/systemd/system/$app.service" +#================================================= +# BACKUP THE MYSQL DATABASE +#================================================= +ynh_print_info --message="Backing up the MySQL database..." + +ynh_mysql_dump_db --database="$db_name" > db.sql + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/install b/scripts/install index 107aa82..8613238 100644 --- a/scripts/install +++ b/scripts/install @@ -49,12 +49,11 @@ ynh_app_setting_set --app $app --key web_port --value $port #================================================= # STANDARD MODIFICATIONS -#================================================= - #================================================= # INSTALL DEPENDENCIES #================================================= ynh_script_progression --message="Installing dependencies..." --weight=7 + ynh_install_app_dependencies $pkg_dependencies #================================================= @@ -72,7 +71,6 @@ ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name #================================================= ynh_script_progression --message="Installing sources files..." --weight=10 - ynh_app_setting_set --app=$app --key=final_path --value=$final_path install_sources @@ -83,7 +81,8 @@ install_sources #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring nginx" +ynh_script_progression --message="Configuring NGINX" + if [ "$path_url" == "/" ] then # $finalnginxconf comes from ynh_add_nginx_config @@ -98,15 +97,16 @@ ynh_add_nginx_config 'is_subpath' # CREATE DEDICATED USER #================================================= ynh_script_progression --message="Configuring system user..." + # Create a system user ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # SPECIFIC SETUP #================================================= +ynh_script_progression --message="Configuring application..." # create config file syncserver.ini -ynh_script_progression --message="Configuring application..." ynh_add_config --template="syncserver.ini" --destination="$final_path/syncserver.ini" # Configure init script @@ -135,14 +135,15 @@ set_permissions # SETUP SSOWAT #================================================= ynh_script_progression --message="Configuring permissions" -# accessible by everyone (authentification is done by firefox accounts) +# accessible by everyone (authentification is done by firefox accounts) ynh_permission_update --permission=main --add=visitors --protected=true --show_tile=true #================================================= # RELOAD Services #================================================= ynh_script_progression --message="Restart services..." + ynh_systemd_action --service_name=nginx --action=reload ynh_script_progression --message="Starting $app services..." --weight=3 diff --git a/scripts/restore b/scripts/restore index e42080b..cda9942 100644 --- a/scripts/restore +++ b/scripts/restore @@ -30,21 +30,23 @@ db_user=$db_name #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= + test ! -d $final_path \ || ynh_die --message="There is already a directory: $final_path " #================================================= # STANDARD RESTORATION STEPS #================================================= +ynh_script_progression --message="Restoring files..." --weight=5 # Restore all config and data -ynh_script_progression --message="Restoring files..." --weight=5 ynh_restore #================================================= # RECREATE THE DEDICATED USER #================================================= ynh_script_progression --message="Recreating the dedicated system user..." + ynh_system_user_create --username="$app" usermod --append --groups www-data "$app" @@ -77,8 +79,8 @@ ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./ #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= - ynh_script_progression --message="Reloading services..." --weight=3 + systemctl daemon-reload systemctl enable --quiet $app.service yunohost service add "$app" @@ -88,8 +90,8 @@ yunohost service add "$app" #================================================= # RELOAD NGINX AND UWSGI #================================================= - ynh_script_progression --message="Starting pgadmin services..." --weight=3 + ynh_systemd_action --service_name "$app.service" \ --line_match "Booting worker with pid" --log_path "systemd" ynh_systemd_action --service_name=nginx --action=reload -t 20 diff --git a/scripts/upgrade b/scripts/upgrade index fa25c9c..91ecca3 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -28,7 +28,6 @@ db_user=$app #================================================= # CHECK VERSION #================================================= -ynh_print_info --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) @@ -113,21 +112,19 @@ fi #================================================= # STANDARD UPGRADE STEPS -#================================================= - - #================================================= # UPGRADE DEPENDENCIES #================================================= ynh_script_progression --message="Upgrading dependencies..." + ynh_install_app_dependencies $pkg_dependencies #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_script_progression --message="Upgrading source files..." --weight=6 # Download, check integrity, uncompress and patch the source from app.src -ynh_script_progression --message="Upgrading source files..." --weight=6 if [ -e $final_path/syncserver.ini ]; then config_backup="$(cat $final_path/syncserver.ini)" install_sources @@ -139,7 +136,8 @@ fi #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring nginx" +ynh_script_progression --message="Configuring NGINX" + if [ "$path_url" == "/" ] then # $finalnginxconf comes from ynh_add_nginx_config @@ -159,9 +157,9 @@ ynh_system_user_create --username="$app" #================================================= # SPECIFIC UPGRADE #================================================= -# SETUP UWSGI ynh_script_progression --message="Configuring application..." +# SETUP UWSGI # create config file syncserver.ini ynh_script_progression --message="Configuring application..." ynh_add_config --template="syncserver.ini" --destination="$final_path/syncserver.ini" @@ -187,8 +185,8 @@ set_permissions #================================================= # Migrate legacy permissions to new system #================================================= - ynh_script_progression --message="Set permissions..." + if ynh_legacy_permissions_exists then ynh_legacy_permissions_delete_all