66set -x
77chmod 777 -R /var/common/*
88__RUNNER_UTILS_BIN_DIR=" /var/common"
9+
910# Find test case path by name
1011find_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
1617APP_PATH=$( find_test_case_bin_by_name " reboot_health_check" )
17- APP_DIR=$( readlink -f $APP_PATH )
18+ APP_DIR=$( readlink -f " $APP_PATH " )
1819SERVICE_FILE=" /etc/systemd/system/reboot-health.service"
1920
2021# Colors for console output
@@ -47,7 +48,7 @@ chmod +x "$APP_PATH"
4748log_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]
5253Description=Reboot Health Check Service
5354After=default.target
@@ -63,8 +64,7 @@ RestartSec=5s
6364[Install]
6465WantedBy=multi-user.target
6566EOF
66-
67- if [ $? -eq 0 ]; then
67+ then
6868 log_info " Created systemd service file: $SERVICE_FILE "
6969else
7070 log_error " Failed to create systemd service file!"
@@ -76,16 +76,14 @@ systemctl daemon-reload
7676log_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."
8281else
8382 log_error " Failed to enable service!"
8483 exit 1
8584fi
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!"
9088else
9189 log_error " Failed to start service!"
0 commit comments