previous up next contents
Previous: qzz_new_mail Up: Batches spécifiques   Contents

save_qyr_001


#! /bin/bash

TERM="raw"   # pour de beaux resultats, il ne faut pas les embellir !

ouca=/home/douillet/docs/sys/doc_reseau
sedf=/tmp/sed_reseau
sedg=/tmp/sed_chains
ip_chains=/tmp/ip_chains
my_chains=/tmp/my_chains
sb=/etc/init.d

while test $1
do case $1 in
  -i) /sbin/ipchains-save > $ip_chains ; shift ;;
  -s) sflag=sflag ; shift ;;
  *)  echo error : mauvaise option ; exit ;;
  esac
done


if test $sflag
 then
  ip0=`/sbin/ifconfig eth0 | grep "inet addr" | sed  -e "s/\ \ Bcast.*$//; s/^.*://"`
  ip1=`/sbin/ifconfig eth1 | grep "inet addr" | sed  -e "s/\ \ Bcast.*$//; s/^.*://"`
  ip2=`/sbin/ifconfig ppp0 2>/dev/null | grep "inet addr" | sed  -e "s/\ P-t-P.*$//; s/^.*:// ; s/ //"`
  ipr0=`echo $ip0 | sed -e "s¶\.[^.]*$¶.0¶" `
  ipr1=`echo $ip1 | sed -e "s¶\.[^.]*$¶.0¶" `
  dn0=`grep "nameserver" /etc/resolv.conf | grep -v "change your name"`
  dn1=`echo $dn0 | sed -e " s/nameserver // ; s/ nameserver.*// " `
  dn2=`echo $dn0 | sed -e " s/.*nameserver // " `
  cat << EOF > $sedg

          s¶-s ¶¶
	s¶input¶ input¶
	s¶193.48.37.48/¶MADRAS__/¶
     s¶255.255.255.255/¶all_ones/¶
               s¶$ipr0¶ETH0____¶
	 s¶$ip0¶ETH0_ord¶
        s¶$ipr1¶ETH1____¶
         s¶$ip1¶ETH1_ord¶
         s¶$ip2¶PPP0_ord¶
         s¶$dn1¶DNS1____¶
         s¶$dn2¶DNS2____¶
	s¶/255\.255\.255\.255¶/32¶g
	  s¶/255\.255\.255\.0¶/24¶g
	  s¶/255\.255\.254\.0¶/23¶g
	      s¶/255\.0\.0\.0¶/8¶g
	        s¶/0\.0\.0\.0¶/0¶g
	s¶-d¶	-d¶
        s¶/32 	-d¶/32 		-d¶
	s¶/24 	-d¶/24 		-d¶
        s¶/8 	-d¶/8 		-d¶
        s¶/0 	-d¶/0 		-d¶
	s¶-d ¶¶

        /-i/ ! {
	s¶-p¶-i all  -p¶
        }
        s¶-i lo¶-i loc ¶

        /-i/ ! {
	s¶-j¶-i all  -p all -j¶
        }

        s¶-i¶	-i¶
        s¶0/0 	-i¶0/0 		-i¶
        s¶/32 	-i¶/32 		-i¶
        s¶/24 	-i¶/24 		-i¶
        s¶/8 	-i¶/8 		-i¶

	s¶0 3:3 	-i ¶0 3:3 		-i ¶
	s¶0 4:4 	-i ¶0 4:4 		-i ¶
	s¶0 8:8 	-i ¶0 8:8 		-i ¶

        /-p/ ! {
	s¶-j¶-p all -j¶
        }

	s¶-i ¶¶

        s¶-p all ¶all  ¶
          s¶-p 1 ¶icmp ¶
         s¶-p 17 ¶udp  ¶
          s¶-p 6 ¶tcp  ¶

	s¶-j ¶¶
	s¶DENY¶DENY  ¶
EOF


echo ETH0_ord = $ip0 >  $my_chains
echo ETH1_ord = $ip1 >> $my_chains
echo "" >> $my_chains

  sed -f  $sedg $ip_chains >> $my_chains
  kwrite $my_chains
 exit
fi

exit


















echo "----------------- doc reseau --------------" > $ouca
echo "" >> $ouca
echo  `date +"%D %Hh%M"`"  :  $HOSTNAME    "  >> $ouca
echo "" >> $ouca

sed -n -e "/^alias eth/ p" /etc/modules.conf >> $ouca
echo "" >> $ouca
/sbin/ifconfig | sed -n -e "/Link\ encap/ p; /inet\ addr/ p ; /MTU/ p ; /RX\ bytes/ p ; /Interrupt/ p" >> $ouca
echo "" >> $ouca



echo "" >> $ouca
echo "----------------- route.conf --------------">> $ouca
echo "" >> $ouca

