#!/bin/bash
apt-get -f update
apt-get -f install openssh-server less
apt-get -f install mysql-server build-essential libperl-dev apache2 php5 libapache2-mod-auth-mysql php5-mysql xml-core gettext mcrypt libapache2-mod-php5 php5-cgi php5-mcrypt php5-mhash php5-mysql php-pear php5-xmlrpc php5-curl curl libcurl3-dev pure-ftpd-common pure-ftpd freeradius subversion locales-all perl perl-modules unzip zip zlib1g-dev gcc-4.1-locales debian-keyring freeradius-ldap freeradius-mysql freeradius-krb5 autoconf libnet-ssleay-perl libauthen-pam-perl libio-pty-perl libmd5-perl postfix
pear install XML_RPC
dpkg -i webmin_1.350_all.deb usermin_1.280_all.deb
rm -rvf /etc/rc*d/S*webmin* 
rm -rvf /etc/rc*d/K*webmin* 
rm -rvf /etc/rc*d/S*usermin* 
rm -rvf /etc/rc*d/K*usermin* 
update-rc.d -f webmin defaults 99 01 
update-rc.d -f usermin defaults 99 01 
rm -rvf /etc/freeradius/sql.conf
rm -rvf /etc/freeradius/clients.conf
rm -rvf /etc/freeradius/radiusd.conf
rm -rvf /etc/freeradius/clients
rm -rvf /etc/freeradius/naslist
cp /root/chillidog_install/clients.tmp /etc/freeradius/clients.conf
cp /root/chillidog_install/sql.tmp /etc/freeradius/sql.conf
cp /root/chillidog_install/radiusd.tmp /etc/freeradius/radiusd.conf
cp /root/chillidog_install/chillidog_webdir_002.zip /var/www/
cp /root/chillidog_install/users /etc/freeradius/users
cd /etc/freeradius
chmod 774 *
cd /var/www
unzip chillidog_webdir_002.zip
cp /root/chillidog_install/apache2.conf /etc/apache2/apache2.conf
cp /root/chillidog_install/index.html /var/www/index.html
gunzip /usr/share/doc/freeradius/examples/mysql.sql.gz
cp /root/chillidog_install/php.ini /etc/php5/apache2/php.ini
chmod -R 777 /var/www/*
chmod -R 777 /var/www
mysqladmin -h localhost -u root -pddwrt create radius
mysql -u root -pddwrt radius </var/www/wifi-1.1.1/all.sql
cd /root/chillidog_install
chmod 777 generate-ssl-key.sh
./generate-ssl-key.sh
cd /root/chillidog_install
chmod 777 firmware_mod_kit_install.sh
./firmware_mod_kit_install.sh
mkdir /var/www/cgi-bin
chmod -R 777 /var/www/cgi-bin
wget -O /var/www/cgi-bin/hotspotlogin.cgi http://auth1.ilovemywimax.com/htdocs/dd-wrt/wifi/003/hotspotlogin.cgi
chmod -R 777 /var/www/cgi-bin
eject
reboot
