分类: LINUX
2010-03-03 01:09:31
/var/log $ cat /mnt/disk/sendip
#!/bin/bash
#start the eth1 service
#if [ `rc-status -C |grep net.eth1|awk '{print $3}'` = "started" ]; then
if `/etc/init.d/net.eth1 -s`; then
echo "==net.eth1 started">> /tmp/sendip.date
else
sudo /etc/init.d/net.eth1 restart
fi
#start the ppp0 service
#if [ `rc-status -C |grep net.ppp0|awk '{print $3}'` = "started" ]; then
if `/etc/init.d/net.ppp0 -s`; then
# or the following 2 lines is that same as this line
#if [ `rc-status -C |grep net.ppp0|awk '{print $3}'` = "started" ]
#then
echo "==net.ppp0 started">> /tmp/sendip.date
else
sudo /etc/init.d/net.ppp0 restart
fi
#start sshd service
#if [ `rc-status -C|grep sshd|awk '{print $3}'` = "started" ]; then
if `/etc/init.d/sshd -s`; then
echo "==sshd started">>/tmp/sendip.date
else
sudo /etc/init.d/sshd restart
fi
#start apache2 service
#if [ `rc-status -C|grep apache2|awk '{print $3}'` = "started" ]; then
if `/etc/init.d/apache2 -s`; then
echo "==apache2 started">>/tmp/sendip.date
else
sudo /etc/init.d/apache2 restart
fi
#start proftpd service
#if [ `rc-status -C|grep proftpd|awk '{print $3}'` = "started" ]; then
if `/etc/init.d/proftpd -s`; then
echo "==proftpd started">>/tmp/sendip.date
else
sudo /etc/init.d/proftpd restart
fi
/sbin/ifconfig ppp0|grep 'inet addr:'|cut -d: -f2|awk '{print $1}'|mutt -s " `date \"+Send_IP: %Y/%m/%d %H:%M:%S\"` "
echo `/sbin/ifconfig ppp0|grep 'inet addr:'|cut -d: -f2|awk '{print $1}'` `date`>>/tmp/sendip.date