# file: setup
# Knoppix add on to setup a LAMP Testserver 
# LAMP = Linux, Apache, Mysql, PHP
# script installs a php web site ready to customize
# installs: phpMyAdmin V. 2.3.2 (newer does nit fit on one diskette)
# installs: FTP service
# how to use this script: 
# open Knoppix root shell, 
# mount /dev/fd0  /mnt/floppy
#   cd /mnt/floppy
#   ./setup

# Autor: hans.klausmann@bwl.fh-regensburg.de

# Mysql Database  at ramdisk install:
cd /ramdisk/var/lib/mysql/mysql
sudo rm -f *
sudo cp /KNOPPIX/var/lib/mysql/mysql/*.*  .
sudo chmod 777 *
# use changed httpd.conf
sudo cp /mnt/floppy/httpd.conf  /ramdisk
# setup link www 
cd /ramdisk/var/www
sudo ln -s /ramdisk/home/knoppix  www
# start apache with new config file 
sudo apache -f /ramdisk/httpd.conf &&
echo "Apache web server running"
# mysql starten
sudo /etc/init.d/mysql start &&
echo "mysql Database running"
echo "Notice: user is root password ist empty!!!"
echo "change this at config.inc.php if not just a testserver"
echo "then restart the Database!!! to make changes alive "
# phpMyAdmin auspacken
echo "unzipping: phpMyAdmin 2.3.2" 
echo "newer Version at www.phpmyadmin.net !!!" &&
unzip -q -d /ramdisk/home/knoppix/ /mnt/floppy/phpMyAdmin-2.3.2.zip &&
# php site auspacken
echo "unzipping test site..."
unzip -q -d /ramdisk/home/knoppix/  /mnt/floppy/site.zip &&
# zip file in web site kopieren (damit zum download erreichbar)
cp /mnt/floppy/site.zip /ramdisk/home/knoppix/site/pages/
# rechte fr counter setzen
chmod 777 /ramdisk/home/knoppix/site/counter/
chmod 777 /ramdisk/home/knoppix/site/counter/counter.txt
chmod 755 /ramdisk/home/knoppix/site/counter/count.cgi

echo " !!! PC now accessable via IP!"
echo "   actual IP adress :"
ifconfig|grep "inet"

# setup ftp access 
cd /etc
rm hosts.allow
cd /ramdisk
cp /mnt/floppy/hosts.allow /ramdisk/
cd /etc
# sym link auf hosts.allow
ln -s /ramdisk/hosts.allow   hosts.allow
inetd
echo "for ftp access we need a new root password!"
echo "pse type 2x  e.g. knoppix"
passwd


#3 browser start
mozilla http://localhost/www/site/  &
mozilla http://localhost/www/phpMyAdmin-2.3.2/  &
mozilla http://localhost/ &

echo "useful commands:"
echo "apache stop : sudo apachectl stop"
echo "apache start: sudo apachectl start"
echo "Prozess list: ps -A"
echo "Mysql stop  : sudo /etc/init.d/mysql stop"
echo "Mysql start : sudo /etc/init.d/mysql start"
echo "more help with: man -k keyword  e.g. man -k mysql"
echo "have fun!"