Syed Jahanzaib Personal Blog to Share Knowledge !

January 29, 2014

WEBMIN Tips

Filed under: Linux Related — Tags: , , — Syed Jahanzaib / Pinochio~:) @ 1:56 PM

Webmin-Logo-600

 

webmin-error

If your webmin account is locked out due to too many wrong attempts, then simply wait at least 10-15 minutes, or issue following commands to login quickly.

/etc/init.d/webmin restart

If you are unable to login with the root id  on webmin

use following.

cd /usr/share/webmin
./changepass.pl /etc/webmin/ root newrootpassword

WEBMIN installation in Ubuntu using apt-get

I assumed that you have installed and configure your Linux box (preferably Ubuntu, but any flavor can do the job, this is the main quality of Linux OS :)~ To install Webmin , first add its repositories to sources.list, to do this first open sources.list


nano /etc/apt/sources.list

Now paste the following lines in the end of this file.

deb http://download.webmin.com/download/repository sarge contrib
deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib
deb http://archive.canonical.com/ lucid partner

Save & Exit.

Now update apt-get and install webmin using


apt-get update
apt-get install webmin

It will take some time to install webmin depend on your internet connection (usually less then 10 minutes) , afterward you can access it using

https://yourlinuxboxip:10000

(TIP: you can change the webmin port by editing in /etc/webmin/miniserv.conf and change the port number to any port you like, for example 443 or 1234)

January 10, 2014

Clear Memory in Linux Box

Filed under: Linux Related — Tags: , , — Syed Jahanzaib / Pinochio~:) @ 11:23 AM

atemyram

Clear Memory in Linux (specially for squid servers)

If you are hosting SQUID proxy server on your Linux box, you may have noticed that SQUID as a proxy server is very greedy with memory. Over the period of time, it consumes large amount of memory , even in some cases 98-99%.

This script will clear the memory so that it be used by system or SQUID again. Make sure you are logged in with root user in order to continue.

Just create a new script and put it in any folder like /temp

Create File by following command

mkdir /temp
cd /temp
touch clearmem.sh
touch /var/log/cron.log
chmod +x clearmem.sh

Now edit the file by

nano /temp/clearmem.sh

.

And Paste the following code.

#!/bin/bash
# Clear/Dump Cache Memory, to increase free memory, useful for SQUID proxy OR for general purposes.
# Syed Jahanzaib / Email: aacable@hotmail.com  Web: https://aacable.wordpress.com
# Make sure you are Logged in with user root.

# Setting variables for script
set $(date)
time=`date |awk '{print $4}'`

# Action . . .
sync;
echo 3 > /proc/sys/vm/drop_caches

# Add entry in /var/log/cron.log to make record.
echo [Jz] Cache Memory Clear, Action Logged at  $6-$2-$3 $time > /var/log/cron.log

.

Save, and Exit.

Now change the permission so it can be executed.

chmod 755 /temp/clearmem.sh

.

Now first execute

free -m

and note down the free memory,

Now execute the file by running …

/temp/clearmem.sh

check the log file by
cat /var/log/cron.log

Now again check the free amount from terminal with the command

free -m

.

And you will see the changes before and after running the file clearmem.sh

.

Howto schedule this file to run daily/hourly using ‘crontab’

To run this file on hourly basis, open terminal, (make sure you are logged in with the root user.
type

crontab -e

(if it asks for text editor, select nano ,)

Now paste following code …

@daily  /temp/clearmem.sh       # Run Daily in night at 00:00 hours
#
@hourly  /temp/clearmem.sh   # Enable this if you want to run the script on hourly basis 

Now, based on above selection, cron job will run this command at selected scheduled timings and clear any memory cache

Now some Explanation of what above script do . . .

It will cause the kernel to drop clean caches, dentries and inodes from memory, causing that memory to become free.

*  sync only makes dirty cache to clean cache. cache is still preserved.
* drop_caches doesn’t touch dirty caches and only drops clean caches. So to make all memory free, it is necessary to do sync first before drop_caches in case flushing daemons hasn’t written the changes to disk.

This is in generally a non-destructive operation.

.
Regard’s
Syed Jahanzaib

January 9, 2014

Lotus Domino SMTP relay

Filed under: IBM Related — Tags: , — Syed Jahanzaib / Pinochio~:) @ 1:48 PM

lotus

It’s not a new story, but today I had to do it again to restore our email relay successfully. so I am writing this just as a reference.

Recently we were having some issues in sending emails to various domains , in some particular case, our Public IP was blacklisted at one or two spam lists. To sort it out, we used our ISP’s SMTP (example: smtp.yoursip.com.pk)to relay mails successfully. Here is how you can add/change the relay host.

  • From the Domino Administrator, click the Configuration tab and then expand the Messaging section.
  • Choose Configurations.
  • Select the Configuration Settings document and then click Edit Configuration.
  • Click the Router/SMTP Basics tab.
  • Complete this field, and then click Save & Close:

Field  
Relay host for messages leaving the local Internet domain

As showed in the image below . . .

123.

To take changes take effect immediately, issue this command at domino admin client

tell router update config

To remove relay host, simply remove the smtp entry and reload config.

.

Regard’s
Syed Jahanzaib

January 5, 2014

Automated Installation Script for Squid 2.7 Stable 9 with Video Caching support

