From a9eca3e1d594f60d93064591f2290cb44f9bdf63 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Sat, 30 Dec 2023 03:02:42 +0100 Subject: [PATCH] fix SC2086 --- scripts/change_url | 4 ++-- scripts/config | 20 ++++++++++---------- scripts/install | 8 ++++---- scripts/remove | 4 ++-- scripts/restore | 14 +++++++------- scripts/upgrade | 10 +++++----- 6 files changed, 30 insertions(+), 30 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index f0964a6..235a1f2 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -16,7 +16,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_script_progression --message="Stopping a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # MODIFY URL IN NGINX CONF @@ -38,7 +38,7 @@ ynh_change_url_nginx_config #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" #================================================= # END OF SCRIPT diff --git a/scripts/config b/scripts/config index 711fd16..0024ec7 100644 --- a/scripts/config +++ b/scripts/config @@ -22,7 +22,7 @@ ynh_abort_if_errors # RETRIEVE ARGUMENTS #================================================= -install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +install_dir=$(ynh_app_setting_get --app="$app" --key=install_dir) #================================================= # SPECIFIC GETTERS FOR TOML SHORT KEY @@ -33,7 +33,7 @@ get__amount() { local amount = 200 # It's possible to change some properties of the question by overriding it: - if [ $amount -gt 100 ] + if [ "$amount" -gt 100 ] then cat << EOF style: success @@ -58,7 +58,7 @@ get__prices() { # Return YNH_NULL if you prefer to not return a value at all. echo YNH_NULL else - echo $prices + echo "$prices" fi } @@ -69,7 +69,7 @@ get__prices() { validate__publishable_key() { # We can imagine here we test if the key is really a publishable key - (is_secret_key $publishable_key) && + (is_secret_key "$publishable_key") && echo 'This key seems to be a secret key' } @@ -81,10 +81,10 @@ set__prices() { #--------------------------------------------- # IMPORTANT: setters are triggered only if a change is detected #--------------------------------------------- - for price in $(echo $prices | sed "s/,/ /"); do - frequency=$(echo $price | cut -d/ -f1) - currency=$(echo $price | cut -d/ -f2) - price_id=$(echo $price | cut -d/ -f3) + for price in $(echo "$prices" | sed "s/,/ /"); do + frequency=$(echo "$price" | cut -d/ -f1) + currency=$(echo "$price" | cut -d/ -f2) + price_id=$(echo "$price" | cut -d/ -f3) sed "d/DONATION\['$frequency'\]\['$currency'\]" "$install_dir/settings.py" echo "DONATION['$frequency']['$currency'] = '$price_id'" >> "$install_dir/settings.py" @@ -93,10 +93,10 @@ set__prices() { #--------------------------------------------- # IMPORTANT: to be able to upgrade properly, you have to save the value in settings too #--------------------------------------------- - ynh_app_setting_set $app prices $prices + ynh_app_setting_set "$app" prices "$prices" } #================================================= # GENERIC FINALIZATION #================================================= -ynh_app_config_run $1 +ynh_app_config_run "$1" diff --git a/scripts/install b/scripts/install index 8c717e2..bf1a40a 100755 --- a/scripts/install +++ b/scripts/install @@ -47,7 +47,7 @@ ynh_setup_source --dest_dir="$install_dir" # $install_dir will automatically be initialized with some decent # permission by default ... however, you may need to recursively reapply # ownership to all files such as after the ynh_setup_source step -chown -R $app:www-data "$install_dir" +chown -R "$app:www-data" "$install_dir" #================================================= # SYSTEM CONFIGURATION @@ -94,7 +94,7 @@ ynh_add_systemd_config ### - As well as the section "INTEGRATE SERVICE IN YUNOHOST" in the restore script ### - And the section "INTEGRATE SERVICE IN YUNOHOST" in the upgrade script -yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" +yunohost service add "$app" --description="A short description of the app" --log="/var/log/$app/$app.log" ### Additional options starting with 3.8: ### @@ -151,7 +151,7 @@ ynh_add_config --template="some_config_file" --destination="$install_dir/some_co # You may need to use chmod 600 instead of 400, # for example if the app is expected to be able to modify its own config chmod 400 "$install_dir/some_config_file" -chown $app:$app "$install_dir/some_config_file" +chown "$app:$app" "$install_dir/some_config_file" ### For more complex cases where you want to replace stuff using regexes, ### you shoud rely on ynh_replace_string (which is basically a wrapper for sed) @@ -189,7 +189,7 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1 ### - And the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the change_url script # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index 097c3f4..3a85218 100755 --- a/scripts/remove +++ b/scripts/remove @@ -32,10 +32,10 @@ ynh_script_progression --message="Removing system configurations related to $app # This should be a symetric version of what happens in the install script # 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_exec_warn_less yunohost service status "$app" >/dev/null then ynh_script_progression --message="Removing $app service integration..." --weight=1 - yunohost service remove $app + yunohost service remove "$app" fi ynh_remove_systemd_config diff --git a/scripts/restore b/scripts/restore index e60cb7a..783f655 100755 --- a/scripts/restore +++ b/scripts/restore @@ -20,7 +20,7 @@ ynh_restore_file --origin_path="$install_dir" # $install_dir will automatically be initialized with some decent # permissions by default ... however, you may need to recursively reapply # ownership to all files such as after the ynh_setup_source step -chown -R $app:www-data "$install_dir" +chown -R "$app:www-data" "$install_dir" #================================================= # RESTORE THE DATA DIRECTORY @@ -30,14 +30,14 @@ ynh_script_progression --message="Restoring the data directory..." --weight=1 ynh_restore_file --origin_path="$data_dir" --not_mandatory # (Same as for install dir) -chown -R $app:www-data "$data_dir" +chown -R "$app:www-data" "$data_dir" #================================================= # RESTORE THE MYSQL DATABASE #================================================= ynh_script_progression --message="Restoring the MySQL database..." --weight=1 -ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql +ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql #================================================= # RESTORE SYSTEM CONFIGURATIONS @@ -53,9 +53,9 @@ ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/systemd/system/$app.service" -systemctl enable $app.service --quiet +systemctl enable "$app.service" --quiet -yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" +yunohost service add "$app" --description="A short description of the app" --log="/var/log/$app/$app.log" ynh_restore_file --origin_path="/etc/logrotate.d/$app" @@ -76,8 +76,8 @@ ynh_restore_file --origin_path="/etc/$app/" ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 # Typically you only have either $app or php-fpm but not both at the same time... -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=php$phpversion-fpm --action=reload +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="php$phpversion-fpm" --action=reload ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index ddb8ba3..45f990a 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -60,7 +60,7 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Stopping a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...) @@ -79,7 +79,7 @@ fi # $install_dir will automatically be initialized with some decent # permissions by default ... however, you may need to recursively reapply # ownership to all files such as after the ynh_setup_source step -chown -R $app:www-data "$install_dir" +chown -R "$app:www-data" "$install_dir" #================================================= # REAPPLY SYSTEM CONFIGURATIONS @@ -94,7 +94,7 @@ ynh_add_nginx_config ynh_add_systemd_config -yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" +yunohost service add "$app" --description="A short description of the app" --log="/var/log/$app/$app.log" ynh_use_logrotate --non-append @@ -118,7 +118,7 @@ ynh_add_config --template="some_config_file" --destination="$install_dir/some_co # You may need to use chmod 600 instead of 400, # for example if the app is expected to be able to modify its own config chmod 400 "$install_dir/some_config_file" -chown $app:$app "$install_dir/some_config_file" +chown "$app:$app" "$install_dir/some_config_file" ### For more complex cases where you want to replace stuff using regexes, ### you shoud rely on ynh_replace_string (which is basically a wrapper for sed) @@ -132,7 +132,7 @@ chown $app:$app "$install_dir/some_config_file" #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" #================================================= # END OF SCRIPT