157043cc283ee1be77a0f6393e02baf89b64bd3b
[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
17 [ -c "$tty" ] || {
18 tty="/dev/$tty"
19 [ -c "$tty" ] || return
20 }
21
22 procd_open_instance
23 procd_set_param command "$PROG"
24 [ "$atime" -eq 0 ] || procd_append_param command "-a"
25 procd_append_param command "$tty"
26 procd_set_param respawn
27 procd_close_instance
28 }