Filed under: Linux Related — Tags: , — Syed Jahanzaib / Pinochio~:) @ 2:24 AM

squid

For updated video caching support witgh Youtube, you can use LUSCA as it is working fine (as of July 2014)

https://aacable.wordpress.com/2014/04/21/howto-cache-youtube-with-squid-lusca-and-bypass-cached-videos-from-mikrotik-queue/

 


 






 

Following is an automated script to install SQUID 2.7 Stable 9 for UBUNTU with aggressive contents & few video web sites video caching support as described in my other article @
https://aacable.wordpress.com/2012/01/19/youtube-caching-with-squid-2-7-using-storeurl-pl/

I will add more n more functions as soon as I get some free time, like configurable options via choice menu like cache size, mem, and other variables.

Revision History . . .

[ 6th January, 2014]    Removed few bugs including “unable to start squid” error in end, while actually squid is running
[ 7th January, 2014]    Download URL have been changed to http://aacable.rdo.pt/files/linux_related
[ 8th January, 2014]    O.S check for UBUNTU added
[ 8th January, 2014]    root user check added
[ 8th January, 2014]    Function added to remove previously downloaded files in /temp folder to avoid duplication
[ 8th January, 2014]    Internet and $URL availability check
[ 20th January, 2014]  Few refresh patterns + storeurl.pl updated for better YT HIT
[ 29th January, 2014]  aacable.rdo.pt was down dueto quota limit, now added secondary link URL2 = http://wifismartzone.com/files/linux_related/
[ 30th January, 2014]  64bit installation issue fixed.

SCRIPT FUNCTIONS . . . 

This script will do the following

– First it will ask you if you want 32bit or 64 squid compile options
– Update Ubuntu
– Install some components required for Compilation of squid package
– Backup squid.conf if already in /etc/squid.conf with squid.conf.old, stop any running squid instance
– Download Squid 2.7 stable 9 source package to /temp folder and compile it
– Download squid.conf and storeurl.pl from the internet and place them in /etc/squid.conf
– Create cache directory like in /cache-1 and default cache size is 10 GB
– add squid in /etc/rc.local so it may start auto upon system reboot  [added: 5th January, 2014]

Note: You should modify all options in /etc/squid.conf after installation , like cache_dir, cache_mem and others as per your network and hardware specifications.

.

REQUIREMENTS . . .

1- Fresh Installation of UBUNTU OS and Configure Internet Access
2- root access to execute script
3- REMOVE ANY KIND OF PREVIOUSLY INSTALLED SQUID INSTALLATION IF ANY
4- Upload or create script in any folder of Ubuntu box,

or create new script with following commands

mkdir /temp
cd /temp
touch squid_2.7.9_install.sh
chmod +x squid_2.7.9_install.sh

nano squid_2.7.9_install.sh

and paste the following code . . .


#!/bin/bash
# Version 1.3 / 31st January, 2014
# SQUID 2.7 Stable9 Automated Installation Script for Ubuntu 10/12 32bit Edition
# Syed Jahanzaib / aacable @ hotmail.com  / https://aacable.wordpress.com

# Setting Variables . . . [JZ]
#URL=http://aacable.rdo.pt/files/linux_related/
URL=http://wifismartzone.com/files/linux_related/
SQUID_DIR="/etc/squid"
CACHE_DIR="/cache-1"
pid=`pidof squid`
osver=`cat /etc/issue |awk '{print $1}'`

# Colors Config  . . . [[ JZ . . . ]]
ESC_SEQ="\x1b["
COL_RESET=$ESC_SEQ"39;49;00m"
COL_RED=$ESC_SEQ"31;01m"
COL_GREEN=$ESC_SEQ"32;01m"

# OS checkup for UBUNTU
echo -e "$COL_GREEN Squid 2.7.9 Automated Installation Script ver 1.3 for Ubuntu . . .$COL_RESET"
echo -e "$COL_GREEN Checking OS version, as it must be Ubuntu in order to Continue . . .$COL_RESET"
if [[ $osver == Ubuntu ]]; then
echo
echo -e "$COL_GREEN Ubuntu is installed with following information fetched. $COL_RESET"
lsb_release -a
sleep 3
else
echo -e "$COL_RED Sorry, it seems your Linux Distribution is not UBUNTU . Exiting ...$COL_RESET"
exit 1
fi

# Make sure only root can run our script / Checking if user is root, otherwise exit with error [[Jz]]
echo
echo -e "$COL_GREEN Verifying if you are logged in with root privileges  . . .$COL_RESET" 1>&2
FILE="/tmp/out.$$"
GREP="/bin/grep"
if [ "$(id -u)" != "0" ]; then
echo
echo -e "$COL_RED This script must be run as root, switch to root now . . .$COL_RESET" 1>&2
exit 1
fi

# Clearing previous download if any in /temp folder
echo
echo -e "$COL_GREEN Clearing previous downloads if any in /temp folder to avoid duplication$COL_RESET"
sleep 3
rm -fr /temp/squid.conf
rm -fr /temp/storeurl.txt
rm -fr /temp/storeurl.pl
rm -fr /temp/squid-2.7.STABLE9*

