Hide-courses.sh

From WeBWorK_wiki
Jump to navigation Jump to search
#!/bin/bash
#
# Hal Sadofsky, September 4, 2010
#
# This script hides courses so that they don't appear on the main WeBWorK page.
#
# Usage is 
#
# sh hide-courses.sh coursename
#
# where coursename can be an indidual coursename, or something with wildcards
# that will match more than one coursename.
#
# so the command
#
# sh hide-courses.sh *
#
# will hide all courses!
#
# this must be run by a user with enough priviliges to create a file in the
# course directory.r
# 
export WEBWORK_ROOT=/opt/webwork/webwork2
export COURSE_DIR=/opt/webwork/courses
export SCRIPT_DIR=/home/wwork/archive-courses
export ARCHIVE_DIR=/opt/webwork/old/
directory=`pwd`
filesuffix='.tar.gz'

cd $COURSE_DIR

for file in $1
do
if [ -d "$file" ]
then
  touch $file/hide_directory
  if [ -f "$file/hide_directory" ]
  then
      echo "Course $file is now hidden."
  else
      echo "Unsuccessful making $file/hide_directory"
  fi
fi
done

cd $directory