Skip to content

Commit

Permalink
MT#60865 Fix shellcheck script issues
Browse files Browse the repository at this point in the history
As reported at https://jenkins.mgm.sipwise.com/job/ngcpcfg-tap-test/4544/
when building against Debian/trixie

Furthermore fix SC2166 + SC2086 issues within helper/check-for-mysql
as reported by manual shellcheck v0.10.0 runs.

Change-Id: Ic9be0dbc8ef4a501cf3b6e62522574da72f85c99
  • Loading branch information
mika committed Sep 10, 2024
1 parent 125ab4c commit eb1cd98
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
8 changes: 4 additions & 4 deletions helper/check-for-mysql
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ else
CONF="/etc/mysql/my.cnf"
fi

if [ $COUNT -le 0 ] ; then
if [ "$COUNT" -le 0 ] ; then
echo "Usage: $0 <number_of_seconds> [<mysqlid>]" >&2
exit 1
fi
Expand Down Expand Up @@ -45,16 +45,16 @@ mysqld_status () {
ps_alive=1
fi

if [ "$1" = "check_alive" -a $ping_alive = 1 ] ||
[ "$1" = "check_dead" -a $ping_alive = 0 -a $ps_alive = 0 ]; then
if { [ "$1" = "check_alive" ] && [ "$ping_alive" = 1 ]; } ||
{ [ "$1" = "check_dead" ] && [ "$ping_alive" = 0 ] && [ "$ps_alive" = 0 ]; }; then
return 0
fi

return 1
}

printf "Checking MySQL service status (for a maximum of %s seconds): " "$COUNT"
for _ in $(seq 1 $COUNT) ; do
for _ in $(seq 1 "$COUNT") ; do
if mysqld_status check_alive warn; then
printf "available.\n"
exit 0
Expand Down
3 changes: 3 additions & 0 deletions scripts/services
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ find_instance() {
local target

# get rid of "./" and "//"
# shellcheck disable=SC2001
service_file=$(echo "$1" | sed -e 's_\./_/_g ; s_//_/_g')

for instance in "${INSTANCES[@]}"; do
Expand Down Expand Up @@ -228,7 +229,9 @@ find_changed_instance_services() {
local target_file

# get rid of "./" and "//"
# shellcheck disable=SC2001
file=$(echo "$1"| sed -e 's_\./_/_g ; s_//_/_g')
# shellcheck disable=SC2001
dir=$(echo "$2"| sed -e 's_\./_/_g ; s_//_/_g')

for instance in "${INSTANCES[@]}"; do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh
echo "INSTANCE_NAME:${INSTANCE_NAME:-}" > \
${OUTPUT_DIRECTORY:-/tmp}/ngcpcfg.service${INSTANCE_NAME:-}
"${OUTPUT_DIRECTORY:-/tmp}/ngcpcfg.service${INSTANCE_NAME:-}"
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh
echo "INSTANCE_NAME:${INSTANCE_NAME:-}" > \
${OUTPUT_DIRECTORY:-/tmp}/ngcpcfg.service${INSTANCE_NAME:-}
"${OUTPUT_DIRECTORY:-/tmp}/ngcpcfg.service${INSTANCE_NAME:-}"

0 comments on commit eb1cd98

Please sign in to comment.