Skip to content

Commit ca3b038

Browse files
committed
Add support for sevice start wrapper
1 parent 169caf1 commit ca3b038

File tree

6 files changed

+252
-2
lines changed

6 files changed

+252
-2
lines changed

bin/meshtasticd-start.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env sh
2+
3+
INSTANCE=$1
4+
CONF_DIR="/etc/meshtasticd/config.d"
5+
VFS_DIR="/var/lib"
6+
7+
# If no instance ID provided, start bare daemon and exit
8+
echo "no instance ID provided, starting bare meshtasticd service"
9+
if [ -z "${INSTANCE}" ]; then
10+
/usr/bin/meshtasticd
11+
exit 0
12+
fi
13+
14+
# Make VFS dir if it does not exist
15+
if [ ! -d "${VFS_DIR}/meshtasticd-${INSTANCE}" ]; then
16+
echo "vfs for ${INSTANCE} does not exist, creating it."
17+
mkdir "${VFS_DIR}/meshtasticd-${INSTANCE}"
18+
fi
19+
20+
# Abort if config for $INSTANCE does not exist
21+
if [ ! -f "${CONF_DIR}/config-${INSTANCE}.yaml" ]; then
22+
echo "no config for ${INSTANCE} found in ${CONF_DIR}. refusing to start" >&2
23+
exit 1
24+
fi
25+
26+
# Start meshtasticd with instance parameters
27+
printf "starting meshtasticd-%s..., ${INSTANCE}"
28+
if /usr/bin/meshtasticd --config="${CONF_DIR}/config-${INSTANCE}.yaml" --fsdir="${VFS_DIR}/meshtasticd-${INSTANCE}"; then
29+
echo "ok"
30+
else
31+
echo "failed"
32+
fi

bin/meshtasticd.service

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[Unit]
2-
Description=Meshtastic Native Daemon
2+
Description=Meshtastic %i Daemon
33
After=network-online.target
44
StartLimitInterval=200
55
StartLimitBurst=5
@@ -9,7 +9,7 @@ AmbientCapabilities=CAP_NET_BIND_SERVICE
99
User=meshtasticd
1010
Group=meshtasticd
1111
Type=simple
12-
ExecStart=/usr/bin/meshtasticd
12+
ExecStart=/usr/bin/meshtasticd-start.sh %i
1313
Restart=always
1414
RestartSec=3
1515

bin/native-install.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env bash
22

33
cp "release/meshtasticd_linux_$(uname -m)" /usr/bin/meshtasticd
4+
cp "bin/meshtasticd-start.sh" /usr/bin/meshtasticd-start.sh
45
mkdir -p /etc/meshtasticd
56
if [[ -f "/etc/meshtasticd/config.yaml" ]]; then
67
cp bin/config-dist.yaml /etc/meshtasticd/config-upgrade.yaml

