Installation Script for Ubuntu (32 Bit)


#!/bin/bash

clear
getconf LONG_BIT

sqlpass=”radius”
wwwpath=”/var/www”
radhost=”localhost”
raduser=”radius”
myusr_rad=”radius”
mypsw_radius=”radius123″
myusr_cts=”conntrack”
mypsw_cts=”conn123″
httpuser=”www-data”
rmver40=”radiusmanager-4.0.4.tgz”
rmver41=”radiusmanager-4.1.0.tgz”

osver=cat /etc/issue |awk ‘{print $1}’

rmurl=”http://talhaali.byethost13.com/files/rm_related/

if [[ $osver == Ubuntu ]]; then
echo
lsb_release -a
sleep 3
else
exit 1
fi
echo
FILE=”/tmp/out.$$”
GREP=”/bin/grep”
if [ “$(id -u)” != “0” ]; then
echo
exit 1
fi

temp=”temp”
{
if [ ! -d “/temp” ]; then
echo
mkdir /temp
else
echo
echo
fi
}

cd /$temp
rm -fr /temp/radiusmanager.
rm -fr /temp/freeradius.
rm -fr /temp/libltd.
rm -fr /temp/ioncube.
sleep 5
echo
cd /temp
wget -q $rmurl/rm4.txt
{
if [ ! -f /temp/rm4.txt ]; then
echo
exit 0
fi
}
rm -fr /temp/rm4.txt
sleep 6

clear

echo
echo “1. Radius Manager 4.1.5”
echo “2. Radius Manager 4.1.6”
echo
echo -n “Choose an option: [1]”
if [ -z “$rmver” ]; then
rmver=”1″
fi
case $rmver in

1) echo “Selected RM version is: 4.0.4″
echo .
defver=”radiusmanager-4.0.4.tgz”
defverdir=”radiusmanager-4.0.4″
sleep 5
wget $rmurl/$defver
;;

2) echo “Selected RM version is: 4.1.0″
defver=”radiusmanager-4.1.0.tgz”
defverdir=”radiusmanager-4.1.0″
echo .
sleep 5
wget $rmurl/$defver
;;

*) echo “Invalid selection. Installation aborted”
echo
exit
;;
esac
{
if [ ! -f /$temp/$defver ]; then
echo .
exit 0
fi
}

echo
sleep 5
apt-get update

echo .
sleep 5

apt-get -y install mc wget rcconf make gcc mysql-server mysql-client libmysqlclient15-dev libperl-dev curl php5 php5-mysql php5-cli php5-curl php5-mcrypt php5-gd php5-snmp apache2

sleep 5
cd /$temp
wget http://www.dmasoftlab.com/cont/download/libltdl3_1.5.24-1ubuntu1_i386.deb
wget http://www.dmasoftlab.com/cont/download/libltdl3-dev_1.5.24-1ubuntu1_i386.deb
dpkg -i libltdl3_1.5.24-1ubuntu1_i386.deb
dpkg -i libltdl3-dev_1.5.24-1ubuntu1_i386.deb

echo .
sleep 5
wget http://www.dmasoftlab.com/cont/download/ioncube_loaders_lin_x86.tar.gz
{
if [ ! -f /$temp/ioncube_loaders_lin_x86.tar.gz ]; then
echo .
exit 0
fi
}
tar zxvf ioncube_loaders_lin_x86.tar.gz
mkdir /usr/local/ioncube
cd /$temp/ioncube
cp -fr * /usr/local/ioncube/

echo .
sleep 5
echo “zend_extension=/usr/local/ioncube/ioncube_loader_lin_5.3.so” >> /etc/php5/apache2/php.ini
echo “zend_extension=/usr/local/ioncube/ioncube_loader_lin_5.3.so” >> /etc/php5/cli/php.ini

cd /$temp
echo .
sleep 5
wget http://www.dmasoftlab.com/cont/download/freeradius-server-2.2.0-dma-patch-2.tar.gz
Checking if FREERADIUS is downloaded
{
if [ ! -f /$temp/freeradius-server-2.2.0-dma-patch-2.tar.gz ]; then
echo .
exit 0
fi
}
echo .
sleep 5
tar zxvf freeradius-server-2.2.0-dma-patch-2.tar.gz
cd freeradius-server-2.2.0/
./configure
make
make install
radiusd -X
ldconfig

chown $httpuser /usr/local/etc/raddb
chown $httpuser /usr/local/etc/raddb/clients.conf

