Add support for sevice start wrapper (#8676)
Co-authored-by: Ben Meadors <benmmeadors@gmail.com> Co-authored-by: Austin <vidplace7@gmail.com>
This commit is contained in:
co-authored by
GitHub
Ben Meadors
Austin
parent
c45c217743
commit
727b1b3e85
Executable
+32
@@ -0,0 +1,32 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
INSTANCE=$1
|
||||||
|
CONF_DIR="/etc/meshtasticd/config.d"
|
||||||
|
VFS_DIR="/var/lib"
|
||||||
|
|
||||||
|
# If no instance ID provided, start bare daemon and exit
|
||||||
|
echo "no instance ID provided, starting bare meshtasticd service"
|
||||||
|
if [ -z "${INSTANCE}" ]; then
|
||||||
|
/usr/bin/meshtasticd
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Make VFS dir if it does not exist
|
||||||
|
if [ ! -d "${VFS_DIR}/meshtasticd-${INSTANCE}" ]; then
|
||||||
|
echo "vfs for ${INSTANCE} does not exist, creating it."
|
||||||
|
mkdir "${VFS_DIR}/meshtasticd-${INSTANCE}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Abort if config for $INSTANCE does not exist
|
||||||
|
if [ ! -f "${CONF_DIR}/config-${INSTANCE}.yaml" ]; then
|
||||||
|
echo "no config for ${INSTANCE} found in ${CONF_DIR}. refusing to start" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Start meshtasticd with instance parameters
|
||||||
|
printf "starting meshtasticd-%s..., ${INSTANCE}"
|
||||||
|
if /usr/bin/meshtasticd --config="${CONF_DIR}/config-${INSTANCE}.yaml" --fsdir="${VFS_DIR}/meshtasticd-${INSTANCE}"; then
|
||||||
|
echo "ok"
|
||||||
|
else
|
||||||
|
echo "failed"
|
||||||
|
fi
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Meshtastic Native Daemon
|
Description=Meshtastic %i Daemon
|
||||||
After=network-online.target
|
After=network-online.target
|
||||||
StartLimitInterval=200
|
StartLimitInterval=200
|
||||||
StartLimitBurst=5
|
StartLimitBurst=5
|
||||||
@@ -9,7 +9,7 @@ AmbientCapabilities=CAP_NET_BIND_SERVICE
|
|||||||
User=meshtasticd
|
User=meshtasticd
|
||||||
Group=meshtasticd
|
Group=meshtasticd
|
||||||
Type=simple
|
Type=simple
|
||||||
ExecStart=/usr/bin/meshtasticd
|
ExecStart=/usr/bin/meshtasticd-start.sh %i
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=3
|
RestartSec=3
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
cp "release/meshtasticd_linux_$(uname -m)" /usr/bin/meshtasticd
|
cp "release/meshtasticd_linux_$(uname -m)" /usr/bin/meshtasticd
|
||||||
|
cp "bin/meshtasticd-start.sh" /usr/bin/meshtasticd-start.sh
|
||||||
mkdir -p /etc/meshtasticd
|
mkdir -p /etc/meshtasticd
|
||||||
if [[ -f "/etc/meshtasticd/config.yaml" ]]; then
|
if [[ -f "/etc/meshtasticd/config.yaml" ]]; then
|
||||||
cp bin/config-dist.yaml /etc/meshtasticd/config-upgrade.yaml
|
cp bin/config-dist.yaml /etc/meshtasticd/config-upgrade.yaml
|
||||||
|
|||||||
Vendored
+1
@@ -4,5 +4,6 @@ bin/config.yaml etc/meshtasticd
|
|||||||
bin/config.d/* etc/meshtasticd/available.d
|
bin/config.d/* etc/meshtasticd/available.d
|
||||||
|
|
||||||
bin/meshtasticd.service lib/systemd/system
|
bin/meshtasticd.service lib/systemd/system
|
||||||
|
bin/meshtasticd-start.sh usr/bin
|
||||||
|
|
||||||
web/* usr/share/meshtasticd/web
|
web/* usr/share/meshtasticd/web
|
||||||
|
|||||||
@@ -95,6 +95,9 @@ cp -r bin/config.d/* %{buildroot}%{_sysconfdir}/meshtasticd/available.d
|
|||||||
# Install systemd service
|
# Install systemd service
|
||||||
install -D -m 0644 bin/meshtasticd.service %{buildroot}%{_unitdir}/meshtasticd.service
|
install -D -m 0644 bin/meshtasticd.service %{buildroot}%{_unitdir}/meshtasticd.service
|
||||||
|
|
||||||
|
# Install meshtasticd start wrapper
|
||||||
|
install -D -m 0755 bin/meshtasticd-start.sh %{buildroot}%{_bindir}/meshtasticd-start.sh
|
||||||
|
|
||||||
# Install the web files under /usr/share/meshtasticd/web
|
# Install the web files under /usr/share/meshtasticd/web
|
||||||
mkdir -p %{buildroot}%{_datadir}/meshtasticd/web
|
mkdir -p %{buildroot}%{_datadir}/meshtasticd/web
|
||||||
cp -r web/* %{buildroot}%{_datadir}/meshtasticd/web
|
cp -r web/* %{buildroot}%{_datadir}/meshtasticd/web
|
||||||
|
|||||||
Reference in New Issue
Block a user