#!/bin/sh
# open the firewall so external host can ftp in

TEMPDIR=/tmp/beezix
CLOSE_SCRIPT=firewall-close

# wait for enter key then exit w/good status
goodexit ()
{
    echo
    echo "Smite the enter key to continue."
    read
    echo
    exit 0
}

# wait for enter key then exit w/bad status
badexit ()
{
    echo
    echo "Whack the enter key to continue."
    read
    echo
    exit 1
}

cat <<DOC_HERE

Opening a major crack in the firewall.  Moving
hosts.allow and hosts.deny to temporary directory
and restarting the network.  In order to allow
ftp login, the user "knoppix" needs a passowrd.

DOC_HERE

echo
if ! sudo passwd knoppix
then
    echo "passwd command failed.  Exiting..."
    badexit
fi

if [ ! -e $TEMPDIR ]
then
    sudo mkdir /tmp/beezix
fi

sudo mv /etc/hosts.allow /tmp/beezix/
sudo mv /etc/hosts.deny /tmp/beezix/

echo
echo "Restarting network..."
echo
sudo /etc/init.d/inetd restart

echo
echo "Done."
echo

cat <<DOC_HERE
You should now be able to ftp in using user
"knoppix" and your new password.  Use an IP
address shown below (if your network is up):

DOC_HERE

ifconfig | grep 'inet addr:' | grep -v '127.0.0.1' |\
    cut -d: -f2 | awk '{ print $1}'

cat <<DOC_HERE

You can close the firewall by running "$CLOSE_SCRIPT"
DOC_HERE

goodexit