#!/bin/sh -x

# Added for compatibility with uhttpd
echo -en "Content-type: text/html\r\n\r\n"

#  /www/cgi-bin/config4a.sh
# This script calls config1 script to create the html file
# /www/config4.html then outputs the file to the browser

# Get the Basic Auth logged in user and save in tmp
rm /tmp/auth.txt
if [ `echo $HTTP_AUTHORIZATION | cut -d " " -f 2 | grep cm9vdDph` ]; then echo "root" > /tmp/auth.txt; fi
if [ `echo $HTTP_AUTHORIZATION | cut -d " " -f 2 | grep YWRtaW46` ]; then echo "admin" > /tmp/auth.txt; fi

# Generate the configuration page
/www/cgi-bin/config/config4.sh

# Send the page back to the browser
cat /tmp/config4.html

# Remove old generated files files 
#rm /tmp/config4.html >> /dev/null