# Checking IF $URL is accessible m if YES then continue further , otherwise EXIT the script with ERROR ! [[ JZ .. . .]]
echo
echo -e "$COL_GREEN Checking if $URL is accessible in order to proceed further. . .!! $COL_RESET"
cd /temp
wget -q $URL/squid.conf
{
if [ ! -f /temp/squid.conf ]; then
echo
echo -e "$COL_RED ERROR: Unable to contact $URL, or possibly itnernet is not working or your IP is in black list at destination server  !! $COL_RESET"
echo -e "$COL_RED ERROR: Please check manual if $URL is accessible or not or if it have required files, JZ  !! $COL_RESET"
exit 0
fi
}
rm -fr /temp/squid.conf
sleep 6
# Moving further . . .

clear
echo -e "$COL_GREEN You are logged in with root ID, Ok to proceed further . . .!! $COL_RESET"
echo
#################################################################
# Selection choice of SQUID 2.7  32bit or 64bit architecture [zaib]
echo -e "$COL_GREEN ********************************************** $COL_RESET"
echo -e "$COL_GREEN   Select the type of your OS Architecture JZ   $COL_RESET"
echo -e "$COL_GREEN ********************************************** $COL_RESET"
echo
echo
echo "1. 32bit Ububtu [If you have 32bit OS]"
echo "2. 64bit ubuntu [If you have 64bit OS]"
echo
echo -n "Choose an option: [1] "

read squidchoice
if [ -z "$squidchoice" ]; then
squidchoice="1"
fi
case $squidchoice in
1 ) echo "Selected Squid version is 32bit"
squidver="./configure --prefix=/usr --exec_prefix=/usr --bindir=/usr/sbin --sbindir=/usr/sbin --libexecdir=/usr/lib/squid --sysconfdir=/etc/squid --localstatedir=/var/spool/squid --datadir=/usr/share/squid --enable-async-io=24 --with-aufs-threads=24 --with-pthreads --enable-storeio=aufs --enable-linux-netfilter --enable-arp-acl --enable-epoll --enable-removal-policies=heap,lru --with-aio --with-dl --enable-snmp --enable-delay-pools --enable-htcp --enable-cache-digests --disable-unlinkd --enable-large-cache-files --with-large-files --enable-err-languages=English --enable-default-err-language=English --with-maxfd=65536"
squidlabel="Squid 32bit"
sleep 1
;;
2 ) echo "Selected Squid version is 64bit"
squidver="./configure --prefix=/usr --exec_prefix=/usr --bindir=/usr/sbin --sbindir=/usr/sbin --libexecdir=/usr/lib/squid --sysconfdir=/etc/squid --localstatedir=/var/spool/squid --datadir=/usr/share/squid --enable-async-io=24 --with-aufs-threads=24 --with-pthreads --enable-storeio=aufs --enable-linux-netfilter --enable-arp-acl --enable-epoll --enable-removal-policies=heap,lru --with-aio --with-dl --enable-snmp --enable-delay-pools --enable-htcp --enable-cache-digests --disable-unlinkd --enable-large-cache-files --with-large-files --enable-err-languages=English --enable-default-err-language=English --with-maxfd=65536 --enable-carp --enable-follow-x-forwarded-for --with-maxfd=65536 build_alias=amd64-debian-linux host_alias=amd64-debian-linux target_alias=amd64-debian-linux"
squidlabel="Squid 64bit"

echo .
sleep 3

# If typ anythign other then 1 adn 2, then give invalid error message and exit [zaib]
;;
* ) echo "Invalid selection. Installation aborted."
echo
exit
;;
esac

################################################################## [zaib]
echo
echo -e "$COL_GREEN Updating Ubuntu first . . . !! $COL_RESET"
apt-get update

echo
echo

echo -e "$COL_GREEN Installing required components . . . !! $COL_RESET"
sleep 3
apt-get -y install gcc build-essential sharutils ccze libzip-dev automake1.9

# Clearing OLD data files . . .
{
if [ -f $SQUID_DIR/squid.conf ]; then
echo
echo
echo -e "$COL_RED Previous SQUID configuration file found in $SQUID_DIR ! renaming it for backup purpose . . . $COL_RESET"
mv $SQUID_DIR/squid.conf $SQUID_DIR/squid.conf.old
else
echo
echo
echo -e "$COL_GREEN No Previous Squid configuration have been found in $SQUID_DIR. Proceeding further $COL_RESET"
fi
}

# Checking SQUID status if its already running - check by PID
if [ "$pid" == "" ]; then
echo
echo
echo -e "$COL_GREEN No SQUID instance found in memory , so it seems we are good to GO !!! $COL_RESET"
else
echo
echo -e "$COL_RED SQUID is already running, probably you have some previous copy of SQUID installation, Better to stop and remove all previous squid installation !! $COL_RESET"
echo
echo -e "$COL_RED KILLING PREVIOUS SQUID INSTANCE by killall -9 squid command  !! $COL_RESET"
killall -9 squid
sleep 3
fi

# Downloading Squid source package [zaib]
echo
echo
echo -e "$COL_GREEN Downloading SQUID source package in /temp folder. . . !! $COL_RESET"
sleep 3

# Checking if /temp folder is previously present or not . . .
{
if [ ! -d "/temp" ]; then
echo
echo
echo -e "$COL_RED /temp folder not found, Creating it so all downlaods will be placed here  . . . $COL_RESET"
mkdir /temp
else
echo
echo -e "$COL_GREEN /temp folder is already present , so no need to create it, Proceeding further . . . $COL_RESET"
fi
}

