commit cb97a7f533a108720132427c9c185c211851520b parent 79a780a5f4ce0274563b4b2933bb863dab226954 Author: parazyd <parazyd@dyne.org> Date: Wed, 27 Jan 2016 15:32:58 +0100 mourner, script to watch /dev for new keys Diffstat:
A | bin/mourner | | | 23 | +++++++++++++++++++++++ |
1 file changed, 23 insertions(+), 0 deletions(-)
diff --git a/bin/mourner b/bin/mourner @@ -0,0 +1,23 @@ +#!/bin/bash +# +# mourner - inotify script to watch /dev for new keys +# +# ~ parazyd + +pattern='sd[b-z][1-9]$' +coproc inotifywait --monitor --event create,delete --format '%e %w%f' /dev + +while read -r -u "${COPROC[0]}" event file; do + if [[ $file =~ $pattern ]]; then + case $event in + CREATE) + echo "Created $file..."; sleep 1 + `pwd`/sacrist $file $event + ;; + DELETE) + echo "Removed $file..."; sleep 1 + `pwd`/sacrist $file $event + ;; + esac + fi +done