p910nd: init: check device (/dev/usb/lpX) existence
authorPaul Donald <newtwen@gmail.com>
Sun, 11 Feb 2024 18:28:38 +0000 (19:28 +0100)
committerRosen Penev <rosenp@gmail.com>
Sun, 11 Feb 2024 23:48:49 +0000 (15:48 -0800)
this prevents the daemon exiting when a configured device
is not plugged in.

Signed-off-by: Paul Donald <newtwen@gmail.com>
net/p910nd/files/p910nd.init

index 092a918ab0f2bab6dfe796f8162af572c3aa4153..a15e8d1dc739b26cb0d313cc8b0099f68530612c 100644 (file)
@@ -32,7 +32,9 @@ start_service() {
 start_p910nd() {
        local section="$1" runas_root
        config_get_bool "enabled" "$section" "enabled" '0'
-       if [ "$enabled" -gt 0 ]; then
+       config_get device "$section" device
+       # If the device path exists, the device is connected; set it up:
+       if [ "$enabled" -gt 0 ] && [ -e "$device" ]; then
                args="-d "
                config_get port "$section" port
                append_bool "$section" bidirectional "-b"