setup-test-dirs.sh 990 Bytes
Newer Older
1
#!/usr/bin/env bash
2 3 4 5

# Create symlinks from ~/mitx_all/data or $ROOT/data, with root passed as first arg
# to all the test courses in mitx/common/test/data/

6 7 8 9
# posix compliant sanity check
if [ -z $BASH ] || [ $BASH = "/bin/sh" ]; then
echo "Please use the bash interpreter to run this script"
exit 1
10 11
fi

12 13 14
ROOT="${1:-$HOME/mitx_all}"

if [[ ! -d "$ROOT" ]]; then
15 16 17 18
   echo "'$ROOT' is not a directory"
   exit 1
fi

19
if [[ ! -d "$ROOT/mitx" ]]; then
20 21 22 23
    echo "'$ROOT' is not the root mitx_all directory"
    exit 1
fi

24
if [[ ! -d "$ROOT/data" ]]; then
25 26 27 28 29 30 31
    echo "'$ROOT' is not the root mitx_all directory"
    exit 1
fi

echo "ROOT is $ROOT"

cd $ROOT/data
32 33

for course in $(/bin/ls ../mitx/common/test/data/)
34 35
do
  # Get rid of the symlink if it already exists
36 37 38 39
   if [[ -L "$course" ]]; then
       echo "Removing link to '$course'"
       rm -f $course
   fi
40 41 42 43 44 45 46
   echo "Make link to '$course'"
   # Create it
   ln -s "../mitx/common/test/data/$course"
done

# go back to where we came from
cd -