setup-test-dirs.sh 1018 Bytes
Newer Older
1
#!/usr/bin/env bash
2

3 4
# Create symlinks from ~/edx_all/data or $ROOT/data, with root passed as first arg
# to all the test courses in edx-platform/common/test/data/
5

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
ROOT="${1:-$HOME/edx_all}"
13 14

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

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

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

echo "ROOT is $ROOT"

cd $ROOT/data
32

33
for course in $(/bin/ls ../edx-platform/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
   echo "Make link to '$course'"
   # Create it
42
   ln -s "../edx-platform/common/test/data/$course"
43 44 45 46
done

# go back to where we came from
cd -