1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
#!/bin/sh
# ledcontrol (@PACKAGE@) version @VERSION@
# Copyright (C) 2000 by Sampo Niskanen, distributed under the terms
# of the GNU GPL version 2 or later. ABSOLUTELY NO WARRANTY.
# See the file COPYING for details.
# Requires the programs test, grep, @AWK@
PATH=/bin:/usr/bin:/usr/local/bin
VERSION="@VERSION@"
PACKAGE="@PACKAGE@"
CONFFILE="@sysconfdir_int@/ledd.conf"
READDEFAULT=yes
PIPEFILES=
while test $# -gt 0; do
case "$1" in
-h|-help|--help)
cat 1>&2 <<HERE
ledcontrol ($PACKAGE) version $VERSION
Copyright (C) 2000 by Sampo Niskanen, distributed under the terms
of the GNU GPL version 2 or later. ABSOLUTELY NO WARRANTY.
See the file COPYING for details.
Usage: $0 [options] [command]
-h --help This help message.
-v -V --version Print version information.
-c FILE --config FILE Read pipe location from configuration file FILE.
-p FILE --pipe FILE Use FILE as the command pipe.
If -c of -p is not specified, ledcontrol tries to read the pipe location
from the default configuration file [$CONFFILE].
For more information on the format of command, see the documentation.
HERE
exit 0;;
-v|-V|-version|--version)
echo "ledcontrol ($PACKAGE) $VERSION" 1>&2
exit 0;;
-c|-config|--config)
if test $# -lt 2; then
echo $0: option $1 requires argument. 1>&2
exit 1
fi
if test ! -r "$2"; then
echo $0: unable to read $2. 1>&2
exit 1
fi
NEWPIPES=`grep -i "^[[:space:]]*pipefile[[:space:]]*[^[:space:]][^[:space:]]*[[:space:]]*$" "$2" | @AWK@ '{ print $2 }'`
PIPEFILES="$NEWPIPES $PIPEFILES"
READDEFAULT=no
shift 2;;
-p|-pipe|--pipe)
if test $# -lt 2; then
echo $0: option $1 requires argument. 1>&2
exit 1
fi
PIPEFILES="$2 $PIPEFILES"
READDEFAULT=no
shift 2;;
anim|set|nop)
break;;
*)
if test -n "`echo "$1" | grep "^ *\(set\|anim\|nop\) "`"; then
break;
fi
echo $0: bad option $1. 1>&2
exit 1;;
esac
done
if test $# -lt 1; then
echo $0: nothing to output. 1>&2
exit 1
fi
if test $READDEFAULT = yes; then
NEWPIPES=`grep -i "^[[:space:]]*pipefile[[:space:]]*[^[:space:]][^[:space:]]*[[:space:]]*$" "$CONFFILE" | @AWK@ '{ print $2 }'`
PIPEFILES="$NEWPIPES $PIPEFILES"
fi
# Find a suitable pipe
for PIPE in $PIPEFILES NOPIPE ; do
if test -p "$PIPE" -a -w "$PIPE"; then
break;
fi
done
if test "$PIPE" = "NOPIPE" ; then
echo $0: no suitable pipefile found. 1>&2
exit 1
fi
echo $* >"$PIPE"
|