coffin

secure lan file storage on a device
git clone git://parazyd.org/coffin.git
Log | Files | Refs | Submodules | README | LICENSE

coffin (1369B)


      1 #!/usr/bin/env bash
      2 #
      3 # Copyright (c) 2016 Dyne.org Foundation
      4 # coffin is written and maintained by Ivan J. <parazyd@dyne.org>
      5 #
      6 # This file is part of coffin
      7 #
      8 # This source code is free software: you can redistribute it and/or modify
      9 # it under the terms of the GNU General Public License as published by
     10 # the Free Software Foundation, either version 3 of the License, or
     11 # (at your option) any later version.
     12 #
     13 # This software is distributed in the hope that it will be useful,
     14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 # GNU General Public License for more details.
     17 #
     18 # You should have received a copy of the GNU General Public License
     19 # along with this source code. If not, see <http://www.gnu.org/licenses/>.
     20 
     21 pattern='sd[a-z][1-9]$'
     22 coproc inotifywait --monitor --event create,delete --format '%e %w%f' /dev
     23 
     24 echo $COPROC_PID > /var/run/coffin.pid # pidfile
     25 
     26 while read -r -u "${COPROC[0]}" event file; do
     27     if [[ $file =~ $pattern ]]; then
     28         case $event in
     29             CREATE)
     30                 echo "Created $file..." #; sleep 1
     31                 $(dirname $0)/sacrist $file $event
     32                 ;;
     33             DELETE)
     34                 echo "Removed $file..." #; sleep 1
     35                 $(dirname $0)/sacrist $file $event
     36                 ;;
     37         esac
     38     fi
     39 done