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

#!/bin/bash
TARGET="$2"
if [ -z "$TARGET" ]; then
TARGET=./
fi
if [[ $TARGET == */ ]]; then
TARGET="$TARGET$(basename $1)"
fi
while read USER; do
echo -n "$USER: "
PTH=$(eval echo "~$USER")/$TARGET
echo -n "$PTH "
if [ -e "$PTH" ]; then
if [ "$3" = "force" ]; then
echo -ne "\x1b[1;31m(forced) \x1b[0m"
else
echo -ne "\x1b[1;31m(skipped, already extant) \x1b[0m"
ls -la "$PTH"
continue
fi
fi
cp -r --preserve=all $1 "$PTH"
chown $USER:$USER "$PTH"
ls -la "$PTH"
done