#! /opt/bin/dash # # os/prog/disk/post.sh # uses non-standard -d,--dups option to avoid consecutive duplicate block requests export PATH="/opt/bin:/bin:/usr/bin" echo "Content-type: text/html\n\ndisk" user=`echo "${REMOTE_USER}" | tr -dc '[:alnum:]' | tr '[:upper:]' '[:lower:]'` if [ -z "$user" ]; then echo "Bad user: ${REMOTE_USER} -> $user"; exit 1; fi if [ -n "$HTTP_HOST" ]; then cd /os/prog/disk || exit 1; fi # tomato = #FF6347 # lightgreen = #90EE90 # in=$(cat | egrep -v '#FF6347|#90EE90') h=$(echo "$in" | awk '{ if( $2 == "P") { print $3; exit; }}') useed=$(echo "$in" | awk '{ if( $2 == "useed") { gsub(/[^0-9]/,"",$3); print $3; exit; }}') #echo "
$in\n
" #exit n="6"; A="$n,-1,0"; R="2"; S="2"; o="1"; z="60,60,60" case "$h" in "SATF") p="SATF"; s="123456789";; *) p="FIFO"; s="123456789";; esac if [ -n "$useed" ]; then seed="$useed" msg="- seed = $seed" else x=$(perl -e "print unpack(\"C*\",$user);"); seed="${s}${x}" #echo "
s = $s, x = $x, seed = $seed
" msg="" fi echo "$user - disk results $msg

green = correct
    red = wrong

Policy = $p

" #echo "

"
#python3 ./disk.py -d -s "$seed" -p "$p" -A "$A" -R "$R" -S "$S" -o "$o" -z "$z" -c
#echo "
" out=$( (echo "$in"; python3 ./disk.py -d -s "$seed" -p "$p" -A "$A" -R "$R" -S "$S" -o "$o" -z "$z" -c) | awk 'BEGIN { v=0; print ""; print ""; } { # each line of user input from disk-post looks like: U name value if( $1 != "") { if( $1 == "U") u[$2]=$3; else if( $1 == "Block:") { gsub(": *",":",$0); split($1,t,":"); b=t[2]; split($2,t,":"); s=t[2]; split($3,t,":"); r=t[2]; x=u["v"v"b"]; if( x != "" && x == b) color="#90EE90"; else color="#FF6347"; print ""; x=u["v"v"s"]; if( x != "" && x == s) color="#90EE90"; else color="#FF6347"; print ""; x=u["v"v"r"]; if( x != "" && x == r) color="#90EE90"; else color="#FF6347"; print ""; print ""; ++v; }}}' ) if [ -z "$useed" ]; then bad=$(echo "$out" | grep "#FF6347" | wc -l) good=$(echo "$out" | grep "#90EE90" | wc -l) log=$(echo "$in" | tr -dc '[:alnum:]') echo "$(date) $user ${p}: good $good bad $bad in: $log" >> log fi echo "$out
BlockSeekRotate
"x"   "x"   "x"  
"