flow.sh 705 B

1234567891011121314151617181920212223
  1. #!/bin/bash
  2. # Run with through workflows and invoke like this:
  3. # export F=%f && export N=%n && /path/to/flow.sh
  4. OCCPATH=/var/www/nextcloud/occ
  5. LOCATION=$(dirname $F)
  6. FLOWCMD=$(grep '^\\#flow' $LOCATION/Readme.md|head -1) || exit 0
  7. MODULE=$(echo $FLOWCMD|tr -s ' '|cut -d' ' -f2)
  8. echo Running flow.sh on [ $LOCATION] executing [ $FLOWCMD ].
  9. case $MODULE in
  10. "findrm")
  11. NCPATH=$(dirname /$N)
  12. PATTERN=$(echo $FLOWCMD|tr -s ' '|cut -d' ' -f3|sed -e 's/^\\//')
  13. NUM=$(echo $FLOWCMD|tr -s ' '|cut -d' ' -f4)
  14. find $LOCATION -maxdepth 1 -type f -name "$PATTERN" ! -iname readme.md -print0 | xargs -0 ls -xt | awk "NR>$NUM" | xargs -I '{}' rm '{}'
  15. $OCCPATH files:scan -p $NCPATH
  16. ;;
  17. esac