echo .
sleep 1
mysql -u root -p$sqlpass -e “create database radius”;
mysql -u root -p$sqlpass -e “create database conntrack”;
mysql -u root -p$sqlpass -e “CREATE USER ‘$myusr_rad’@’$radhost’ IDENTIFIED BY ‘$mypsw_radius’;”
mysql -u root -p$sqlpass -e “CREATE USER ‘$myusr_cts’@’$radhost’ IDENTIFIED BY ‘$mypsw_cts’;”
mysql -u root -p$sqlpass -e “GRANT ALL ON radius.* TO radius@$radhost;”
mysql -u root -p$sqlpass -e “GRANT ALL ON conntrack.* TO conntrack@$radhost;”

cd /$temp
tar zxvf $defver
cd /$temp/$defverdir
echo .
sleep 5

echo Copying Radius Manager WEB content to $wwwpath/radiusmanager
cp -fr www/radiusmanager $wwwpath
cp $wwwpath/radiusmanager/config/paypal_cfg.php.dist $wwwpath/radiusmanager/config/paypal_cfg.php
mv $wwwpath/radiusmanager/config/paypal_cfg.php.dist $wwwpath/radiusmanager/config/paypal_cfg.php
mv $wwwpath/radiusmanager/config/netcash_cfg.php.dist $wwwpath/radiusmanager/config/netcash_cfg.php
mv $wwwpath/radiusmanager/config/authorizenet_cfg.php.dist $wwwpath/radiusmanager/config/authorizenet_cfg.php
mv $wwwpath/radiusmanager/config/dps_cfg.php.dist $wwwpath/radiusmanager/config/dps_cfg.php
mv $wwwpath/radiusmanager/config/2co_cfg.php.dist $wwwpath/radiusmanager/config/2co_cfg.php

chown $httpuser $wwwpath/radiusmanager/config
chown $httpuser $wwwpath/radiusmanager/config/system_cfg.php
chown $httpuser $wwwpath/radiusmanager/config/paypal_cfg.php
chown $httpuser $wwwpath/radiusmanager/config/netcash_cfg.php
chown $httpuser $wwwpath/radiusmanager/config/authorizenet_cfg.php
chown $httpuser $wwwpath/radiusmanager/config/dps_cfg.php
chown $httpuser $wwwpath/radiusmanager/config/2co_cfg.php
chown $httpuser $wwwpath/radiusmanager/tftpboot
chmod 600 $wwwpath/radiusmanager/config/system_cfg.php
chmod 600 $wwwpath/radiusmanager/config/paypal_cfg.php
chmod 600 $wwwpath/radiusmanager/config/netcash_cfg.php
chmod 600 $wwwpath/radiusmanager/config/authorizenet_cfg.php
chmod 600 $wwwpath/radiusmanager/config/dps_cfg.php
chmod 600 $wwwpath/radiusmanager/config/2co_cfg.php
chmod 644 $wwwpath/radiusmanager/config/docsis_keyfile
chmod 644 $wwwpath/radiusmanager/config/docsis_template

mkdir /var/www/radiusmanager/tmpimages
chown $httpuser $wwwpath/radiusmanager/tmpimages
chmod 755 bin/rm*
cp -fr bin/rm* /usr/local/bin
cp -fr bin/rootexec /usr/local/sbin
chmod 4755 /usr/local/sbin/rootexec
cp -fr etc/radiusmanager.cfg /etc
chown root /etc/radiusmanager.cfg
chmod 600 /etc/radiusmanager.cfg
cp -fr rc.d/rmpoller /etc/init.d
chown root.root /etc/init.d/rmpoller
chmod 755 /etc/init.d/rmpoller
update-rc.d rmpoller defaults 99
cp -fr rc.d/rmconntrack /etc/init.d
chown root.root /etc/init.d/rmconntrack
chmod 755 /etc/init.d/rmconntrack
update-rc.d rmconntrack defaults 99
chmod 755 rc.d/debian/radiusd
cp -fr rc.d/debian/radiusd /etc/init.d
update-rc.d radiusd defaults 99
cp -fr etc/logrotate.d/radiusd /etc/logrotate.d/radiusd
cp -fr etc/cron/radiusmanager /etc/cron.d/radiusmanager
chmod 644 /etc/cron.d/radiusmanager

echo .
sed -i ‘s/var\/lib\/mysql\/mysql.sock/var\/run\/mysqld\/mysqld.sock/g’ /etc/radiusmanager.cfg
sed -i ‘s/var\/www\/html/var\/www/g’ /etc/radiusmanager.cfg
sed -i ‘s/var\/www\/html/var\/www/g’ /etc/cron.d/radiusmanager
sed -i ‘s/var\/www\/html/var\/www/g’ /var/www/radiusmanager/config/system_cfg.php

chown $httpuser /usr/local/etc/raddb
chown $httpuser /usr/local/etc/raddb/clients.conf

service radiusd start
service apache2 restart
service mysql restart

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s