Script to add multiple ips
#!/bin/bash
clear
a=51
for i in `seq 12 60 ` ;do
a=`expr $a + 1 `
path=/etc/sysconfig/network-scripts/ifcfg-eth0:$a
check=`ifconfig |grep "\<192.168.0.$i\>"`
if [ ! -f /etc/sysconfig/network-scripts/ifcfg-eth0:"$a" ]; then
if [ -z "$check" ]; then
cat >> $path << _eof_
DEVICE=eth0:$a
NETMASK=255.255.255.0
BOOTPROTO=static
IPADDR=192.168.253.$i
ONBOOT=yes
_eof_
echo -e "######## Added the IP aliases 192.168.0.$i ##############"
ifup eth0:$a
else
echo -e "The Ip address already exist"
fi
else
echo -e "The ip aliases $cf exist"
fi
done
clear
a=51
for i in `seq 12 60 ` ;do
a=`expr $a + 1 `
path=/etc/sysconfig/network-scripts/ifcfg-eth0:$a
check=`ifconfig |grep "\<192.168.0.$i\>"`
if [ ! -f /etc/sysconfig/network-scripts/ifcfg-eth0:"$a" ]; then
if [ -z "$check" ]; then
cat >> $path << _eof_
DEVICE=eth0:$a
NETMASK=255.255.255.0
BOOTPROTO=static
IPADDR=192.168.253.$i
ONBOOT=yes
_eof_
echo -e "######## Added the IP aliases 192.168.0.$i ##############"
ifup eth0:$a
else
echo -e "The Ip address already exist"
fi
else
echo -e "The ip aliases $cf exist"
fi
done
this script will test the server name of each system
this script will test the server name of each system
#!/usr/bin/perl
use Net::Telnet ;
open ( IN,"/tmp/IDC_IPs") or die "cannot open file " ;
while ( $ip=<IN>) {
$t = new Net::Telnet ( Timeout=>3, Errmode=>'return', port =>'25' );
$t->open("$ip");
$output1 = $t->getline ;
$t->print("ehlo data");
($output2) = $t->getline ;
chomp($output2);
chomp($ip);
print "$ip $output2\n" ;
}
close IN ;
Documentation on ServerBackup
Now On the backupserver machines
mkdir /net/serverbackup ----------> location where all the tar.gz files are stored
This scritpt will wget the flles from vairous server
vi /usr/local/bin/serverbackup
#!/bin/bash
set -x
DIR=/net/serverbackup
SERVERINFO=/net/serverbackup/serverbackupfiles
cd /net/serverbackup
if [ -d $DIR ] ;then
if [ -f $SERVERINFO ];then
for i in `cat $SERVERINFO |awk -F "|" '{print $2}'`
do
`cat $SERVERINFO |grep $i |awk -F "|" '{print $3}'``date +%Y%m%d`.tgz;
done
else
echo " serverbackupfiles does not exist "
fi
else
echo " serverbackup dir does not exist "
fi
This file (serverbackupfiles) is requied by the "serverbackup" script
cat /net/serverbackup/serverbackupfiles
|server112|wget --user=agnello --password=username http:///server112.com/serverbackup/pamserver2.
crontab -e
##for serverbackup to weget the files
0 11 * * * /usr/local/bin/serverbackup
Now On the system to be backed up
cd /net/serverbackup
ln -s /net/serverbackup /var/www/html/serverbackup
vi /usr/local/bin/serverbackupdaily
#!/bin/bash
#
set -x
backupfile1="`date '+%Y%m%d'`"
backupfile="servername.$backupfile1.tgz"
if cd /; then
tar zcf /tmp/$backupfile --exclude-from=/etc/backup/excludedaily `cat /etc/backup/BACKUPDAILY`
mv /tmp/$backupfile /net/serverbackup
chown -R web.web /net/serverbackup
fi
exit 0
vi /etc/httpd/conf/httpd.conf
#setting for serverbackup
AllowOverride AuthConfig
AuthName "serverBackup login"
AuthType Basic
AuthUserFile /net/serverbackup/.htpasswd
AuthGroupFile /dev/null
require user serverbackup
Order deny,allow
Deny from all
Allow from all
htpasswd -bc /net/serverbackup/.htpasswd serverbackup password
crontab -e
##for serverbackup
0 06 * * * /usr/local/bin/serverbackupdaily
script to convert mdir to mbox format
#! /bin/sh
#
# Get a directory name as input and convert all mail files inside
# to mbox format
#
# NOTE: processing of subdirectories not yet implemented correctly:
# all mails in subfolders are put into the same mbox
# (it would be better if an mbox file will be generated for
# each subfolder)
# NOTE: calculation of message date in case of 'From:' doesn't recognise
# time zones
#
# History:
# Feb 06 2001 Joerg Reinhardt
# - first edition
# Feb 07 2001 Joerg Reinhardt
# - added usage output
# Feb 12 2001 Joerg Reinhardt
# - mails not containing a 'From:' field but an 'X-From-Line:' or a
# 'Reply-To:' field are now recognised and also processed (e.g. put into
# the mbox file); this works fine for all my mails
# - added progress information
# - warning about corrupt files is now written to stderr
# check for argument or help argument respectively
if [[ ($1 == "") ||
($1 == "-h") ||
($1 == "--help") ||
($1 == "-help") ]]; then
echo "Usage: "$0" <Xfmail-mail-directory>";
fi;
# check if parameter is a directory
if [[ -d $1 ]]; then
# set target filename
dirname=`echo $1 | awk '{while(substr($0,length($0),1)=="/"){$0=substr($0,1,length($0)-1);}print $0;}'`;
mboxfile=$dirname'.mbox';
# check if directory is empty
if [[ `find $dirname -type f` == "" ]]; then
echo $dirname": directory empty."
exit 1;
fi;
# prevent automatic overwriting of target
if [[ -e $mboxfile ]]; then \
dialogtext="Write file "$mboxfile"?";
if dialog --yesno "$dialogtext" 10 60; then
clear;
rm -vf $mboxfile;
else
clear; exit 1;
fi;
fi;
echo "writing xfmail mail directory '$1' to '$mboxfile'.";
# collect files inside Xfmail mail-directory and produce MBOX format
# target file
for i in `find $1/* -type f`; do
# output progress information
echo -n -e \\r" "
echo -n -e \\rprocessing $i
# look for senders email address in the order
# 'From:'
# 'X-From-Line:'
# 'Reply-To:'
shortfromflag='true';
fromline=`grep 'From:' $i`;
# parse 'From:' field
from=`echo $fromline | awk 'BEGIN{FS="<";}{if($0~/</) {pos=index($2,">");if(pos!=0) {print substr($2,1,pos-1);}} else {pos=index($0,":");print substr($0,pos+1);}}'`;
if [[ $from == "" ]]; then
shortfromflag='false';
fromline=`grep 'X-From-Line:' $i`;
from=`echo $fromline | awk 'BEGIN{FS="Line:";}{print $2;}'`;
if [[ $from == "" ]]; then
shortfromflag='true';
fromline=`grep 'Reply-To:' $i`;
# parse 'Reply-To:' field
from=`echo $fromline | awk 'BEGIN{FS="<";}{if($0~/</) {pos=index($2,">");if(pos!=0) {print substr($2,1,pos-1);}} else {pos=index($0,":");print substr($0,pos+1);}}'`;
if [[ $from == "" ]]; then
echo;
echo "WARNING: "$i": no 'From:' nor 'X-From-Line:' nor 'Reply-To:' field found." >&2;
continue;
fi;
fi;
fi;
if [[ $shortfromflag == "true" ]]; then
# parse date field
dateline=`grep 'Date:' $i`;
if [[ $dateline == "" ]]; then
# set dummy date if no date field found
dateline="Date: Thu, 01 Jan 1970 00:00:00 +0000 (GMT)";
fi;
weekday=`echo $dateline | awk '{gsub(/,/,"",$2);print $2;}'`;
day=`echo $dateline | awk '{print $3;}'`;
month=`echo $dateline | awk '{print $4;}'`;
year=`echo $dateline | awk '{print $5;}'`;
time=`echo $dateline | awk '{print $6;}'`;
diffGMT=`echo $dateline | awk '{print $7;}'`;
timezone=`echo $dateline | awk '{print $8;}'`;
# output MBOX mail header
echo "From " $from $weekday $month $day $time $year >> $mboxfile;
else
# output long MBOX mail header found in 'X-From-Line:' field
echo $from >> $mboxfile;
fi;
# output mail itself
cat $i >> $mboxfile;
done;
echo;
else
echo $1": not a directory.";
fi;
Subscribe to:
Posts (Atom)