ratox-nuggets

useful ratox related scripts
git clone git://git.2f30.org/ratox-nuggets.git
Log | Files | Refs | LICENSE

commit 5daf6d61be064fe620376fc812bf462a6e9b12dc
parent f4754ff27d8a032658e01609c1c7d8fe8c42075f
Author: FRIGN <dev@frign.de>
Date:   Sun Nov  2 11:50:15 +0100

Simplify sanity checks

Not everyone has lsof and this other fancy stuff.
Just check for the existence of "id". In case the user runs the
script on a dead ratox-folder, it will error out sooner or later
anyway.

Diffstat:
functions | 7+++++++
rat-autoanswer | 2++
rat-autoapprove | 6++----
rat-list | 15++++-----------
rat-remotemic | 1+
rat-textout | 1+
6 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/functions b/functions @@ -22,3 +22,10 @@ function stdin_trasher () { { cat > /dev/null <&3 3<&- & } 3<&0 echo $! } + +function check_if_dir() { + if ! test -e id; then + echo "ERROR: Is this a ratox directory?" >&2 + exit 1 + fi +} diff --git a/rat-autoanswer b/rat-autoanswer @@ -10,6 +10,8 @@ LIBRARY_LOCATION=`dirname $0` . $LIBRARY_LOCATION/functions export PATH=$LIBRARY_LOCATION:$PATH +check_if_dir + while true; do log "Monitoring for new call" monitor_pending call diff --git a/rat-autoapprove b/rat-autoapprove @@ -4,11 +4,9 @@ LIBRARY_LOCATION=`dirname $0` . $LIBRARY_LOCATION/functions +export PATH=$LIBRARY_LOCATION:$PATH -[ ! -f .ratox.data ] && { - log "Should be run in root of ratox profile" - exit 1 -} +check_if_dir while true; do find request/out/ -type p | while read request; do diff --git a/rat-list b/rat-list @@ -1,6 +1,10 @@ #!/bin/sh # List friends +LIBRARY_LOCATION=`dirname $0` +. $LIBRARY_LOCATION/functions +export PATH=$LIBRARY_LOCATION:$PATH + set -e green() { printf "\033[1;32m$1\033[0;39;49m\n"; } red() { printf "\033[1;31m$1\033[0;39;49m\n"; } @@ -16,16 +20,6 @@ set_state() { fi } -# Try to determine whether this is run from within -# a ratox directory and complain if not. -check_if_dir(){ - # "grouping hack" to prevent output to stdout on FreeBSD - if ! { fstat id |grep -q 'ratox';} > /dev/null 2>&1 || [ ! -r id ]; then - echo "ERROR: Is this a ratox directory?" >&2 - exit 1 - fi -} - print_output() { IDS=$(ls |grep '[A-Z0-9]\{64\}') for ID in $IDS; do @@ -42,6 +36,5 @@ print_output() { done } - check_if_dir print_output diff --git a/rat-remotemic b/rat-remotemic @@ -7,6 +7,7 @@ LIBRARY_LOCATION=`dirname $BASH_SOURCE` . $LIBRARY_LOCATION/functions +export PATH=$LIBRARY_LOCATION:$PATH function remotemic() { TRASHER=$(stdin_trasher) diff --git a/rat-textout b/rat-textout @@ -1,4 +1,5 @@ #!/bin/sh +check_if_dir test x"$1" = x"" && exit 1 idstr="$1"