#!/bin/sh
# Copyright 2002 by Kai 'Oswald' Seidler, oswald@apachefriends.org, GPL-licensed

. /opt/lampp/share/lampp/lampplib

if test "$1" = "check"
then    
        check="true"
else    
        check="false"
fi

lc="/opt/lampp/etc/lampp"
f="/opt/lampp/etc/proftpd.conf"

bon="[1m"
boff="[m"

if egrep "^UserPassword nobody wRPBu8u4YP0CY" $f > /dev/null 2>&1
then
        $check && exit 1

	$de && echo "LAMPP: ${bon}Das FTP-Passwort ist noch auf 'lampp' gestellt.${boff}"
	$de || echo "LAMPP: ${bon}The FTP password is still set to 'lampp'.${boff}"
	if test ! -f $lc/startftp
	then
		$de && echo "LAMPP: (Da aber ProFTPD nicht gestartet wird, ist das auch nicht so schlimm.)"
		$de || echo "LAMPP: (But you didn't use ProFTPD so this is not critical.)"
	fi
	$de && q="Mchtest Du das Pawort ndern?"
	$de || q="Do you want to change the password?"
	ask="asky";
else
        $check && exit 0

	$de && echo "LAMPP: ProFTPD hat ein neues FTP-Passwort. Super!"
	$de || echo "LAMPP: ProFTPD has a new FTP password. Great!"
	$de && q="Mchtest Du trotzdem das Pawort ndern?"
	$de || q="Do you want to change the password anyway?"
	ask="askn";
fi

if $ask "$q"
then
	$de && q="Pawort:"
	$de || q="Password:"
	$de && q2="Pawort (Wiederholung):"
	$de || q2="Password (again):"
	word=`askp "$q" "$q2"`
	$awk -vpw="$word" '
/^UserPassword nobody wRPBu8u4YP0CY/ {
		print "# commented out by lampp security"
		print "#"$0
		print "UserPassword nobody "pw
		next
	}
	{
		print
	}
' $f > /tmp/lampp$$
	cp /tmp/lampp$$ $f
	rm /tmp/lampp$$
	/opt/lampp/lampp reloadftp
fi