cd /temp

# Checking IF SQUID 2.7 Stable9 installation file have been ALREADY downloaded in /temp to avoid duplication! [[ JZ .. . .]]
{
if [ -f /temp/squid-2.7.STABLE9+patch.tar.gz ]; then
rm -fr /temp/squid-2.7.STABLE9+patch.tar.gz
fi
}

wget https://mikrotik-squid.googlecode.com/files/squid-2.7.STABLE9%2Bpatch.tar.gz

# Checking IF SQUID 2.7 Stable9 installation file have been downloaded properly. if YEs continue further , otherwise EXIT the script with ERROR ! [[ JZ .. . .]]
{
if [ ! -f /temp/squid-2.7.STABLE9+patch.tar.gz ]; then
echo
echo

echo -e "$COL_RED ERROR: SQUID source code package File could not be download or not found in /temp/ !! $COL_RESET"
exit 0
fi
}
echo
echo

echo -e "$COL_GREEN Extracting Squid from tar archive. . . !! $COL_RESET"
sleep 3
tar zxvf squid-2.7.STABLE9+patch.tar.gz
cd squid-2.7.STABLE9
mkdir /etc/squid

echo -e "$COL_GREEN Executing $squidlabel Compiler which you have selected architecture type in start menu . . . !! $COL_RESET"
$squidver
echo
echo
echo -e "$COL_GREEN Executing MAKE and MAKE INSTALL commands . . . !! $COL_RESET"
sleep 3
make
make install
echo
echo

echo -e "$COL_GREEN Creating SQUID LOGS folder and assiging permissions . . . !! $COL_RESET"
sleep 3

# Checking if log folder is previously present or not . . .
{
if [ -d "/var/log/squid" ]; then
echo
echo
echo -e "$COL_GREEN LOGS folder found. No ned to create, proceeding ruther . . . $COL_RESET"
else
echo
echo
echo -e "$COL_GREEN Creating LOG Folder in /var/log/squid and setting permissions accordingly (to user proxy) $COL_RESET"
mkdir /var/log/squid
fi
}

chown proxy:proxy /var/log/squid

## ** DOWNLOAD SQUID.CONF
echo
echo
echo -e "$COL_GREEN Downloading SQUID.CONF file from $URL and copy it to $SQUID_DIR. . . !! $COL_RESET"
sleep 3

# Checking IF SQUID.CONF File have been ALREADY downloaded in /temp to avoid duplication! [[ JZ .. . .]]
{
if [ -f /temp/squid.conf ]; then
rm -fr /temp/squid.conf
fi
}

cd /temp
wget $URL/squid.conf

# Checking IF SQUID.CONF file have been downloaded. if YEs continue further , otherwise EXIT the script with ERROR ! [[ JZ .. . .]]
{
if [ ! -f /temp/squid.conf ]; then
echo
echo
echo -e "$COL_RED ERROR: SQUID.CONF File could not be download or not found in /temp/ !! $COL_RESET"
exit 0
fi
}
cp -fr squid.conf $SQUID_DIR

## ** DOWNLOAD SQUID.CONF
echo
echo
echo -e "$COL_GREEN Downloading STOREURL.PL file from $URL and copy it to $SQUID_DIR. . . !! $COL_RESET"
sleep 3
cd /temp

{
if [ -f /temp/storeurl.txt ]; then
rm -fr /temp/storeurl.txt
fi
}

wget $URL/storeurl.txt

{
if [ -f /temp/storeurl.pl ]; then
rm -fr /temp/storeurl.pl
fi
}

mv storeurl.txt storeurl.pl

# Checking IF STOREURL.PL file have been downloaded. if YEs continue further , otherwise EXIT the script with ERROR ! [[ JZ .. . .]]
{
if [ ! -f /temp/storeurl.pl ]; then
echo
echo
echo -e "$COL_RED ERROR: STOREURL.PL File could not be download or not found in /temp/ !! $COL_RESET"
exit 0
fi
}
cp -fr storeurl.pl $SQUID_DIR

echo
echo
echo -e "$COL_GREEN Setting EXECUTE permission for storeurl.pl . . . !! $COL_RESET"
chmod +x $SQUID_DIR/storeurl.pl

# Creating CACHE folders
echo
echo
echo -e "$COL_GREEN Creating CACHE directory in $CACHE_DIR , in this example,I used 10GB for cache, adjust it accordingly  . . . !! $COL_RESET"
sleep 3

