#!/bin/ksh
#------------------------------------------------------------------------------!
# Current revisions:
# -----------------
# 
# Former revisions:
# -----------------
# $Id: release_tutorial 947 2012-07-17 16:03:17Z hoffmann $
#
# 946 2012-07-17 16:02:40Z maronga
# Typo removed
#
# 915 2012-05-30 15:11:11Z maronga
# Initial revision
#
# Description:
# ------------
# Script for copying the compiled PDFs to a desired web directory. This script
# should be used by user raasch only.
#
# Execution:
# ----------
# release_tutorial --> Copy all PDF files to $release_directory (see below)
#------------------------------------------------------------------------------!

    release_directory="/home/raasch/public_html/files"
    mod_dir_lecture="755"
    mod_dir_handout="755"
    mod_dir_web="755"
    mod_lecture="644"
    mod_handout="644"
    mod_web="644"

    full_name=`readlink -f $0`
    directory="$(dirname $full_name)/../TUTORIAL/SOURCE"
    input_dir="$(dirname $full_name)/../TUTORIAL"
    cd $input_dir

    printf "\n Files will be released in $release_directory/."
    printf "\n Subdirectories LECTURE, HANDOUT and WEB will be creared if necessary."
    printf "\n Start copying...\n"


    if [[ ! -d $release_directory/LECTURE ]] then
       printf " $release_directory/LECTURE will be created.\n"
       mkdir -p $release_directory/LECTURE
       chmod $mod_dir_lecture $release_directory/LECTURE
    fi
    cp LECTURE/*.pdf "$release_directory/LECTURE/"
    chmod $mod_lecture $release_directory/LECTURE/*
    printf " Finished LECTURE.\n"

    if [[ ! -d $release_directory/HANDOUT ]] then
       printf " $release_directory/HANDOUT will be created.\n"
       mkdir -p $release_directory/HANDOUT
       chmod $mod_dir_handout $release_directory/HANDOUT

    fi
    cp HANDOUT/*.pdf "$release_directory/HANDOUT/"
    chmod $mod_handout $release_directory/HANDOUT/*
    printf " Finished HANDOUT.\n"

    if [[ ! -d $release_directory/WEB ]] then
       printf " $release_directory/WEB will be created.\n"
       mkdir -p $release_directory/WEB
       chmod $mod_dir_web $release_directory/WEB
    fi
    cp WEB/*.pdf "$release_directory/WEB/"
    chmod $mod_web $release_directory/WEB/*
    printf " Finished WEB.\n"

    printf " \n +++ All actions finished.\n"

exit



