965608b5ef5f3327d2a5a525d8dab4d21da9b13c
[ais.git] / etc / init.sh
1 #!/bin/sh
2 ### BEGIN INIT INFO
3 # Provides:          ais
4 # Required-Start:    apache2 postgresql
5 # Required-Stop:     apache2 postgresql
6 # Default-Start:     2 3 4 5
7 # Default-Stop:      0 1 6
8 # Short-Description: AIS server
9 # Description:       Start/stop the AIS aquisition daemon and the job runner
10 ### END INIT INFO
11 #
12 # XXX Server to installed with:
13 # ln -s THISFILE /etc/init.d/ais
14 # update-rc.d ais defaults
15
16 set -e
17
18 . /lib/lsb/init-functions
19
20 case $1 in
21     start)
22         [ -r /etc/ais/database ] && RUN_PARAMS=--db
23                 log_daemon_msg "Starting AIS acquisition"
24                 if sudo -u nirgal python -m ais.inputs.run $RUN_PARAMS
25                 then
26                         log_success_msg ais.inputs.run
27                 else
28                         log_failure_msg failed
29                 fi
30                 log_daemon_msg "Starting AIS job runner"
31                 if [ -r /etc/ais/database ]
32                 then
33                         if sudo -u nirgal python -m ais.jobrunner --debug
34                         then
35                                 log_success_msg ais.jobrunner
36                         else
37                                 log_failure_msg failed
38                         fi
39                 else
40                         log_warning_msg "Disabled because there is no /etc/ais/database"
41                 fi
42     ;;
43     stop)
44         log_success_msg "Not implemented"
45         exit 1
46     ;;
47     *)
48         log_success_msg "Usage: ais.sh {start|stop}"
49         exit 1
50     ;;
51 esac