From 90c8eef146348b5571bd21ae93da6e80eca1e00b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20J=C3=A4ggi?= Date: Fri, 27 Mar 2020 08:46:45 +0100 Subject: [PATCH] gnss-config: added return code if gpsd restart fails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Script returns 7 if gpsd restart failed. Used for lava testing. BugzID: 62045 Signed-off-by: Tobias Jäggi --- .../gnss-config/files/gnss-config.sh | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/recipes-connectivity/gnss-config/files/gnss-config.sh b/recipes-connectivity/gnss-config/files/gnss-config.sh index 78376d0..383541a 100755 --- a/recipes-connectivity/gnss-config/files/gnss-config.sh +++ b/recipes-connectivity/gnss-config/files/gnss-config.sh @@ -13,6 +13,7 @@ # 4 saving to flash failed # 5 baud rate specified in $CONFIG_FILE not supported by $DEVICE_NAME # 6 set tty baud rate was not successful +# 7 failed to restart gpsd # static variables DEVICE_NAME="NEO-M8L" @@ -164,6 +165,15 @@ write_config_out(){ echo "Supported Augmentation Services: $augment_service" >> $CONFIG_OUT_FILE } +restart_gpsd(){ + if [ "$RESTART_GPSD" -eq "1" ]; then + systemctl start gpsd + if [ "$?" -ne "0" ]; then + exit 7 # failed to restart gpsd + fi + fi +} + # start of main # check if script was launched by systemd @@ -239,9 +249,7 @@ if br_receiver="$(poll_baud_rate_receiver "$DESIRED_BAUD_RATE")";then exit 6 fi write_config_out - if [ "$RESTART_GPSD" -eq "1" ]; then - systemctl start gpsd - fi + restart_gpsd # script can exit exit 0 # baud rate of receiver is already matching $DESIRED_BAUD_RATE else @@ -330,10 +338,6 @@ else fi write_config_out - -# TODO: verify or error handling -if [ "$RESTART_GPSD" -eq "1" ]; then - systemctl start gpsd -fi +restart_gpsd exit 0 # successfully changed baud rate to $DESIRED_BAUD_RATE specified in $CONFIG_FILE