Merge pull request #221 from OniriCorpe/fix-SC2086

Fix SC2086 and various other shellcheck errors
This commit is contained in:
eric_G 2024-01-10 23:14:41 +01:00 committed by GitHub
commit 9b0f4dcaae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 39 additions and 31 deletions

View file

@ -16,7 +16,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1 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 # 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_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 # END OF SCRIPT

View file

@ -22,7 +22,7 @@ ynh_abort_if_errors
# RETRIEVE ARGUMENTS # 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 # SPECIFIC GETTERS FOR TOML SHORT KEY
@ -33,7 +33,7 @@ get__amount() {
local amount=200 local amount=200
# It's possible to change some properties of the question by overriding it: # It's possible to change some properties of the question by overriding it:
if [ $amount -gt 100 ] if [ "$amount" -gt 100 ]
then then
cat << EOF cat << EOF
style: success style: success
@ -52,13 +52,14 @@ EOF
} }
get__prices() { get__prices() {
local prices = "$(grep "DONATION\['" "$install_dir/settings.py" | sed -r "s@^DONATION\['([^']*)'\]\['([^']*)'\] = '([^']*)'@\1/\2/\3@g" | sed -z 's/\n/,/g;s/,$/\n/')" local prices
prices="$(grep "DONATION\['" "$install_dir/settings.py" | sed -r "s@^DONATION\['([^']*)'\]\['([^']*)'\] = '([^']*)'@\1/\2/\3@g" | sed -z 's/\n/,/g;s/,$/\n/')"
if [ "$prices" == "," ]; if [ "$prices" == "," ];
then then
# Return YNH_NULL if you prefer to not return a value at all. # Return YNH_NULL if you prefer to not return a value at all.
echo YNH_NULL echo YNH_NULL
else else
echo $prices echo "$prices"
fi fi
} }
@ -69,7 +70,7 @@ get__prices() {
validate__publishable_key() { validate__publishable_key() {
# We can imagine here we test if the key is really a 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' echo 'This key seems to be a secret key'
} }
@ -81,10 +82,10 @@ set__prices() {
#--------------------------------------------- #---------------------------------------------
# IMPORTANT: setters are triggered only if a change is detected # IMPORTANT: setters are triggered only if a change is detected
#--------------------------------------------- #---------------------------------------------
for price in $(echo $prices | sed "s/,/ /"); do for price in $(echo "$prices" | sed "s/,/ /"); do
frequency=$(echo $price | cut -d/ -f1) frequency=$(echo "$price" | cut -d/ -f1)
currency=$(echo $price | cut -d/ -f2) currency=$(echo "$price" | cut -d/ -f2)
price_id=$(echo $price | cut -d/ -f3) price_id=$(echo "$price" | cut -d/ -f3)
sed "d/DONATION\['$frequency'\]\['$currency'\]" "$install_dir/settings.py" sed "d/DONATION\['$frequency'\]\['$currency'\]" "$install_dir/settings.py"
echo "DONATION['$frequency']['$currency'] = '$price_id'" >> "$install_dir/settings.py" echo "DONATION['$frequency']['$currency'] = '$price_id'" >> "$install_dir/settings.py"
@ -93,10 +94,10 @@ set__prices() {
#--------------------------------------------- #---------------------------------------------
# IMPORTANT: to be able to upgrade properly, you have to save the value in settings too # IMPORTANT: to be able to upgrade properly, you have to save the value in settings too
#--------------------------------------------- #---------------------------------------------
ynh_app_setting_set --app=$app --key=prices --value="$prices" ynh_app_setting_set --app="$app" --key=prices --value="$prices"
} }
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
ynh_app_config_run $1 ynh_app_config_run "$1"

View file

@ -47,7 +47,7 @@ ynh_setup_source --dest_dir="$install_dir"
# $install_dir will automatically be initialized with some decent # $install_dir will automatically be initialized with some decent
# permission by default ... however, you may need to recursively reapply # permission by default ... however, you may need to recursively reapply
# ownership to all files such as after the ynh_setup_source step # 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 # SYSTEM CONFIGURATION
@ -94,7 +94,7 @@ ynh_add_systemd_config
### - As well as the section "INTEGRATE SERVICE IN YUNOHOST" in the restore script ### - As well as the section "INTEGRATE SERVICE IN YUNOHOST" in the restore script
### - And the section "INTEGRATE SERVICE IN YUNOHOST" in the upgrade 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: ### 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, # 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 # for example if the app is expected to be able to modify its own config
chmod 400 "$install_dir/some_config_file" 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, ### 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) ### 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 ### - And the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the change_url script
# Start a systemd service # 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 # END OF SCRIPT

View file

@ -30,10 +30,10 @@ ynh_script_progression --message="Removing system configurations related to $app
# This should be a symetric version of what happens in the install script # 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`) # 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 then
ynh_script_progression --message="Removing $app service integration..." --weight=1 ynh_script_progression --message="Removing $app service integration..." --weight=1
yunohost service remove $app yunohost service remove "$app"
fi fi
ynh_remove_fail2ban_config ynh_remove_fail2ban_config

View file

@ -20,7 +20,7 @@ ynh_restore_file --origin_path="$install_dir"
# $install_dir will automatically be initialized with some decent # $install_dir will automatically be initialized with some decent
# permissions by default ... however, you may need to recursively reapply # permissions by default ... however, you may need to recursively reapply
# ownership to all files such as after the ynh_setup_source step # 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 # RESTORE THE DATA DIRECTORY
@ -30,7 +30,14 @@ ynh_script_progression --message="Restoring the data directory..." --weight=1
ynh_restore_file --origin_path="$data_dir" --not_mandatory ynh_restore_file --origin_path="$data_dir" --not_mandatory
# (Same as for install dir) # (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
#================================================= #=================================================
# RESTORE SYSTEM CONFIGURATIONS # RESTORE SYSTEM CONFIGURATIONS
@ -44,9 +51,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/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file --origin_path="/etc/systemd/system/$app.service" 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" ynh_restore_file --origin_path="/etc/logrotate.d/$app"
@ -76,8 +83,8 @@ ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 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... # 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="$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="php$phpversion-fpm" --action=reload
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload

View file

@ -60,7 +60,7 @@ upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1 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...) # "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...)
@ -79,7 +79,7 @@ fi
# $install_dir will automatically be initialized with some decent # $install_dir will automatically be initialized with some decent
# permissions by default ... however, you may need to recursively reapply # permissions by default ... however, you may need to recursively reapply
# ownership to all files such as after the ynh_setup_source step # 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 # REAPPLY SYSTEM CONFIGURATIONS
@ -94,7 +94,7 @@ ynh_add_nginx_config
ynh_add_systemd_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 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, # 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 # for example if the app is expected to be able to modify its own config
chmod 400 "$install_dir/some_config_file" 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, ### 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) ### 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_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 # END OF SCRIPT