# Attempt is made here to lock in Webmin configuration,
#
# making it more predictable and secure.
# Port and password are generated using week random
# generators, but that may still be better than human.
# These values will be preserved in the compile log,
# making it possible to recover.
#

readonly ALPHABET="1234567890abcdefghijklmnopqrstuvxyz"  &&

config_dir="/etc/webmin"                                 &&
var_dir="/var/log/webmin"                                &&
perl="`which perl`"                                      &&
host="`hostname`"                                        &&
#
# generate port number between 2048 and (16384 - 1)
#
port=$((RANDOM % (16384 - 2048) + 2048))                 &&
os_type="debian-linux"                                   &&
os_version="3.0"                                         &&
real_os_type="Source Mage GNU/Linux"                     &&
real_os_version="1.0"                                    &&
atboot=1                                                 &&
nostart="1"                                              &&
if is_depends_enabled $SPELL net-ssleay; then 
  ssl=1
else
  ssl=0
fi                                                       &&
login="admin"                                            &&
password=""                                              &&
for (( C = 0; C < 8; ++C )) do
password="${password}${ALPHABET:RANDOM % 36:1}"
done                                                     &&
export config_dir var_dir perl host port                 \
os_type os_version real_os_type real_os_version          \
atboot ssl login password nostart                        &&

echo "Default password: $password"                       &&
echo "Default port: $port"                               &&

mkdir  -p       /usr/share/webmin                        &&
cp     -dfR  .  /usr/share/webmin                        &&
cd              /usr/share/webmin                        &&

./setup.sh                                              
#rm  /etc/init.d/webmin
