aeb606be1e14865e5df9c44513109e0e919b4ea7
[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 set -e
13
14 . /lib/lsb/init-functions
15
16 case $1 in
17     start)
18                 [ -r /etc/ais/database ] && RUN_PARAMS=--db
19                 log_daemon_msg "Starting AIS acquisition"
20                 if sudo -u ais python -m ais.inputs.run $RUN_PARAMS
21                 then
22                         log_success_msg ais.inputs.run
23                 else
24                         log_failure_msg failed
25                 fi
26                 log_daemon_msg "Starting AIS job runner"
27                 if [ -r /etc/ais/database ]
28                 then
29                         if sudo -u ais python -m ais.jobrunner --debug
30                         then
31                                 log_success_msg ais.jobrunner
32                         else
33                                 log_failure_msg failed
34                         fi
35                 else
36                         log_warning_msg "Disabled because there is no /etc/ais/database"
37                 fi
38     ;;
39     stop|restart|force-reload)
40         log_success_msg "Not implemented"
41         exit 1
42     ;;
43     *)
44         log_success_msg "Usage: ais.sh {start|stop}"
45         exit 1
46     ;;
47 esac