ugps: Add option disabled
[openwrt/openwrt.git] / package / utils / ugps / files / ugps.init
1 #!/bin/sh /etc/rc.common
2 # Copyright (c) 2014 OpenWrt.org
3
4 START=80
5
6 USE_PROCD=1
7 PROG=/usr/sbin/ugps
8
9 service_triggers() {
10 procd_add_reload_trigger gps
11 }
12
13 start_service() {
14 local tty="$(uci get gps.@gps[-1].tty)"
15 local atime="$(uci get gps.@gps[-1].adjust_time)"
16 local disabled="$(uci get gps.@gps[-1].disabled || echo 0)"
17
18 [ "$disabled" == "0" ] || return
19
20 [ -c "$tty" ] || {
21 tty="/dev/$tty"
22 [ -c "$tty" ] || return
23 }
24
25 procd_open_instance
26 procd_set_param command "$PROG"
27 [ "$atime" -eq 0 ] || procd_append_param command "-a"
28 procd_append_param command "$tty"
29 procd_set_param respawn
30 procd_close_instance
31 }