Script to generate /etc/network/interfaces file on Ubuntu/Debian

Wednesday, September 30th, 2009

#!/bin/bash
ifile=/etc/network/interfaces
echo -n “Insert IPstart:”
read ipstart
echo -n “Insert IPend:”
read ipend
echo -n “Insert Gateway:”
read gw
#echo -n “Insert Subnet: ”
#read subnet
echo -n “Insert Netmask: ”
read net
echo -n “Insert aliast to start: ”
read ali

firstIp=`echo “${ipstart%.*}”`
lastIpStart=`echo “${ipstart##*.}”`
lastIpEnd=`echo “${ipend##*.}”`
dif=`echo $(($lastIpEnd-$lastIpStart))`

ip=$lastIpStart
for ((i=$ali;i<=$ali+$dif;i++)){
echo "auto eth0:$i" >>$ifile
echo “iface eth0:$i inet static” >>$ifile
echo “address $firstIp.$ip” >>$ifile
echo “network $subnet” >>$ifile
echo “netmask $net” >>$ifile
echo “gateway $gw” >> $ifile
echo ” ” >> $ifile
let ip++
}

Joomla with suPHP: Premature end of script headers: index.php

Thursday, July 30th, 2009

Got this error while I was trying to configure Joomla to work with suPHP. This is the config I`m using to make it work:


ServerAdmin aa@aa.com
ServerName www.site.org
ServerAlias site.org
DocumentRoot /home/virtuals/www.site.org/public_html/
ErrorLog /home/virtuals/www.site.org/logs/error.log
CustomLog /home/virtuals/www.site.org/logs/access.log combined
ServerSignature On
php_admin_flag safe_mode Off
php_admin_flag register_globals On
php_admin_value open_basedir /home/virtuals/www.site.org/public_html:/tmp



AllowOverride All
Allow from All
Options Indexes FollowSymLinks



php_admin_flag engine on
suPHP_Engine on
AddHandler php5-script .php
php_admin_flag engine on

Script to autorestart httpd server if it fails

Thursday, June 18th, 2009

I use this script on a cpanel server..if output of pgrep command is 0 then the $restart command is issued

#!/bin/bash
restart=”/scripts/restartsrv_httpd”
pgrep httpd || $restart
exit 0

If its a VPS then I might add to clear the Semaphore Arrays.

for i in `ipcs -s | grep nobody | awk ‘{print $2}’`; do ipcrm -s $i; done

Then I put this script into Cron to run every 5 minutes.

# MIN HOUR DAYOFMONTH MONTH DAYOFWEEK COMMAND
*/5 * * * * /root/checkhttp.sh