#!/bin/bash

#
# To run this on your own site, put it in a directory that is enabled for cgi-bin,
# and make sure it has the executable bits set (chmod 755 uname.sh).
#
# In Apache, you can enable /usr/lib/cgi-bin/ for URLs beginning /cgi-bin with:
#
#   Include conf-available/serve-cgi-bin.conf
#

echo "Content-type: text/html"
echo ""
echo "<pre>"

# Simplified query parsing, since we only support one parameter.
if [[ $QUERY_STRING == source* ]]; then
    cat $0 | sed -r 's/\&/\&amp;/g' | sed -r 's/</\&lt;/g'
    echo "</pre>"
    echo "# <a href='$SCRIPT_NAME'>script</a>"
else
    echo "Hostname: `hostname`"
    cat /etc/issue
    uname -a
    echo
    echo "</pre>"
    echo "<a href='$SCRIPT_NAME?source=1'>source</a>"
fi

# script