#! /bin/sh # # update2.sh for testing only, 25 Aug. 2007 # # update project file # # this script is invoked via chroot+setuidgid # # cwd is $top/$sub # # R. Perry, Aug. 2003 # # ZZ marks local customization sections PATH="/usr/bin"; export PATH mode="$1" user="$2" sub="$3" file="$4" args="$5" ### # function to display subdir, home menu # menu1() { echo "${sub} - Home - preproc - asm - asmopt - cerr - reload - +linenums - -linenums
" # ZZ # echo "

Note: this environment will be shut down after May 9, # then will be available again, read-only, later next week.

" } ### # function to display compile/run menu # menu2() { echo "

Compile args:
" } ### # function to display Update menu # # menu3() { echo " <-save changes " } case "$mode" in update) #UCR |update_compile|update_compile_run # # make backup, copy file # rm -f "$file.OLD" mv "$file" "$file.OLD" case "$file" in Makefile) tr -d '\r' | sed -e 's/^ / /' -e '/^$/d' > "$file" ;; *) tr -d '\r' | sed -e '/^$/d' > "$file" ;; esac ;; upload) # # make backup, upload file # read boundary while read header do if [ -z "$header" ]; then break fi done tmpfile="upload.$$" rm -f "$tmpfile" sed -e '/^$/d' -e "/^$boundary/,\$d" > "$tmpfile" # if [ -s "$tmpfile" ]; then rm -f "$file.OLD" mv "$file" "$file.OLD" mv "$tmpfile" "$file" else rm -f "$tmpfile" fi ;; copy) # # make backup, copy file # read fname fpath="/htdocs/perry/$fname" # if [ -n "$fname" -a -r "$fpath" ]; then rm -f "$file.OLD" mv "$file" "$file.OLD" cp "$fpath" "$file" fi exit 0 ;; edit|plinenums|mlinenums) # # create links as needed, display edit page # for p in ../../../proto/${sub}/* do f=`basename "$p"` if [ ! -r "$f" ]; then ln -s "$p" "$f" fi done # # dynamically create additional files here... # # if [ ! -r "$file" ]; then # touch "$file" # fi # if [ ! -r "$file" ]; then case "$COURSE" in # ZZ # ccs) case "$sub" in a3) case "$file" in p1.java) /vecr/ccs/a3/p1.sh "$user" > p1.java ;; *) touch "$file" ;; esac ;; *) touch "$file" ;; esac ;; # fc) case "$sub" in a2) case "$file" in p4.c) /vecr/fc/a2/p4.sh "$user" > p4.c ;; *) touch "$file" ;; esac ;; # t3) case "$file" in # p1.c|p2.c|p3.c|p4.c) /vecr/fc/t3/get.sh "$user" "$file" > "$file" ;; # esac # ;; *) touch "$file" ;; esac ;; # *) touch "$file" ;; # esac fi # # echo "Content-type: text/html\n" echo "${user} - ${COURSE} - ${sub}/${file}

${user} - ${COURSE} - ${sub}/${file} - submit - view submissions" # if [ "$sub" = "HTML" ]; then case "$file" in *.sh|*.c|*.java) echo " (run output Content-Type will be HTML)" ;; esac # #ZZ also check run.sh # # elif [ "$COURSE" = "osp" -a "$sub" = "a9" ]; then # case "$file" in # *.sh|*.c) echo " (run output Content-Type will be HTML)" # ;; # esac fi # case "$file" in Makefile) echo " (leading blank will be converted to tab)" ;; esac # echo "

" # # ZZ # # if [ "${COURSE}" = "fc" -a "$sub" = "a10" ]; then # echo "*** assignment #10 was collected May 6, 06:47 AM ***

" # fi # menu1 menu2 echo "

" menu3 echo "args:

" menu3 echo "
" menu2 menu1 echo "
" # case "$COURSE" in # ZZ osp) echo "
" ;; fc) case "$file" in *.c) echo "
" ;; *.txt) echo "
" ;; esac ;; esac # echo "" ;; *) echo "Content-type: text/plain\n" echo "Bad mode" exit 1 ;; esac