summaryrefslogtreecommitdiffstats
path: root/package/utils/ugps/files/ugps.init
blob: 77c36030667e5493ab64e31d6350bcb1cf383014 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/sh /etc/rc.common
# Copyright (c) 2014 OpenWrt.org

START=80

USE_PROCD=1
PROG=/usr/sbin/ugps

service_triggers() {
	procd_add_reload_trigger gps
}

start_service() {
	local tty="$(uci get gps.@gps[-1].tty)"
	local atime="$(uci get gps.@gps[-1].adjust_time)"
	local disabled="$(uci get gps.@gps[-1].disabled || echo 0)"

	[ "$disabled" == "0" ] || return
	[ "$tty" ] || return

	case "$tty" in
		"/"*)
			true
			;;
		*)
			tty="/dev/$tty"
			;;
	esac

	procd_open_instance
	procd_set_param command "$PROG"
	[ "$atime" -eq 0 ] || procd_append_param command "-a"
	procd_append_param command "$tty"
	procd_set_param respawn
	procd_close_instance
}