alfred: add alfred 2013.3.0 to feed
[feed/routing.git] / alfred / files / alfred.init
1 #!/bin/sh /etc/rc.common
2
3 #
4 # Copyright (C) 2013 OpenWrt.org
5 #
6 # This is free software, licensed under the GNU General Public License v2.
7 # See /LICENSE for more information.
8 #
9
10 START=99
11 STOP=99
12 alfred_args=""
13 vis_args=""
14 pid_file_alfred="/var/run/alfred.pid"
15 pid_file_vis="/var/run/vis.pid"
16 enable=0
17 vis_enable=0
18 SERVICE_DAEMONIZE=1
19 SERVICE_WRITE_PID=1
20
21 alfred_start()
22 {
23 local args=""
24 local section="$1"
25 local disabled interface mode batmanif
26
27 # check if section is disabled
28 config_get_bool disabled "$section" disabled 0
29 [ $disabled = 0 ] || return 1
30
31 args=""
32
33 config_get interface "$section" interface
34 append args "-i $interface"
35
36 config_get mode "$section" mode
37 [ "$mode" = "master" ] && append args "-m"
38
39 config_get batmanif "$section" batmanif
40 append args "-b $batmanif"
41
42 append alfred_args "$args"
43 enable=1
44
45 config_get_bool start_vis "$section" start_vis 0
46 if [ "$start_vis" = 1 ] && [ -x /usr/sbin/vis ]; then
47 vis_enable=1
48 append vis_args "-i $batmanif -s"
49 fi
50
51 return 0
52 }
53
54 start()
55 {
56 config_load "alfred"
57 config_foreach alfred_start alfred
58
59 if [ "$enable" = "0" ]; then
60 exit 0
61 fi
62 echo "${initscript}: starting alfred"
63 SERVICE_PID_FILE="$pid_file_alfred"
64 service_start /usr/sbin/alfred ${alfred_args}
65
66 if [ "$vis_enable" = "0" ]; then
67 exit 0
68 fi
69 echo "${initscript}: starting vis"
70 SERVICE_PID_FILE="$pid_file_vis"
71 service_start /usr/sbin/vis ${vis_args}
72 }
73
74 stop()
75 {
76 SERVICE_PID_FILE="$pid_file_alfred"
77 service_stop /usr/sbin/alfred
78 SERVICE_PID_FILE="$pid_file_vis"
79 [ -x /usr/sbin/vis ] && service_stop /usr/sbin/vis
80
81 }