Files
packages/utils/gpsd/files/gpsd.init
Florian Eckert ace9f160ce gpsd: migrate option device to a list devices
More than one device can be added to the gpsd at startup. Currently the gpsd
service start script in OpenWrt treats this as an option with only one value.
To allow multiple devices to be specified, the uci 'option device' must be
removed and a new uci 'list devices' is added.

This change means that several devices can be specified at gpsd start with
the new uci 'list devices' configuration.

Running configurations in the field are migrated by a migration script.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2025-02-28 08:13:00 +01:00

67 lines
1.2 KiB
Bash

#!/bin/sh /etc/rc.common
# Copyright (C) 2009-2011 OpenWrt.org
START=50
USE_PROCD=1
PROG=/usr/sbin/gpsd
NAME=gpsd
LOG_LEVEL="0"
validate_section_gpsd()
{
uci_load_validate gpsd gpsd "$1" "$2" \
'enabled:bool:1' \
'readonly:bool:1' \
'devices:list(string)' \
'listen_globally:bool:0' \
'port:port:2947'
}
gpsd_instance()
{
local device
[ "$2" = 0 ] || {
echo "validation failed"
return 1
}
[ "$enabled" = "0" ] && return 1
procd_open_instance
procd_set_param command "$PROG" -N -n
[ "$listen_globally" -ne 0 ] && procd_append_param command -G
procd_append_param command -S "$port"
procd_append_param command -D "$LOG_LEVEL"
[ "$readonly" = "1" ] && procd_append_param command -b
procd_append_param command -F /var/run/gpsd.sock
for device in $devices; do
procd_append_param command "$device"
done
procd_set_param respawn
procd_close_instance
}
start_service()
{
config_load "$NAME"
config_foreach validate_section_gpsd gpsd gpsd_instance
}
service_triggers() {
procd_add_reload_trigger "$NAME"
procd_add_validation validate_section_gpsd
}
service_started() {
local enabled
enabled="$(uci_get gpsd core enabled 0)"
[ "$enabled" = "0" ] && return
env -i ACTION="STARTED" /sbin/hotplug-call gpsd
}