config.yaml

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
### Many device configs have been moved to /etc/meshtasticd/available.d
2+
### To activate, simply copy or link the appropriate file into /etc/meshtasticd/config.d
3+
4+
### Define your devices here using Broadcom pin numbering
5+
### Uncomment the block that corresponds to your hardware
6+
### Including the "Module:" line!
7+
---
8+
Lora:
9+
# Default to auto-detecting the module type
10+
# This will be overridden by configs from config.d
11+
Module: auto
12+
13+
# # Uncomment to enable Simulation mode, or use --sim
14+
Module: sim
15+
16+
# Module: sx1262 # Waveshare SX1302 LISTEN ONLY AT THIS TIME!
17+
# CS: 7
18+
# IRQ: 17
19+
# Reset: 22
20+
21+
# Module: RF95 # Elecrow Lora RFM95 IOT https://www.elecrow.com/lora-rfm95-iot-board-for-rpi.html
22+
# Reset: 22
23+
# CS: 7
24+
# IRQ: 25
25+
26+
# Module: sx1280 # SX1280
27+
# CS: 21
28+
# IRQ: 16
29+
# Busy: 20
30+
# Reset: 18
31+
32+
### The Radxa Zero 3E/W employs multiple gpio chips.
33+
### Each gpio pin must be unique, but can be assigned to a specific gpio chip and line.
34+
### In case solely a no. is given, the default gpio chip and pin == line will be employed.
35+
###
36+
# Module: sx1262 # Radxa Zero 3E/W + Ebyte E22-900M30S
37+
# DIO2_AS_RF_SWITCH: true
38+
# DIO3_TCXO_VOLTAGE: 1.8
39+
# CS: # NSS PIN_24 -> chip 4, line 22
40+
# pin: 24
41+
# gpiochip: 4
42+
# line: 22
43+
# SCK: # SCK PIN_23 -> chip 4, line 18
44+
# pin: 23
45+
# gpiochip: 4
46+
# line: 18
47+
# Busy: # BUSY PIN_29 -> chip 3!, line 11
48+
# pin: 29
49+
# gpiochip: 3
50+
# line: 11
51+
# MOSI: # MOSI PIN_19 -> chip 4, line 19
52+
# pin: 19
53+
# gpiochip: 4
54+
# line: 19
55+
# MISO: # MISO PIN_21 -> chip 4, line 21
56+
# pin: 21
57+
# gpiochip: 4
58+
# line: 21
59+
# Reset: # NRST PIN_27 -> chip 4, line 10
60+
# pin: 27
61+
# gpiochip: 4
62+
# line: 10
63+
# IRQ: # DIO1 PIN_28 -> chip 4, line 11
64+
# pin: 28
65+
# gpiochip: 4
66+
# line: 11
67+
# RXen: # RXEN PIN_22 -> chip 3!, line 17
68+
# pin: 22
69+
# gpiochip: 3
70+
# line: 17
71+
# TXen: RADIOLIB_NC # TXEN no PIN, no line, fallback to default gpio chip
72+
73+
# Module: sx1268 # SX1268-based modules, tested with Ebyte E22 400M33S
74+
# CS: 21
75+
# IRQ: 16
76+
# Busy: 20
77+
# Reset: 18
78+
# TXen: 6
79+
# RXen: 12
80+
# DIO3_TCXO_VOLTAGE: true
81+
82+
# DIO3_TCXO_VOLTAGE: true # the Waveshare Core1262 and others are known to need this setting
83+
84+
# TXen: x # TX and RX enable pins
85+
# RXen: x
86+
87+
# SX126X_MAX_POWER: 8 # Limit the output power to 8 dBm, useful for amped nodes
88+
89+
# spiSpeed: 2000000
90+
91+
### Set default/fallback gpio chip to use in /dev/. Defaults to 0.
92+
### Notably the Raspberry Pi 5 puts the GPIO header on gpiochip4
93+
# gpiochip: 4
94+
95+
### Specify the SPI device to use in /dev/. Defaults to spidev0.0
96+
### Some devices, like the pinedio, may require spidev0.1 as a workaround.
97+
# spidev: spidev0.0
98+
99+
### Deprecated location for User Button:
100+
101+
#GPIO:
102+
# User: 6
103+
104+
### Define GPS
105+
106+
GPS:
107+
# SerialPath: /dev/ttyS0
108+
109+
### Specify I2C device, or leave blank for none
110+
111+
I2C:
112+
# I2CDevice: /dev/i2c-1
113+
114+
### Set up SPI displays here. Note that I2C displays are generally auto-detected.
115+
116+
Display:
117+
118+
### Adafruit PiTFT 2.8 TFT+Touchscreen
119+
# Panel: ILI9341
120+
# CS: 8
121+
# DC: 25
122+
# Width: 240
123+
# Height: 320
124+
# Rotate: true
125+
126+
### SHCHV 3.5 RPi TFT+Touchscreen
127+
# Panel: ILI9486
128+
# spidev: spidev0.0
129+
# BusFrequency: 30000000
130+
# DC: 24
131+
# Reset: 25
132+
# Width: 320
133+
# Height: 480
134+
# OffsetRotate: 2
135+
136+
### TZT 2.0 Inch TFT Display ST7789V 240RGBx320
137+
# Panel: ST7789
138+
# spidev: spidev0.0
139+
# # CS: 8 # can be freely chosen
140+
# BusFrequency: 80000000
141+
# DC: 24 # can be freely chosen
142+
# Width: 320
143+
# Height: 240
144+
# Reset: 25 # can be freely chosen
145+
# Rotate: true
146+
# OffsetRotate: 1
147+
# Invert: true
148+
149+
### You can also specify the spi device for the display to use
150+
# spidev: spidev0.0
151+
152+
Touchscreen:
153+
### Note, at least for now, the touchscreen must have a CS pin defined, even if you let Linux manage the CS switching.
154+
155+
# Module: STMPE610 # Option 1 for Adafruit PiTFT 2.8
156+
# CS: 7
157+
# IRQ: 24
158+
159+
# Module: FT5x06 # Option 2 for Adafruit PiTFT 2.8
160+
# IRQ: 24
161+
# I2CAddr: 0x38
162+
163+
### You can also specify the spi device for the touchscreen to use
164+
# spidev: spidev0.0
165+
166+
167+
Input:
168+
### Configure device for direct keyboard input
169+
170+
# KeyboardDevice: /dev/input/by-id/usb-_Raspberry_Pi_Internal_Keyboard-event-kbd
171+
172+
### Standard User Button Config
173+
# UserButton: 6
174+
175+
### Trackball/Joystick input
176+
# TrackballUp: 6
177+
# TrackballDown: 19
178+
# TrackballLeft: 5
179+
# TrackballRight: 26
180+
# TrackballPress: 13
181+
182+
###
183+
184+
Logging:
185+
LogLevel: info # debug, info, warn, error
186+
# TraceFile: /var/log/meshtasticd.json
187+
# AsciiLogs: true # default if not specified is !isatty() on stdout
188+
189+
Webserver:
190+
# Port: 9443 # Port for Webserver & Webservices
191+
# RootPath: /usr/share/meshtasticd/web # Root Dir of WebServer
192+
# SSLKey: /etc/meshtasticd/ssl/private_key.pem # Path to SSL Key, generated if not present
193+
# SSLCert: /etc/meshtasticd/ssl/certificate.pem # Path to SSL Certificate, generated if not present
194+
195+
196+
HostMetrics:
197+
# ReportInterval: 30 # Interval in minutes between HostMetrics report packets, or 0 for disabled
198+
# Channel: 0 # channel to send Host Metrics over. Defaults to the primary channel.
199+
# UserStringCommand: cat /sys/firmware/devicetree/base/serial-number # Command to execute, to send the results as the userString
200+
201+
202+
Config:
203+
# DisplayMode: TWOCOLOR # uncomment to force BaseUI
204+
# DisplayMode: COLOR # uncomment to force MUI
205+
206+
General:
207+
MaxNodes: 200
208+
MaxMessageQueue: 100
209+
ConfigDirectory: /etc/meshtasticd/config.d/
210+
AvailableDirectory: /etc/meshtasticd/available.d/
211+
VFSDir: "./test"
212+
# MACAddress: AA:BB:CC:DD:EE:FF
213+
# MACAddressSource: eth0

debian/meshtasticd.install

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ bin/config.yaml etc/meshtasticd
44
bin/config.d/* etc/meshtasticd/available.d
55

66
bin/meshtasticd.service lib/systemd/system
7+
bin/meshtasticd-start.sh usr/bin
78

89
web/* usr/share/meshtasticd/web

meshtasticd.spec.rpkg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ cp -r bin/config.d/* %{buildroot}%{_sysconfdir}/meshtasticd/available.d
8989
# Install systemd service
9090
install -D -m 0644 bin/meshtasticd.service %{buildroot}%{_unitdir}/meshtasticd.service
9191

92+
# Install meshtasticd start wrapper
93+
install -D -m 0755 bin/meshtasticd-start.sh %{buildroot}%{_bindir}/meshtasticd-start.sh
94+
9295
# Install the web files under /usr/share/meshtasticd/web
9396
mkdir -p %{buildroot}%{_datadir}/meshtasticd/web
9497
cp -r web/* %{buildroot}%{_datadir}/meshtasticd/web

0 commit comments

Comments
 (0)