模板一:ip配置
#!/bin/sh
ifconfig eth0 192.168.1.xxx netmask 255.255.255.0 up >/dev/null 2>&1
/sbin/route add default gw 192.168.1.1
模板二:Samba挂载
#!/bin/sh
mount -o nolock 192.168.1.xxx:/nfs /mnt
模板三:检测程序重启,内存检测,CPU占有率,IP分配情况
#!/bin/bash
#trap "echo ` SIGTERM is trapped!`" SIGTERM
pathbin=/opt/
echo 0 > /tmp/UpgradeFlag
sudo echo $(date) >> /opt/log.txt
sleep 10
sudo echo $(date) >> /opt/log.txt
/opt/memory_limit.sh 90%&
/opt/CPU_occupancy_rate.sh 100.0&
trap "echo `singal is trapped.`" SIGTERM
while :
do
for i in webs Client file_num_limit;
do
pid=`pidof $i`
if [ -z "${pid}" ]; then
if [ "$i" = "file_num_limit" ];
then
${pathbin}$i /opt/Log_msg&
else
${pathbin}$i &
fi
fi
done
if [ '1' -eq `cat /tmp/UpgradeFlag` ]; then
echo 0 > /tmp/UpgradeFlag
sleep 3
echo "upgrade : tar xzvf /opt/Upgrade.bin -C /"
killall webs Client file_num_limit
tar xzvf /opt/Upgrade.bin -C /
sleep 1
reboot
fi
sleep 3
done
exit 0
内存检测memory_limit.sh
#! /bin/bash
str2=$1
echo "$1"
while true
do
string=$(df -h /root)
result=$(echo $string | grep "${str2}")
if [ -n "$result" ]; then
echo "exist ----"
rm /opt/Log_msg/*
killall Client
sleep 3
fi
sleep 3
done
exit 0
CPU占有率CPU_occupancy_rate.sh
#! /bin/bash
str2=$1
echo "$1"
while true
do
string=$(ps -aux | grep kswapd0)
#echo "${string}"
result=$(echo $string | grep "${str2}")
echo "$result"
if [ -n "$result" ]; then
echo "exist ---"
killall kswapd0
sleep 3
fi
sleep 3
done