Automatically adds --db to ais.inputs.run if and only if /etc/ais/databse exists
authorJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Wed, 9 May 2012 15:19:26 +0000 (15:19 +0000)
committerJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Wed, 9 May 2012 15:19:26 +0000 (15:19 +0000)
Don't try to run jobrunner if that file doesn't exists

etc/init.sh

index c3f5cf4cdb636031bcfaf2cd8be6a99ac8902b50..965608b5ef5f3327d2a5a525d8dab4d21da9b13c 100755 (executable)
@@ -19,8 +19,26 @@ set -e
 
 case $1 in
     start)
-        sudo -u nirgal python -m ais.inputs.run
-        sudo -u nirgal python -m ais.jobrunner --debug
+        [ -r /etc/ais/database ] && RUN_PARAMS=--db
+               log_daemon_msg "Starting AIS acquisition"
+               if sudo -u nirgal python -m ais.inputs.run $RUN_PARAMS
+               then
+                       log_success_msg ais.inputs.run
+               else
+                       log_failure_msg failed
+               fi
+               log_daemon_msg "Starting AIS job runner"
+               if [ -r /etc/ais/database ]
+               then
+                       if sudo -u nirgal python -m ais.jobrunner --debug
+                       then
+                               log_success_msg ais.jobrunner
+                       else
+                               log_failure_msg failed
+                       fi
+               else
+                       log_warning_msg "Disabled because there is no /etc/ais/database"
+               fi
     ;;
     stop)
         log_success_msg "Not implemented"