diff options
-rwxr-xr-x | census/sched-arping | 2 | ||||
-rwxr-xr-x | util/bin/magic | 14 |
2 files changed, 6 insertions, 10 deletions
diff --git a/census/sched-arping b/census/sched-arping index d281cac3..14f8af3c 100755 --- a/census/sched-arping +++ b/census/sched-arping @@ -4,5 +4,5 @@ TMP=`mktemp` crontab -l >$TMP echo "23 * * * * $PWD/arping_users.py > $PWD/../db/arping" | -../util/bin/magic "arping" create $TMP +../util/bin/magic create "arping" $TMP crontab $TMP diff --git a/util/bin/magic b/util/bin/magic index cb9cee6e..a404c0c3 100755 --- a/util/bin/magic +++ b/util/bin/magic @@ -1,12 +1,8 @@ #! /bin/sh -# -# magic NAME create FILE < CONTENT -# magic NAME update FILE < CONTENT -# magic NAME destroy FILE -# +set -euf -bs="# begin krebs magic <$1>" -es="# end krebs magic <$1>" +bs="# begin krebs magic <$2>" +es="# end krebs magic <$2>" has() { grep -q "^$bs$" $3 && grep -q "^$es$" $3 @@ -37,7 +33,7 @@ destroy() { } help() { cat <<EOF -Usage: $0 DELIMITER_NAME FUNCTION FILE +Usage: $0 FUNCTION DELIMITER_NAME FILE $0 creates,updates or destroys magic inside a file. It can be used to reliably add or remove custom lines. For example add own lines in /etc/rc.local to auto-load @@ -55,7 +51,7 @@ shell comment symbol "#". EOF } -case $2 in +case $1 in (create) create "$@" ;; (retrieve) retrieve "$@" ;; (update) update "$@" ;; |