Course Management Scripts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
497 B

6 years ago
  1. #!/bin/bash
  2. TARGET="$2"
  3. if [ -z "$TARGET" ]; then
  4. TARGET=./
  5. fi
  6. if [[ $TARGET == */ ]]; then
  7. TARGET="$TARGET$(basename $1)"
  8. fi
  9. while read USER; do
  10. echo -n "$USER: "
  11. PTH=$(eval echo "~$USER")/$TARGET
  12. echo -n "$PTH "
  13. if [ -e "$PTH" ]; then
  14. if [ "$3" = "force" ]; then
  15. echo -ne "\x1b[1;31m(forced) \x1b[0m"
  16. else
  17. echo -ne "\x1b[1;31m(skipped, already extant) \x1b[0m"
  18. ls -la "$PTH"
  19. continue
  20. fi
  21. fi
  22. cp -r --preserve=all $1 "$PTH"
  23. chown $USER:$USER "$PTH"
  24. ls -la "$PTH"
  25. done