]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
change refactor postrm script
authorBastian Dehn <hhaalo@arcor.de>
Tue, 18 Nov 2025 16:48:08 +0000 (17:48 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Tue, 18 Nov 2025 16:48:33 +0000 (17:48 +0100)
src/debian/postrm

index b8dacd3de015f125e74647723f53d4b745709821..ae1438442c8b76f0b19b62275d12cf50c02418d5 100644 (file)
@@ -1,26 +1,36 @@
 #!/bin/bash
 
+errlog()
+{
+       local lastexit=$?
+       local msg="$1"
+
+       echo "$msg"
+
+       return $lastexit
+}
+
 main()
 {
-       DLLCONFIG="/etc/sane.d/dll.conf"
-       ENTRY="kds_s2000w_net"
+       local DLLCONFIG="/etc/sane.d/dll.conf"
+       local ENTRY="kds_s2000w_net"
 
-       if [ ! -f "$DLLCONFIG" ]; then
-               echo "ERROR: $DLLCONFIG does not exist"
-               exit 0
-       fi
+       [ -f "$DLLCONFIG" ] \
+               || errlog "ERROR: $DLLCONFIG does not exist" \
+               || return $?
 
        echo "found $DLLCONFIG"
-       ENTRYCHECK=$(cat $DLLCONFIG | grep $ENTRY)
+       local entrycheck=$(cat $DLLCONFIG | grep $ENTRY)
+
+       [ -z "$entrycheck" ] \
+               && echo "$ENTRY entry does not exists in $DLLCONFIG" \
+               && return 0
 
-       if [ -z "$ENTRYCHECK" ]; then
-               echo "$ENTRY entry does not exists in $DLLCONFIG"
-               exit 0
-       fi
+       sed -i "/$ENTRY/d" $DLLCONFIG \
+               || errlog "could not remove $ENTRY from $DLLCONFIG"  \
+               || return $?
 
-       sed -i "/$ENTRY/d" $DLLCONFIG
        echo "remove $ENTRY from $DLLCONFIG"
 }
 
-main
-exit 0
\ No newline at end of file
+main
\ No newline at end of file