#!/bin/bash
set -e
-main()
+find_config()
{
- DLLCONFIG=${DLLCONFIG:="/etc/sane.d/dll.conf"}
- local ENTRY="kds_s2000w_net"
-
[ ! -f "$DLLCONFIG" ] \
&& echo "ERROR: $DLLCONFIG does not exist" \
- && return 0
+ && return 1
echo "found $DLLCONFIG"
+}
+
+add_entry()
+{
+ local entry="$1"
+ local dllconfig="$2"
- grep --silent "$ENTRY" "$DLLCONFIG" || echo "$ENTRY" >> "$DLLCONFIG"
+ grep --silent "$entry" "$dllconfig" && return 0
+ echo "$entry" >> "$dllconfig"
+ echo "add kds_s2000w_net to ../build/dll.conf"
+}
+
+main()
+{
+ DLLCONFIG=${DLLCONFIG:="/etc/sane.d/dll.conf"}
+ local ENTRY="kds_s2000w_net"
+
+ find_config "$DLLCONFIG" || return 0
+ add_entry "$ENTRY" "$DLLCONFIG"
}
main
\ No newline at end of file
run ../src/debian/postinst
assert_success
- assert_output "found ../build/dll.conf"
+ assert_line --index 0 "found ../build/dll.conf"
+ assert_line --index 1 "add kds_s2000w_net to ../build/dll.conf"
assert_equal "$(cat ../build/dll.conf)" "kds_s2000w_net"
assert_equal "$(cat ../build/dll.conf | wc --lines)" "1"
unset DLLCONFIG