lede-packages-rs

git clone git://archive.git.mtrnord.blog/MTRNord/lede-packages-rs.git
Log | Files | Refs | README | LICENSE

gpsd.init (787B)


      1 #!/bin/sh /etc/rc.common
      2 # Copyright (C) 2009-2011 OpenWrt.org
      3 START=50
      4 
      5 USE_PROCD=1
      6 PROG=/usr/sbin/gpsd
      7 NAME=gpsd
      8 
      9 validate_section_gpsd()
     10 {
     11 	uci_validate_section gpsd gpsd "${1}" \
     12 		'enabled:bool:1' \
     13 		'device:string' \
     14 		'listen_globally:bool:0' \
     15 		'port:port:2947'
     16 }
     17 
     18 gpsd_instance()
     19 {
     20 	local device enabled listen_globally port
     21 
     22 	validate_section_gpsd "${1}" || {
     23 		echo "validation failed"
     24 		return 1
     25 	}
     26 
     27 	[ "${enabled}" = "0" ] && return 1
     28 
     29 	procd_open_instance
     30 	procd_set_param command "$PROG" -N -n
     31 
     32 	[ "${listen_globally}" -ne 0 ] && procd_append_param command -G
     33 	procd_append_param command -S "${port}"
     34 	procd_append_param command "${device}"
     35 	procd_set_param respawn
     36 
     37 	procd_close_instance
     38 }
     39 
     40 start_service()
     41 {
     42 	config_load "${NAME}"
     43 	config_foreach gpsd_instance gpsd
     44 }