summaryrefslogtreecommitdiffstats
path: root/net/meshtasticd/files/meshtasticd.init
blob: 440a5f404213845c329bb61702ddf339711594df (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
37
38
39
40
41
42
43
44
#!/bin/sh /etc/rc.common
#
# SPDX-License-Identifier: GPL-2.0-only

# shellcheck shell=busybox

START=99
STOP=10

USE_PROCD=1
PROG=/usr/bin/meshtasticd

start_service() {
	config_load 'meshtastic'

	local config_dir data_dir

	uci_validate_section 'meshtasticd' 'meshtasticd' 'meshtasticd' \
		'config_dir:string:/etc/meshtasticd' \
		'data_dir:string:/var/lib/meshtasticd'

	local config_file="${config_dir}/config.yaml"
	local config_d_dir="${config_dir}/config.d/*"

	mkdir -p "$data_dir"

	# meshtasticd needs to be run from its data directory
	cd "$data_dir"

	procd_open_instance
	procd_set_param command "$PROG"
	procd_append_param command --fsdir="$data_dir"
	procd_set_param file "$config_file"
	procd_set_param file "$config_d_dir"
	procd_set_param term_timeout 15
	procd_set_param respawn
	procd_set_param stdout 1
	procd_set_param stderr 1
	procd_close_instance
}

service_triggers() {
	procd_add_reload_trigger 'meshtasticd'
}