diff --git a/pi-image/fixup-config.sh b/pi-image/fixup-config.sh new file mode 100755 index 0000000..6af5e44 --- /dev/null +++ b/pi-image/fixup-config.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +SATELLITE_CONFIG_PATH=/boot/satellite-config + +# path could be a symlink +SATELLITE_CONFIG_PATH=$(realpath $SATELLITE_CONFIG_PATH) + +# config file doesn't exist, try and find it +if ! [ -f "$SATELLITE_CONFIG_PATH" ]; then + if [ -f "/boot/firmware/satellite-config" ]; then + ln -s /boot/firmware/satellite-config $SATELLITE_CONFIG_PATH + else + echo "Warning: Failed to find config" + fi +fi diff --git a/pi-image/satellite.service b/pi-image/satellite.service index 78ba4c8..6e9370e 100644 --- a/pi-image/satellite.service +++ b/pi-image/satellite.service @@ -7,10 +7,11 @@ Wants=network-online.target Type=simple User=satellite WorkingDirectory=/usr/local/src/companion-satellite -EnvironmentFile=/boot/satellite-config +EnvironmentFile=-/boot/satellite-config Environment=SATELLITE_CONFIG_PATH=/boot/satellite-config +ExecStartPre=+/usr/local/src/companion-satellite/pi-image/fixup-config.sh ExecStart=/opt/fnm/aliases/default/bin/node /usr/local/src/companion-satellite/dist/main.js $COMPANION_IP $COMPANION_PORT $REST_PORT -Restart=on-failure +Restart=always KillSignal=SIGINT TimeoutStopSec=60