sed -e "/^#/ d ; /^$/ d" /etc/route.conf >> $ouca

echo "" >> $ouca
echo "----------------- route -------------------">> $ouca
echo "" >> $ouca

/sbin/route -n >> $ouca


echo "" >> $ouca
echo "----------------- apache ------------------">> $ouca
echo "" >> $ouca

$sb/apache status | sed -e "s/:/:     /" >> $ouca


echo "" >> $ouca
echo "----------------- samba -------------------">> $ouca
echo "" >> $ouca

$sb/smb status >> $ouca
echo "" >> $ouca


cat << EOF > $sedf
/interfaces/	{
s/^[ ]*//
s/	//g
p
}

EOF

sed -n -f $sedf /etc/smb.conf >> $ouca

echo "" >> $ouca
echo "----------------- printer -----------------">> $ouca
echo "" >> $ouca

echo `$sb/lpd status` >> $ouca

cat << EOF > $sedf
/rm=/	{
s/^[ ]*//
s/	//g
s/:rm=/interface = /
p
}

EOF

sed -n -f $sedf /etc/printcap >> $ouca

echo "" >> $ouca
echo "----------------- hosts -------------------">> $ouca
echo "" >> $ouca

sed -e "/^#/ d ; /ipv6/ d ; /^$/ d" /etc/hosts | sort >> $ouca


echo "" >> $ouca
echo "----------------- rc.config ---------------" >> $ouca
echo "" >> $ouca


cat << EOF > $sedf
/^IPA/			p
/^NET/			p
/^IFCON/		p

EOF

sed -n -f $sedf /etc/rc.config | sort  >> $ouca

echo "" >> $ouca
sed -n -e "/^NAMESERVER/ p" /etc/rc.config   >> $ouca
grep "nameserver" /etc/resolv.conf | grep -v "change your name" >> $ouca


echo ""  >> $ouca
echo "-------------------------------------------">> $ouca
echo "" >> $ouca


cat << EOF > $sedf
/^IP[^A]/		p
/^START_CUPS/		p
/^START_DHCP/		p
/^START_FW/		p
/^START_HT/		p
/^START_IN/		p
/^START_LO/		p
/^START_LPD/		p
/^START_RO/		p
/^START_SM/		p

EOF


sed -n -f $sedf /etc/rc.config | sort >> $ouca


echo "" >> $ouca
echo "----------------- firewall ----------------">> $ouca
echo "" >> $ouca

echo "Checking for service firewall: " `cat $ip_chains | grep -c -e "^."` "ipchains" >> $ouca
echo "" >> $ouca

cat << EOF > $sedf
/^FW/	p

EOF

sed -n -f $sedf /etc/rc.config.d/firewall.rc.config  >> $ouca

echo "" >> $ouca
echo "" >> $ouca
echo "" >> $ouca
echo "" >> $ouca
echo "" >> $ouca
echo "----------------- ipchains ----------------">> $ouca
echo "" >> $ouca

cat << EOF > $sedf
s/\/255\.255\.255\.255/\/32/g
s/\/255\.255\.255\.0/\/24/g
s/\/255\.255\.254\.0/\/23/g
s/\/255\.0\.0\.0/\/8/g
s/\/0\.0\.0\.0/\/0/g

s/0\.0\.0\.0\/0 -d/0.0.0.0\/0 	-d/
s/-d/	-d/

/-p/ ! {
s/-j/-p all  -j/
}

/-i/ ! {
s/-p/-i + -p/
}

s/\/0 -i/\/0 	-i/
s/\/8 -i/\/8 	-i/
s/-i/		-i/
s/-i lo/-i L/
s/-i eth/-i /
s/-i ppp0/-i P/

s/-A forward -s 0\.0\.0\.0\/0 		-d/-A forward -s 0.0.0.0\/0 	-d/

/fw_masq/{
s/	-d/-d/
}

/-t 01/{
s/	-i/-i/
}

s/-p 0/-p ip  /
s/-p 17/-p udp /
s/-p 12/-p pup /
s/-p 1/-p icmp/
s/-p 2/-p igmp/
s/-p 3/-p ggp /
s/-p 6/-p tcp /
s/-p 8/-p egp /
s/-p 20/-p hmp /
s/-p 22/-p idp /
s/-p 27/-p rdp /
s/-p 29/-p iso4/


EOF

sed -f $sedf $ip_chains >> $ouca


echo "" >> $ouca
echo "-------------------------------------------">> $ouca
echo "" >> $ouca

chmod a+w $ip_chains ; chmod a+w $sedf

kedit $ouca

previous up next contents
Previous: qzz_new_mail Up: Batches spécifiques   Contents


douillet@ensait.fr
2003-06-24