#!/bin/sh

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

#  /www/cgi-bin/secn
# This script calls config1 script to create the html file
# /tmp/config1.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/config1.sh

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

# Remove old generated files files 
rm /tmp/config1.html >> /dev/null
#rm /tmp/config3.sh >> /dev/null
