Skip to content

Commit d37dcc2

Browse files
authored
Merge pull request qualcomm-linux#359 from smuppand/Reboot_health_check
shellcheck: fix POSIX and direct command checks in reboot health setup
2 parents 6ce4990 + b3ffc2e commit d37dcc2

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

Runner/suites/Kernel/Baseport/Reboot_health_check/setup_systemd.sh

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66
set -x
77
chmod 777 -R /var/common/*
88
__RUNNER_UTILS_BIN_DIR="/var/common"
9+
910
# Find test case path by name
1011
find_test_case_bin_by_name() {
11-
local test_name="$1"
12-
find $__RUNNER_UTILS_BIN_DIR -type f -iname "$test_name" 2>/dev/null
12+
test_name="$1"
13+
find "$__RUNNER_UTILS_BIN_DIR" -type f -iname "$test_name" 2>/dev/null
1314
}
1415

1516
# Define variables
1617
APP_PATH=$(find_test_case_bin_by_name "reboot_health_check")
17-
APP_DIR=$(readlink -f $APP_PATH)
18+
APP_DIR=$(readlink -f "$APP_PATH")
1819
SERVICE_FILE="/etc/systemd/system/reboot-health.service"
1920

2021
# Colors for console output
@@ -47,7 +48,7 @@ chmod +x "$APP_PATH"
4748
log_info "Made app binary executable: $APP_PATH"
4849

4950
# Create systemd service file
50-
cat << EOF > "$SERVICE_FILE"
51+
if cat <<EOF > "$SERVICE_FILE"
5152
[Unit]
5253
Description=Reboot Health Check Service
5354
After=default.target
@@ -63,8 +64,7 @@ RestartSec=5s
6364
[Install]
6465
WantedBy=multi-user.target
6566
EOF
66-
67-
if [ $? -eq 0 ]; then
67+
then
6868
log_info "Created systemd service file: $SERVICE_FILE"
6969
else
7070
log_error "Failed to create systemd service file!"
@@ -76,16 +76,14 @@ systemctl daemon-reload
7676
log_info "Systemd daemon reloaded."
7777

7878
# Enable and start service
79-
systemctl enable reboot-health.service
80-
if [ $? -eq 0 ]; then
79+
if systemctl enable reboot-health.service; then
8180
log_info "Service enabled at boot."
8281
else
8382
log_error "Failed to enable service!"
8483
exit 1
8584
fi
8685

87-
systemctl start reboot-health.service
88-
if [ $? -eq 0 ]; then
86+
if systemctl start reboot-health.service; then
8987
log_success "Service started successfully!"
9088
else
9189
log_error "Failed to start service!"

0 commit comments

Comments
 (0)