#!/bin/bash . settings if [[ $REQUEST_METHOD != POST ]] then cat <<-EOHead Content-type: text/plain Last-Modified: $(LC_ALL=C TZ=GMT date +'%a, %d %b %Y %X %Z') Expires: $(LC_ALL=C TZ=GMT date +'%a, %d %b %Y %X %Z') refresh: 0,url=/cgi/$webuser/add.html EOHead exit fi declare -A POST exprdsname='^[[:upper:][:lower:]_]+$' exprvalue='^-?[[:digit:]]+$' while read dsname value do if [[ $dsname =~ $exprdsname ]] \ && [[ $value =~ $exprvalue ]] then POST["$dsname"]="$value" fi done < <( sed 's/&/\n/g;s/=/ /g' ) cat <<-EOHead Content-type: text/plain Last-Modified: $(LC_ALL=C TZ=GMT date +'%a, %d %b %Y %X %Z') Expires: $(LC_ALL=C TZ=GMT date +'%a, %d %b %Y %X %Z') refresh: 0,url=/cgi/$webuser/?start=${POST["start"]}&end=${POST["end"]} EOHead if [[ $webuser == $AUTH_USER || $webuser == dev ]] then echo "Welcome agent $webuser"$'!\n\n' else echo 'Nice try!' exit fi data=N for dsname in "${dsnames[@]}" do data+=:${POST["$dsname"]:=U} echo "$dsname....${POST["$dsname"]}" done rrdtool update ingress.rrd "$data" if [ -n "$CACHE_DIR" ] then find "$CACHE_DIR" -type f -delete echo $'\nCache cleared!' fi