#!/bin/bash # # mkopus- create opus # # This script NEEDS to be run on www # # 20120827 - overhaul to accommodate opus changes # 20111218 - initial implementation # ## ## Bootstrap ## source ~/bin/lib/gnops.sh hostchk www cd /usr/local/etc/mth ## ## Configuration and Variables ## PATH=$PATH:/home/wedge/bin SEMESTER="`gn semester`" OPUSPATH="/var/www/lab46web/data/pages/opus/${SEMESTER}" YEAR="`date +%Y`" MONTH="`date +%B`" # Verify that ${OPUSPATH} exists # if [ ! -e "${OPUSPATH}" ]; then mkdir -p ${OPUSPATH} fi if [ -z "${1}" ]; then # no part was specified on the command line part=1 else part="${1}" fi echo "Processing . . ." for student in `gn list`; do echo -n " -> $student: " pt= if [ ! -e "${OPUSPATH}/${student}" ]; then mkdir -p ${OPUSPATH}/${student} fi for section in start title intro; do if [ ! -e "${OPUSPATH}/${student}/${section}.txt" ]; then cat ${OPUSPATH}/${section}.txt | sed "s/SEMESTER/${SEMESTER}/g" | sed "s/USER/${student}/g" | sed "s/YEAR/${YEAR}/g" | sed "s/MONTH/${MONTH}/g" > ${OPUSPATH}/${student}/${section}.txt echo -n "${section} " fi done if [ ! -e "${OPUSPATH}/${student}/part${part}.txt" ]; then cp ${OPUSPATH}/part.txt ${OPUSPATH}/${student}/part${part}.txt echo -n "part${part}( " pt=1 fi for course in `gn deref ${student}`; do if [ ! -e "${OPUSPATH}/${student}/${course}part${part}.txt" ]; then cat ${OPUSPATH}/keyword0.txt | sed "s/DESIG/${course}/g" | sed "s/NUM/${part}/g" >> ${OPUSPATH}/${student}/part${part}.txt cat ${OPUSPATH}/keyword1.txt | sed "s/DESIG/${course}/g" | sed "s/NUM/${part}/g" >> ${OPUSPATH}/${student}/${course}part${part}.txt echo -n "${course} " fi done if [ ! -z "${pt}" ]; then echo -n ") " fi if [ "`cat ${OPUSPATH}/${student}/part${part}.txt | grep "Experiment ${part}" | wc -l`" -eq 0 ]; then cat ${OPUSPATH}/experiment.txt | sed "s/NUM/${part}/g" >> ${OPUSPATH}/${student}/part${part}.txt echo -n "experiment " fi echo "." done echo "PROCESSING COMPLETE." echo echo "ESTABLISHING PROPER ACCESS CONTROL... " sudo chmod -R u=rwX,g=rwX,o= ${OPUSPATH} sudo chown -R wedge:www-data ${OPUSPATH} echo "OPUS CREATION TASK COMPLETE" exit 0