shell 脚本模版
#!/bin/bash
#var define
DnsCapDir1="/DnsCap"
DnsCapDir2="/mnt/RAMFS"
DnsCapEXE=./DnsCap
DnsCapOutput=DnsCap.log
NRSendClientEXE=./NRSendClient
NRSendClientOutput=NRSendClient.log
ReadIPEXE=./ReadIP
WebInfoEXE=./WebInfo
#DnsCap configure fun
function DnsCap
{
#mast cd DnsCap exec the DnsCap
cd ./DnsCap/
#create /DnsCap Dir
if [ ! -d "$DnsCapDir1" ] ; then
mkdir "$DnsCapDir1"
echo "mkdir $DnsCapDir1"
fi
#create /mnt/RAMFS Dir
if [ ! -d "$DnsCapDir2" ] ; then
mkdir "$DnsCapDir2"
echo "touch $DnsCapDir2"
fi
#check DnsCap is exits
if [ ! -e "$DnsCapEXE" ] ; then
echo "DnsCap is not exits"
cd ../
exit
fi
#chmod DnsCap to exec
if [ ! -x "$DnsCapEXE" ] ; then
chmod 777 $DnsCapEXE
fi
#start DnsCap service
state=$(pgrep DnsCap)
if [ ! -z $state ] ; then
echo 'DnsCap already start'
else
($DnsCapEXE > $DnsCapOutput)&
echo "start DnsCap service"
fi
cd ../
}
#!/bin/bash
#var define
DnsCapDir1="/DnsCap"
DnsCapDir2="/mnt/RAMFS"
DnsCapEXE=./DnsCap
DnsCapOutput=DnsCap.log
NRSendClientEXE=./NRSendClient
NRSendClientOutput=NRSendClient.log
ReadIPEXE=./ReadIP
WebInfoEXE=./WebInfo
#DnsCap configure fun
function DnsCap
{
#mast cd DnsCap exec the DnsCap
cd ./DnsCap/
#create /DnsCap Dir
if [ ! -d "$DnsCapDir1" ] ; then
mkdir "$DnsCapDir1"
echo "mkdir $DnsCapDir1"
fi
#create /mnt/RAMFS Dir
if [ ! -d "$DnsCapDir2" ] ; then
mkdir "$DnsCapDir2"
echo "touch $DnsCapDir2"
fi
#check DnsCap is exits
if [ ! -e "$DnsCapEXE" ] ; then
echo "DnsCap is not exits"
cd ../
exit
fi
#chmod DnsCap to exec
if [ ! -x "$DnsCapEXE" ] ; then
chmod 777 $DnsCapEXE
fi
#start DnsCap service
state=$(pgrep DnsCap)
if [ ! -z $state ] ; then
echo 'DnsCap already start'
else
($DnsCapEXE > $DnsCapOutput)&
echo "start DnsCap service"
fi
cd ../
}