# Checking if /cache-1 folder exist  . . .
{
if [ ! -d "$CACHE_DIR" ]; then
echo
echo
echo -e "$COL_GREEN Creating cache folder in $CACHE_DIR , Default size is 10GB, you should set it accordingly to your requirements  . . . $COL_RESET"
mkdir $CACHE_DIR
chown proxy:proxy $CACHE_DIR
squid -z
chmod 777 -R $CACHE_DIR
else
echo
echo -e "$COL_RED $CACHE_DIR folder already exists , Clearing it before proceeding. . . $COL_RESET"
rm -fr $CACHE_DIR/*
chown proxy:proxy $CACHE_DIR
echo -e "$COL_GREEN $CACHE_DIR Initializing Cache Directories as per the config  . . . $COL_RESET"
echo
squid -z
chmod 777 -R $CACHE_DIR
fi
}

echo
echo
echo -e "$COL_GREEN Adding squid in /etc/rc.local for auto startup . . . !! $COL_RESET"
sed -i '/exit/d' /etc/rc.local
sed -i '/[/usr\/sbin\/squid]/d' /etc/rc.local
echo /usr/sbin/squid >> /etc/rc.local
echo exit 0 >> /etc/rc.local
echo
echo -e "$COL_GREEN Starting SQUID (and adding 10 seconds Pause for proper initialization). . . !! $COL_RESET"
squid
sleep 5

# Checking SQUID status via PID [zaib]
#if [ "$pid" == "" ]; then
#echo
#echo -e "$COL_RED ERROR: UNABLE to start SQUID, try to run with -d1N syntax and see where its showing error !! $COL_RESET"
#else
ps aux |grep squid
echo
echo -e "$COL_GREEN $squidlabel is Running OK with PID number "$pid", no further action required, EXITING  . . .$COL_RESET"
echo
echo To view squid web access activity log, use command
echo -e "$COL_GREEN tail -f /var/log/squid/access.log $COL_RESET"
echo OR
echo -e "$COL_GREEN tail -f /var/log/squid/access.log |ccze $COL_RESET"
echo
echo -e "$COL_GREEN Regard's / Syed Jahanzaib . . . !! $COL_RESET"
echo

☺♥

.

.

.

.

Regard’s
Syed Jahanzaib

January 4, 2014

Automated Installation Script For DMASOFTLAB RADIUS MANAGER v4.1.x in Ubuntu


rm-logo

radiusmanager-modified

Following is an customized script to install DMASOFTLAB Radius Manager ver 4.0.4 & 4.1.xfor Ubuntu 10x or 12.x / 32bit.
(Selectable via menu, I will add the latest cumulative patch no.5 in this script later ).

The aim of writing this script was to save some time and efforts every time I put in new RM installation. Since DMA don’t have any official support forum (except for there email support which is valid for paid customers only) , so I thought it might be helpful for others too  by sharing this info 🙂

I know very well that It is not a perfect script, it can be very well shorten as per the requirement, but still it does it’s job very nicely with out any user intervention 🙂

Suggestions are most welcome at  . . .
aacable @ hotmail . com

 

Script Update Revision History:

1- —– forgot to make revision  from the beginning  😉
[ 7th January 2014 ]    Download URL changed to aacable.rdo.pt /files/rm_related
[ 7th January 2014 ]    MySQL user ‘conntrack’ variable fixed in MySQL section
[ 8th January, 2014]    O.S check for UBUNTU added
[ 8th January, 2014]    root user check added
[ 8th January, 2014]    Function added to remove previously downloaded files in /temp folder to avoid duplication
[ 8th January, 2014]    Internet and $URL availability check
[ 29th January, 2014]  aacable.rdo.pt was down dueto quota limit, now added secondary link URL2 = http://wifismartzone.com/files/linux_related/
[28th July, 2014] Add rmpoller service to run at startup
[19th November, 2014]  Fixed captcha image not showing dueto tmpimages folder missing

Requirements:

1- Fresh Installation of UBUNTU 32bit  (script is well tested with 10.x and 12.x ,  both Desktop/Server edition works, 32bit edition only)

2- Internet access, off course ; )

3- Valid License files provided by DMASOFTLAB , valid with your physical (or virtual) interface MAC address


 

What components does this script add to the system ?

This script will install following in your system. (as per order nos.)

> Download Radius Manager from an remote location, as per your choice between 4.0 and 4.1
(choice menu offered right after execution of the script) and place it /temp folder

> Update Ubuntu by apt-get update command

> Install necessary components like mysql , apache2, php5,

> download and install dmasoftlab required components like libltd* , IONCUBE and add its entries in Apache’s php files

> Download and compile freeradius-server-2.2.0-dma-patch-2 package

> Add Radius & Conntrack DB in mysql suing CLI (Make sure your root password matched in variables section)

> Extract Radius Manager Installation file & install it.

> Restart Services like apache2, mysql, radius


 

IMPORTANT:


1- B
efore accessing RM ACP , make sure you upload valid LICENSE files in /var/www/radiusmanager folder

2- Also make sure that when mysql asks you for password (during installation) set it to “zaib1234” , otherwise it will be a mess to change it later 🙂


 

How-to Execute The Script  !!

There are several ways to do it, one is explained below . . .

Create a new script

touch /rm-ubuntu-32bit.sh
chmod +x /rm-ubuntu-32bit.sh
nano /rm-ubuntu-32bit.sh

.

Now copy paste the following code.

#!/bin/bash
# Version 1.3 / 9th November, 2014
# Syed Jahanzaib / aacable@hotmail.com
# https://aacable.wordpress.com
# DMASOFTLAB Radius Manager 4.0.4 / 4.1.x Automated Installation Script for Ubuntu 10/12 32bit Edition
# Some CORE installation part have been taken from the Original INSTALL.SH with some In-House Heavy modifications : )
# Last Modified - 11-JAN-2016 , added wget retries for weak internet links
# After UBUNTU / 32bit installation , First configure internet access.
# set -x
# Setting Variables . . . [JZ]
clear
 
# MySQL ROOT Password , Change this variable according to your own setup if required. . . [[ JZ . . . ]]
sqlpass="zaib1234"
 
# For RM & MYSQL . . . [[ JZ . . . ]]
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}'`
 
# RM Installation Package Download URL , Change this variable according to your own setup , if required. . . [[ JZ . . . ]]
#rmurl="http://aacable.rdo.pt/files/rm_related"
rmurl="http://wifismartzone.com/files/rm_related"
 
# Colors Config . . . [[ JZ . . . ]]
ESC_SEQ="\x1b["
COL_RESET=$ESC_SEQ"39;49;00m"
COL_RED=$ESC_SEQ"31;01m"
COL_GREEN=$ESC_SEQ"32;01m"
 
# OS checkup for UBUNTU
echo -e "$COL_GREEN Checking OS version, as it must be Ubuntu in order to Continue . Syed Jahanzaib / aacable@hotmail.com. .$COL_RESET"
if [[ $osver == Ubuntu ]]; then
echo
echo -e "$COL_GREEN Ubuntu is installed with following information fetched. $COL_RESET"
lsb_release -a
sleep 3
else
echo -e "$COL_RED Sorry, it seems your Linux Distribution is not UBUNTU . Exiting ...$COL_RESET"
exit 1
fi
 
# Make sure only root can run our script / Checking if user is root, otherwise exit with error [[Jz]]
echo
echo -e "$COL_GREEN Verifying if you are logged in with root priveleges . . .$COL_RESET" 1>&2
FILE="/tmp/out.$$"
GREP="/bin/grep"
if [ "$(id -u)" != "0" ]; then
echo
echo -e "$COL_RED This script must be run as root, switch to root now . . .$COL_RESET" 1>&2
exit 1
fi
echo -e "$COL_GREEN OK - You are logged in with root ID, Ok to proceed further . . .!! $COL_RESET"
 
# Temporary Folder where all software will be downloaded . . . [[ JZ . . . ]]
temp="temp"
 
# Checking if /temp folder is previously present or not . . .
{
if [ ! -d "/temp" ]; then
echo
echo -e "$COL_RED /temp folder not found, Creating it so all downloads will be placed here . . . $COL_RESET"
mkdir /temp
else
echo
echo -e "$COL_GREEN /temp folder is already present , so no need to create it, Proceeding further . . . $COL_RESET"
echo
fi
}
 
cd /$temp
 
# Clearing Old downloads in /temp to avoid DUPLICATIONS . . .
echo -e "$COL_RED Clearing Old downloads in /temp to avoid DUPLICATIONS . . . $COL_RESET"
 
rm -fr /temp/radiusmanager*.*
rm -fr /temp/freeradius*.*
rm -fr /temp/libltd*.*
rm -fr /temp/ioncube*.*
sleep 5
 
# Checking IF $rmurl is accessible m if YES then continue further , otherwise EXIT the script with ERROR ! [[ JZ .. . .]]
echo
echo -e "$COL_GREEN Checking if $rmurl is accessible in order to proceed further. . .!! $COL_RESET"
cd /temp
wget --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 -t 0 -q $rmurl/rm4.txt
{
if [ ! -f /temp/rm4.txt ]; then
echo
echo -e "$COL_RED ERROR: Unable to contact $rmurl, or possibly internet is not working or your IP is in black list at destination server !! $COL_RESET"
echo -e "$COL_RED ERROR: Please check manual if $rmurl is accessible or not or if it have required files, JZ !! $COL_RESET"
exit 0
fi
}
rm -fr /temp/rm4.txt
sleep 6
######################
 
clear
 
# Selection choice menu of RM version 4.0 or 4.1
echo -e "$COL_GREEN ########################################### $COL_RESET"
echo -e "$COL_GREEN Select the type of your operating system: $COLRESET"
echo -e "$COL_GREEN Syed Jahanzaib / aacable@hotmail.com $COLRESET"
echo -e "$COL_GREEN ########################################### $COL_RESET"
echo
echo "1. Radius Manager 4.0.4"
echo "2. Radius Manager 4.1.0"
echo
echo -n "Choose an option: [1] "
 
read rmver
if [ -z "$rmver" ]; then
rmver="1"
fi
case $rmver in
1 ) echo "Selected RM version is: 4.0.4 [Old]"
 
# Download radius manager 4.0.4 in $temp folder
echo .
echo -e "$COL_GREEN Downloading RADIUS MANAGER 4.0.4 package from INTERNET . Sleeping for 5 Seconds . . (Press CTRL+C to stop any time) $COL_RESET"
defver="radiusmanager-4.0.4.tgz"
defverdir="radiusmanager-4.0.4"
 
sleep 5
wget --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 -t 0 $rmurl/$defver
;;
2 ) echo "Selected RM version is: 4.1.0 [Latest]"
echo -e "$COL_GREEN Downloading RADIUS MANAGER 4.1.0 package from INTERNET . Sleeping for 5 Seconds . . (Press CTRL+C to stop any time) $COL_RESET"
defver="radiusmanager-4.1.0.tgz"
defverdir="radiusmanager-4.1.0"
 
echo .
sleep 5
 
# Download radius manager 4.1.0 in $temp folder
wget --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 -t 0 $rmurl/$defver
;;
* ) echo "Invalid selection. Installation aborted."
echo
exit
;;
esac
 
# Checking IF RM installation file have been downloaded. if YEs continue further , otherwise EXIT the script with ERRO ! [[ JZ .. . .]]
{
if [ ! -f /$temp/$defver ]; then
echo .
echo -e "$COL_RED ERROR: RM Installation File could not be download or found in /$temp/$defver ! $COL_RESET"
exit 0
fi
}
 
# Function to check RM Installation Package SIZE , if its Ok or corrupted (JZ) I will update it later
#SIZE=$(du -sb file.txt | awk '{ print $1 }')
#if ((SIZE<900)); then
# echo "RM File Size not Ok, possibly corrupted";
#else
# echo "RM FILE SIZE OK !";
#exit 0
#fi
 
# Update UBUNTU FIRST . . . [[ JZ . . . ]]
echo
echo
echo -e "$COL_GREEN Updating UBUNTU . Sleeping for 5 Seconds . . (Press CTRL+C to stop any time) $COL_RESET"
sleep 5
apt-get update
 
# Installing required components for RM . . . [[ JZ . . . ]]
 
echo .
echo -e "$COL_GREEN Installing components like MYSQL , PHP etc . Sleeping for 5 Seconds . . (Press CTRL+C to stop any time) $COL_RESET"
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
 
# While installing above components , it may ask for mysql password, use same password as you have used before . . . [[ JZ . . . ]]
 
echo .
echo -e "$COL_GREEN Installing LIB packages . Sleeping for 5 Seconds . . (Press CTRL+C to stop any time) $COL_RESET"
sleep 5
cd /$temp
wget --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 -t 0 http://www.dmasoftlab.com/cont/download/libltdl3_1.5.24-1ubuntu1_i386.deb
wget --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 -t 0 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
 
# IONCUBE Installation:
# Now Download ioncube library and add it to php . . . [[ JZ . . . ]]
echo .
echo -e "$COL_GREEN Installing IONCUBE . Sleeping for 5 Seconds . . (Press CTRL+C to stop any time) $COL_RESET"
sleep 5
 
wget --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 -t 0 http://www.dmasoftlab.com/cont/download/ioncube_loaders_lin_x86.tar.gz
 
# Checking if IONCUBE installation file have been downloaded. if YEs continue further , otherwise EXIT the script with ERROR ! [[ JZ .. . .]]
{
if [ ! -f /$temp/ioncube_loaders_lin_x86.tar.gz ]; then
echo .
echo -e "$COL_RED ERROR: COULD NOT DOWNLOAD IONCUBE !!! EXITING . . . $COL_RESET"
exit 0
fi
}
 
tar zxvf ioncube_loaders_lin_x86.tar.gz
mkdir /usr/local/ioncube
cd /$temp/ioncube
cp -fr * /usr/local/ioncube/
 
# Now Add the appropriate ionCube loader to your php.ini . . . [JZ]
echo .
echo -e "$COL_GREEN Adding iONCUBE in PHP . Sleeping for 5 Seconds . . (Press CTRL+C to stop any time) $COL_RESET"
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 .
echo -e "$COL_GREEN Downloading FREERADiUS 2.2.20-dma-patch-2 package . Sleeping for 5 Seconds . . (Press CTRL+C to stop any time) $COL_RESET"
sleep 5
wget --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 -t 0 http://www.dmasoftlab.com/cont/download/freeradius-server-2.2.0-dma-patch-2.tar.gz
 
# Checking if FREERADIUS is downloaded, just to make sure internet is working ,IF NOT, EXIT the script with ERROR ! [[ JZ .. . .]]
{
if [ ! -f /$temp/freeradius-server-2.2.0-dma-patch-2.tar.gz ]; then
echo .
echo -e "$COL_RED ERROR: COULD NOT DOWNLOAD FREERADIUS 2.2.20-dma-patch-2, possible INTERNET is not Working !!! EXITING . . . $COL_RESET"
exit 0
fi
}
 
echo .
echo -e "$COL_GREEN Compiling FREERADIUS . Sleeping for 5 Seconds . . (Press CTRL+C to stop any time) $COL_RESET"
sleep 5
tar zxvf freeradius-server-2.2.0-dma-patch-2.tar.gz
cd freeradius-server-2.2.0/
 
### Now proceed with the compilation of FREERAIDUS , applicable for all
./configure
make
make install
ldconfig
 
# Set the correct ownership on FreeRadius configuration files
chown $httpuser /usr/local/etc/raddb
chown $httpuser /usr/local/etc/raddb/clients.conf
 
# ================================================================
# Creating MySQL databases with MySQL command line tool . . . [JZ]
# ================================================================
# ** FROM CLI ** . . . [JZ]
echo .
echo -e "$COL_GREEN adding RADIUS user & DB in MYSQL . Sleeping for 5 Seconds . . (Press CTRL+C to stop any time) $COL_RESET"
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;"
 
# Time to Install RADIUS MANAGER 4.x.x . . . [JZ]
# ===============================================
 
cd /$temp
tar zxvf $defver
cd /$temp/$defverdir
echo .
echo -e "$COL_GREEN Starting RADIUS MANAGER install script install.sh . Sleeping for 5 Seconds . . (Press CTRL+C to stop any time) $COL_RESET"
sleep 5
 
echo "Radius Manager installer $defver for Ubuntu ONLY ****" [ JZ ]
echo "Copyright 2004-2012, DMA Softlab LLC"
echo "All right reserved."
echo
echo .
echo -e "$COL_GREEN (Use CTRL+C to abort any time) . Sleeping for 5 Seconds . . (Press CTRL+C to stop any time) $COL_RESET"
sleep 5
 
# copy web content
 
echo Copying Radius Manager WEB content to $wwwpath/radiusmanager
cp -fr www/radiusmanager $wwwpath
 
# rename .dist files
 
# Zaib / copy paypal cfg file so that user.php may not be missed
mv $wwwpath/radiusmanager/config/payfast_cfg.php.dist $wwwpath/radiusmanager/config/payfast_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
 
# set ownership and permissions
 
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/tmpimages
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
 
# Adding tmpimage folder for CAPTCHA images (Zaib)
mkdir /var/www/radiusmanager/tmpimages
chown $httpuser $wwwpath/radiusmanager/tmpimages
 
# chmod and copy binaries
 
echo "Copying binaries to /usr/local/bin"
chmod 755 bin/rm*
cp -fr bin/rm* /usr/local/bin
 
echo "Copying rootexec to /usr/local/sbin"
cp -fr bin/rootexec /usr/local/sbin
chmod 4755 /usr/local/sbin/rootexec
 
# chmod and copy radiusmanager.cfg
 
echo "Copying radiusmanager.cfg to /etc"
cp -fr etc/radiusmanager.cfg /etc
chown root /etc/radiusmanager.cfg
chmod 600 /etc/radiusmanager.cfg
 
# create or upgrade tables
 
echo "Creating MySQL tables"
mysql -h $radhost -u $myusr_rad -p$mypsw_radius radius < sql/radius.sql
mysql -h $radhost -u $myusr_cts -p$mypsw_cts conntrack < sql/conntrack.sql
 
# create rmpoller service
 
echo "Enabling rmpoller service at boot time"
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
 
# create rmconntrack service
 
echo "Enabling rmconntrack service at boot time"
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
 
# copy radiusd init script
 
echo "Enabling radiusd service at boot time"
chmod 755 rc.d/debian/radiusd
cp -fr rc.d/debian/radiusd /etc/init.d
update-rc.d radiusd defaults 99
 
# copy logrotate script
 
echo "Copying logrotate script"
cp -fr etc/logrotate.d/radiusd /etc/logrotate.d/radiusd
 
# copy cron job script
 
echo "Copying cronjob script"
cp -fr etc/cron/radiusmanager /etc/cron.d/radiusmanager
chmod 644 /etc/cron.d/radiusmanager
 
# comment out the old style cron job
 
sed -i 's/02\ 0\ \*\ \*\ \*\ root\ \/usr\/bin\/php/#2\ 0\ \*\ \*\ \*\ root\ \/usr\/bin\/php/g' /etc/crontab
 
# replace strings in cfg files for Debian
echo .
echo -e "$COL_GREEN Setting Debina base WWW dir in configuration files . . .!$COL_RESET"
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
 
# set permission on raddb files
 
echo "Setting permission on raddb files"
chown $httpuser /usr/local/etc/raddb
chown $httpuser /usr/local/etc/raddb/clients.conf
 
echo
echo .
echo -e "$COL_GREEN Radius manager Installation complete!$COL_RESET"
echo
 
# Now copy the two license files (that you receive from DMASOFTLAB) in /var/www/radiusmanager . . . [JZ]
cp -fr lic.txt /var/www/radiusmanager/
cp -fr mod.txt /var/www/radiusmanager/
 
echo .
echo .
echo -e "$COL_GREEN Re-Starting Apache2, Radius and mySQL Service$COL_RESET"
echo .
service radiusd start
service apache2 restart
service mysql restart
echo .
echo .
echo .
echo .
echo .
echo -e "$COL_GREEN All Done. Please access ADMIN panel via http://yourip/radiusmanager/admin.php $COL_RESET"
echo -e "$COL_GREEN RM Installation script by SYED JAHANZAIB / aacable@hotmail.com $COL_RESET"

 

Save & Exit …





 

 

Now execute the script by

/rm-ubuntu-32bit.sh


 

After the script ends, do make sure that you don’t see any frequent Error’s  on the installation. Thats why I have added 5 Seconds delay in each section so you can view the results.

Now UPLOAD your valid License into /var/www/radiusmanager

.

Then try to access RM ACP via browser by

http://yourip/radiusmanager/admin.php

.

If you get blank page, then use tail command to view Apache error log , example

tail -f /var/log/apache2/error.log

.

OR more specifically

tail -f /var/log/apache2/error.log |grep lic

.

If you see any error like showed in the image below . . . (for not valid license), then make sure your license files are valid for right version and with the right mac address interface.

.

rm-lic-error


 

To deploy Radius Manager Patch 5 (4.1.5) , Kindly see the following Link

https://aacable.wordpress.com/2014/02/28/radius-manager-4-1-patch5-deployment/

I will add few snapshots and video as soon as I get some time.

 


 

Regard’s
Syed Jahanzaib

%d bloggers like this: