diff --git a/general/overlay/etc/init.d/S96telemetry b/general/overlay/etc/init.d/S96telemetry old mode 100755 new mode 100644 index 7e6984d0..0ec38a7b --- a/general/overlay/etc/init.d/S96telemetry +++ b/general/overlay/etc/init.d/S96telemetry @@ -1,28 +1,51 @@ #!/bin/sh - DAEMON="Telemetry_Transfer" + PIDFILE="/var/run/$DAEMON.pid" -COMMAND="socat UDP-RECV:2002 STDOUT | mcom -s 420000 /dev/ttyAMA0 | socat - udp-sendto:192.168.144.222:2001" +LOG_DIR="/var/log/$DAEMON" +STDOUT_LOG="$LOG_DIR/stdout.log" +STDERR_LOG="$LOG_DIR/stderr.log" + +COMMAND="socat UDP-RECV:2002 STDOUT | mcom -s 420000 /dev/ttyAMA0 2>>STDERR_LOG | socat - udp-sendto:192.168.144.201:5601 2>>STDERR_LOG " + +# Ensure the log directory exists +[ ! -d "$LOG_DIR" ] && mkdir -p "$LOG_DIR" start() { echo -n "Starting $DAEMON: " - start-stop-daemon -b -m -S -q -p "$PIDFILE" -x /bin/sh -- -c "$COMMAND" + + start-stop-daemon -b -m -S -q -p "$PIDFILE" -x /bin/sh -- -c "$COMMAND" \ + >> "$STDOUT_LOG" 2>> "$STDERR_LOG" + if [ $? -eq 0 ]; then echo "OK" else echo "FAIL" fi + + # Schedule the restart of S95telemetry after 30 seconds + (sleep 30 && /etc/init.d/S95telemetry restart) & } stop() { echo -n "Stopping $DAEMON: " - start-stop-daemon -K -q -p "$PIDFILE" - if [ $? -eq 0 ]; then + + # Kill the process using the PID file + if start-stop-daemon -K -q -p "$PIDFILE"; then rm -f "$PIDFILE" echo "OK" else echo "FAIL" fi + + # Kill any remaining processes by checking COMMAND + for pattern in "UDP-RECV:2002" "mcom -s 420000" "udp-sendto:192.168.144.201:5601"; do + pids=$(ps | grep "$pattern" | grep -v grep | awk '{print $1}') + for pid in $pids; do + kill "$pid" 2>/dev/null + echo "Killed process $pid with pattern $pattern" + done + done } restart() { @@ -31,22 +54,19 @@ restart() { start } - case "$1" in start) start ;; - stop) stop ;; - restart|reload) restart ;; - *) echo "Usage: $0 {start|stop|restart|reload}" exit 1 ;; esac + diff --git a/general/overlay/etc/init.d/S97majestic-config-writer b/general/overlay/etc/init.d/S97majestic-config-writer index 40c464e1..463dff0f 100755 --- a/general/overlay/etc/init.d/S97majestic-config-writer +++ b/general/overlay/etc/init.d/S97majestic-config-writer @@ -69,7 +69,7 @@ records: maxUsage: 95 outgoing: enabled: true - server: udp://192.168.144.222:8000 + server: udp://192.168.144.201:5600 watchdog: enabled: true timeout: 300 diff --git a/general/overlay/etc/inittab b/general/overlay/etc/inittab index 14bfc44b..bdf8440a 100644 --- a/general/overlay/etc/inittab +++ b/general/overlay/etc/inittab @@ -29,7 +29,7 @@ null::sysinit:/bin/ln -sf /proc/self/fd/2 /dev/stderr ::sysinit:/etc/init.d/rcS # Put a getty on the serial port -console::respawn:/sbin/getty -L console 0 vt100 +#console::respawn:/sbin/getty -L console 0 vt100 # Stuff to do before rebooting ::shutdown:/etc/init.d/rcK diff --git a/general/overlay/etc/network/interfaces.d/eth0 b/general/overlay/etc/network/interfaces.d/eth0 index 714fa3d2..25e45d62 100644 --- a/general/overlay/etc/network/interfaces.d/eth0 +++ b/general/overlay/etc/network/interfaces.d/eth0 @@ -2,4 +2,4 @@ auto eth0 iface eth0 inet static address 192.168.144.200 netmask 255.255.255.0 - gateway 192.168.1.1 + gateway 192.168.144.1