From: Bastian Dehn Date: Tue, 18 Nov 2025 16:41:51 +0000 (+0100) Subject: change refactor postinst script X-Git-Tag: v1.1.22^2~16 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=d924609a9d3d8ead34c21096196b50f32ce50561;p=sane-kds-s2000w-net.git change refactor postinst script --- diff --git a/src/debian/postinst b/src/debian/postinst index 32e9895..94f8a4b 100644 --- a/src/debian/postinst +++ b/src/debian/postinst @@ -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) + + [ -n "$entrycheck" ] \ + && echo "$ENTRY entry exists in $DLLCONFIG" \ + && return 0 - if [ -n "$ENTRYCHECK" ]; then - echo "$ENTRY entry exists in $DLLCONFIG" - exit 0 - fi + sed -i "\$a$ENTRY" $DLLCONFIG \ + || errlog "could not add entry $ENTRY to $DLLCONFIG" \ + || return $? - sed -i "\$a$ENTRY" $DLLCONFIG echo "add $ENTRY to $DLLCONFIG" } -main -exit 0 \ No newline at end of file +main \ No newline at end of file