summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@iiso>2011-11-08 23:21:13 +0100
committertv <tv@iiso>2011-11-08 23:21:13 +0100
commit2775e90ade100163824dfe4ec52f159700e9c86d (patch)
tree88b4acf89f94a3ffa7d350c41219c9982149e431
parent6e4d5355374c6205376bf35cdb10e67542b7958a (diff)
parent7bef2d4da84b6fb2ca2235a8058cec9150d69cbe (diff)
Merge branch 'master' of github.com:krebscode/painload
-rwxr-xr-xcensus/sched-arping2
-rw-r--r--noise/Makefile2
-rwxr-xr-xutil/bin/magic14
3 files changed, 8 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/noise/Makefile b/noise/Makefile
index 932c5940..0d72b2e9 100644
--- a/noise/Makefile
+++ b/noise/Makefile
@@ -7,6 +7,7 @@ infest:
apt-get install --yes expect beep alsa-utils ucspi-tcp espeak
f=/usr/bin/beep; chown krebs:krebs $$f && chmod 4755 $$f
getent passwd noise || useradd noise
+ echo 'noise ALL=(ALL) NOPASSWD: /krebs/streams/streams' | magic create noise /etc/sudoers
ln -vsnf /krebs/noise/init.d/noise /etc/init.d/noise
## tv: TODO update-rc.d is DEBIAN ONLY, fix this
update-rc.d -f noise defaults
@@ -14,3 +15,4 @@ infest:
amixer sset 'PCM' 100 unmute || true
amixer sset 'PC Speaker' 100 unmute || \
amixer sset 'Beep' 100 unmute || true
+
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 "$@" ;;