2013-08-02 10:03:26 +00:00
|
|
|
function hashencode(){
|
2013-08-20 06:47:34 +00:00
|
|
|
local str_map="$1"
|
|
|
|
echo `echo $str_map | sed 's/\./xDOTx/g' | sed 's/:/xCOLONx/g' | sed 's/,/:xCOMMAx/g'`
|
2013-08-02 10:03:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function hashset(){
|
2013-08-20 06:47:34 +00:00
|
|
|
local str_hashname="hash${1}${2}"
|
|
|
|
local str_value=$3
|
|
|
|
str_hashname=$(hashencode $str_hashname)
|
|
|
|
eval "${str_hashname}='${str_value}'"
|
2013-08-02 10:03:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function hashget(){
|
2013-08-20 06:47:34 +00:00
|
|
|
local str_hashname="hash${1}${2}"
|
|
|
|
str_hashname=$(hashencode $str_hashname)
|
|
|
|
eval echo "\$${str_hashname}"
|
2013-08-02 10:03:26 +00:00
|
|
|
}
|
2013-08-20 06:47:34 +00:00
|
|
|
|
|
|
|
function debianpreconf(){
|
|
|
|
#create the config sub dir
|
|
|
|
if [ ! -d "/etc/network/interfaces.d" ];then
|
|
|
|
mkdir -p "/etc/network/interfaces.d"
|
|
|
|
fi
|
|
|
|
#search xcat flag
|
2013-11-08 10:02:16 +00:00
|
|
|
grep '#XCAT_CONFIG' /etc/network/interfaces
|
2013-08-20 06:47:34 +00:00
|
|
|
if [ $? -eq 0 ];then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
#back up the old interface configure
|
|
|
|
if [ ! -e "/etc/network/interfaces.bak" ];then
|
|
|
|
mv /etc/network/interfaces /etc/network/interfaces.bak
|
|
|
|
fi
|
|
|
|
|
|
|
|
#create the new config file
|
|
|
|
echo "#XCAT_CONFIG" > /etc/network/interfaces
|
|
|
|
echo "source /etc/network/interfaces.d/*" >> /etc/network/interfaces
|
|
|
|
|
|
|
|
local str_conf_file=''
|
|
|
|
|
|
|
|
#read the backfile
|
|
|
|
cat /etc/network/interfaces.bak | while read str_line
|
|
|
|
do
|
|
|
|
if [ ! "$str_line" ];then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
local str_first_char=${str_line:0:1}
|
|
|
|
if [ $str_first_char = '#' ];then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
local str_conf_type=`echo $str_line | cut -d" " -f1`
|
|
|
|
if [ $str_conf_type = 'auto' -o $str_conf_type = 'allow-hotplug' ];then
|
|
|
|
str_line=${str_line#$str_conf_type}
|
|
|
|
for str_nic_name in $str_line; do
|
|
|
|
echo "$str_conf_type $str_nic_name" > "/etc/network/interfaces.d/$str_nic_name"
|
|
|
|
done
|
|
|
|
elif [ $str_conf_type = 'iface' -o $str_conf_type = 'mapping' ];then
|
|
|
|
#find out the nic name, should think about the eth0:1
|
|
|
|
str_nic_name=`echo $str_line | cut -d" " -f 2 | cut -d":" -f 1`
|
|
|
|
str_conf_file="/etc/network/interfaces.d/$str_nic_name"
|
|
|
|
if [ ! -e $str_conf_file ];then
|
|
|
|
echo "auto $str_nic_name" > $str_conf_file
|
|
|
|
fi
|
|
|
|
|
|
|
|
#write lines into the conffile
|
|
|
|
echo $str_line >> $str_conf_file
|
|
|
|
else
|
|
|
|
echo $str_line >> $str_conf_file
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2013-11-01 10:33:39 +00:00
|
|
|
#tranfer the netmask to prefix for ipv4
|
|
|
|
function v4mask2prefix(){
|
|
|
|
local num_bits=0
|
|
|
|
local old_ifs=$IFS
|
|
|
|
IFS=$'.'
|
|
|
|
local array_num_temp=($1)
|
|
|
|
IFS=$old_ifs
|
|
|
|
for num_dec in ${array_num_temp[@]}
|
|
|
|
do
|
|
|
|
case $num_dec in
|
|
|
|
255) let num_bits+=8;;
|
|
|
|
254) let num_bits+=7;;
|
|
|
|
252) let num_bits+=6;;
|
|
|
|
248) let num_bits+=5;;
|
|
|
|
240) let num_bits+=4;;
|
|
|
|
224) let num_bits+=3;;
|
|
|
|
192) let num_bits+=2;;
|
|
|
|
128) let num_bits+=1;;
|
|
|
|
0) ;;
|
|
|
|
*) echo "Error: $dec is not recognised"; exit 1
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
echo "$num_bits"
|
|
|
|
}
|
|
|
|
|
|
|
|
function v4prefix2mask(){
|
|
|
|
local a=$1
|
|
|
|
local b=0
|
|
|
|
local num_index=1
|
|
|
|
local str_temp=''
|
|
|
|
local str_mask=''
|
|
|
|
|
|
|
|
while [[ $num_index -le 4 ]]
|
|
|
|
do
|
|
|
|
if [ $a -ge 8 ];then
|
|
|
|
b=8
|
|
|
|
a=$((a-8))
|
|
|
|
else
|
|
|
|
b=$a
|
|
|
|
a=0
|
|
|
|
fi
|
|
|
|
case $b in
|
|
|
|
0) str_temp="0";;
|
|
|
|
1) str_temp="128";;
|
|
|
|
2) str_temp="192";;
|
|
|
|
3) str_temp="224";;
|
|
|
|
4) str_temp="240";;
|
|
|
|
5) str_temp="248";;
|
|
|
|
6) str_temp="252";;
|
|
|
|
7) str_temp="254";;
|
|
|
|
8) str_temp="255";;
|
|
|
|
esac
|
|
|
|
|
|
|
|
str_mask=$str_mask$str_temp"."
|
|
|
|
|
|
|
|
num_index=$((num_index+1))
|
|
|
|
done
|
|
|
|
|
2013-11-14 07:49:05 +00:00
|
|
|
str_mask=`echo $str_mask | sed 's/\.$//'`
|
2013-11-01 10:33:39 +00:00
|
|
|
echo "$str_mask"
|
|
|
|
}
|
|
|
|
|
|
|
|
function v4calcbcase(){
|
|
|
|
local str_mask=$2
|
|
|
|
echo $str_mask | grep '\.' > /dev/null
|
|
|
|
if [ $? -ne 0 ];then
|
|
|
|
str_mask=$(v4prefix2mask $str_mask)
|
|
|
|
fi
|
|
|
|
local str_bcast=''
|
|
|
|
local str_temp=''
|
|
|
|
local str_ifs=$IFS
|
|
|
|
IFS=$'.'
|
|
|
|
local array_ip=($1)
|
|
|
|
local array_mask=($str_mask)
|
|
|
|
IFS=$str_ifs
|
|
|
|
|
|
|
|
if [ ${#array_ip[*]} -ne 4 -o ${#array_mask[*]} -ne 4 ];then
|
|
|
|
echo "255.255.255.255"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
for index in {0..3}
|
|
|
|
do
|
|
|
|
str_temp=`echo $[ ${array_ip[$index]}|(${array_mask[$index]} ^ 255) ]`
|
|
|
|
str_bcast=$str_bcast$str_temp"."
|
|
|
|
done
|
|
|
|
|
2013-11-14 07:49:05 +00:00
|
|
|
str_bcast=`echo $str_bcast | sed 's/\.$//'`
|
2013-11-01 10:33:39 +00:00
|
|
|
echo "$str_bcast"
|
|
|
|
}
|
|
|
|
|
|
|
|
function v4calcnet(){
|
|
|
|
local str_mask=$2
|
|
|
|
echo $str_mask | grep '\.' > /dev/null
|
|
|
|
if [ $? -ne 0 ];then
|
|
|
|
str_mask=$(v4prefix2mask $str_mask)
|
|
|
|
fi
|
|
|
|
local str_net=''
|
|
|
|
local str_temp=''
|
|
|
|
local str_ifs=$IFS
|
|
|
|
IFS=$'.'
|
|
|
|
local array_ip=($1)
|
|
|
|
local array_mask=($str_mask)
|
|
|
|
IFS=$str_ifs
|
|
|
|
|
|
|
|
for index in {0..3}
|
|
|
|
do
|
|
|
|
str_temp=`echo $[ ${array_ip[$index]}&${array_mask[$index]} ]`
|
|
|
|
str_net=$str_net$str_temp"."
|
|
|
|
done
|
|
|
|
|
2013-11-14 07:49:05 +00:00
|
|
|
str_net=`echo $str_net | sed 's/\.$//'`
|
2013-11-01 10:33:39 +00:00
|
|
|
echo "$str_net"
|
|
|
|
}
|
2013-11-08 15:37:18 +00:00
|
|
|
|
|
|
|
function v6expand(){
|
|
|
|
local str_v6address=$1
|
|
|
|
str_v6address=${str_v6address%%/*}
|
|
|
|
echo "$str_v6address" | grep '::' > /dev/null
|
|
|
|
if [ $? -ne 0 ];then
|
|
|
|
echo "$str_v6address"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
local num_colon=`echo "$str_v6address" | grep -o ':' | wc -l`
|
|
|
|
local num_omit=$((7-num_colon))
|
|
|
|
local str_temp=0
|
|
|
|
local num_index=1
|
|
|
|
while [ $num_index -le $num_omit ];do
|
|
|
|
str_temp=$str_temp":0"
|
|
|
|
num_index=$((num_index+1))
|
|
|
|
done
|
|
|
|
|
|
|
|
str_v6address=`echo $str_v6address | sed "s/::/:$str_temp:/" | sed 's/^:/0:/' | sed 's/:$/:0/'`
|
|
|
|
echo "$str_v6address"
|
|
|
|
}
|
|
|
|
|
|
|
|
function v6prefix2mask(){
|
|
|
|
local num_v6prefix=$1
|
|
|
|
num_v6prefix=`echo $num_v6prefix | sed 's:/::g'`
|
|
|
|
if [ $num_v6prefix -gt 128 ];then
|
|
|
|
$num_v6prefix=128
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $num_v6prefix -le 0 ];then
|
|
|
|
$num_v6prefix=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
local num_i=1
|
|
|
|
local str_mask=''
|
|
|
|
while [ $num_i -le 8 ];do
|
|
|
|
if [ $num_v6prefix -ge 16 ];then
|
|
|
|
str_mask=$str_mask"ffff:"
|
|
|
|
num_v6prefix=$((num_v6prefix-16))
|
|
|
|
elif [ $num_v6prefix -eq 0 ];then
|
|
|
|
str_mask=$str_mask"0:"
|
|
|
|
else
|
|
|
|
local str_temp=$(((65535>>$num_v6prefix)^65535))
|
|
|
|
str_temp=`echo "$str_temp"|awk '{printf("%x\n",$0)}'`
|
|
|
|
str_mask=$str_mask"$str_temp:"
|
|
|
|
num_v6prefix=0
|
|
|
|
fi
|
|
|
|
num_i=$((num_i+1))
|
|
|
|
done
|
|
|
|
|
2013-11-14 07:49:05 +00:00
|
|
|
str_mask=`echo $str_mask | sed 's/:$//'`
|
2013-11-08 15:37:18 +00:00
|
|
|
echo "$str_mask"
|
|
|
|
}
|
|
|
|
|
|
|
|
function v6calcnet(){
|
|
|
|
local str_v6ip=$(v6expand $1)
|
|
|
|
local str_v6mask=$2
|
|
|
|
local str_v6net=''
|
|
|
|
|
|
|
|
echo "$str_v6maks " | grep ':' > /dev/null
|
|
|
|
if [ $? -ne 0 ];then
|
|
|
|
str_v6mask=$(v6prefix2mask $str_v6mask)
|
|
|
|
fi
|
|
|
|
|
|
|
|
local str_old_ifs=$IFS
|
|
|
|
IFS=$':'
|
|
|
|
local array_ip=($str_v6ip)
|
|
|
|
local array_mask=($str_v6mask)
|
|
|
|
IFS=$str_old_ifs
|
|
|
|
|
|
|
|
for num_i in {0..7}
|
|
|
|
do
|
|
|
|
str_temp=$(( 0x${array_ip[$num_i]} & 0x${array_mask[$num_i]} ))
|
|
|
|
str_temp=`echo $str_temp | awk '{printf("%x\n",$0)}'`
|
|
|
|
str_v6net=$str_v6net$str_temp":"
|
|
|
|
done
|
|
|
|
|
2013-11-14 07:49:05 +00:00
|
|
|
str_v6net=`echo $str_v6net | sed 's/:$//'`
|
2013-11-08 15:37:18 +00:00
|
|
|
echo "$str_v6net"
|
|
|
|
}
|
2014-06-08 13:01:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
function servicemap {
|
|
|
|
local svcname=$1
|
|
|
|
local svcmgrtype=$2
|
|
|
|
local svclistname=
|
|
|
|
|
2014-06-10 15:54:31 +00:00
|
|
|
INIT_dhcp="dhcp3-server dhcpd isc-dhcp-server";
|
2014-06-08 13:01:15 +00:00
|
|
|
|
2014-07-04 16:06:56 +00:00
|
|
|
INIT_nfs="nfsserver nfs-server nfs nfs-kernel-server";
|
2014-06-08 13:01:15 +00:00
|
|
|
|
|
|
|
INIT_named="named bind9";
|
|
|
|
|
|
|
|
INIT_syslog="syslog syslogd rsyslog";
|
|
|
|
|
2014-07-04 16:06:56 +00:00
|
|
|
INIT_firewall="iptables firewalld SuSEfirewall2_setup ufw";
|
2014-06-08 13:01:15 +00:00
|
|
|
|
|
|
|
INIT_http="apache2 httpd";
|
|
|
|
|
2014-06-10 15:54:31 +00:00
|
|
|
INIT_ntpserver="ntpd ntp";
|
|
|
|
|
|
|
|
INIT_mysql="mysqld mysql";
|
|
|
|
|
|
|
|
INIT_ssh="sshd ssh";
|
|
|
|
|
2014-06-08 13:01:15 +00:00
|
|
|
local path=
|
2014-07-04 16:06:56 +00:00
|
|
|
local postfix=""
|
2014-06-08 13:01:15 +00:00
|
|
|
local retdefault=$svcname
|
|
|
|
local svcvar=${svcname//[-.]/_}
|
|
|
|
if [ "$svcmgrtype" = "0" ];then
|
|
|
|
path="/etc/init.d/"
|
|
|
|
elif [ "$svcmgrtype" = "1" ];then
|
2014-07-15 10:10:05 +00:00
|
|
|
#retdefault=$svcname.service
|
2014-06-08 13:01:15 +00:00
|
|
|
path="/usr/lib/systemd/system/"
|
2014-07-04 16:06:56 +00:00
|
|
|
postfix=".service"
|
|
|
|
elif [ "$svcmgrtype" = "2" ];then
|
|
|
|
path="/etc/init/"
|
|
|
|
postfix=".conf"
|
2014-06-08 13:01:15 +00:00
|
|
|
fi
|
|
|
|
|
2014-07-04 16:06:56 +00:00
|
|
|
svclistname=INIT_$svcvar
|
2014-06-08 13:01:15 +00:00
|
|
|
local svclist=$(eval echo \$$svclistname)
|
|
|
|
|
|
|
|
if [ -z "$svclist" ];then
|
|
|
|
svclist="$retdefault"
|
|
|
|
fi
|
|
|
|
|
|
|
|
for name in `echo $svclist`
|
|
|
|
do
|
2014-07-04 16:06:56 +00:00
|
|
|
if [ -e "$path$name$postfix" ];then
|
2014-06-08 13:01:15 +00:00
|
|
|
echo $name
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function startservice {
|
|
|
|
local svcname=$1
|
|
|
|
local cmd=
|
|
|
|
local svcunit=`servicemap $svcname 1`
|
2014-07-04 16:06:56 +00:00
|
|
|
local svcjob=`servicemap $svcname 2`
|
2014-06-08 13:01:15 +00:00
|
|
|
local svcd=`servicemap $svcname 0`
|
|
|
|
|
|
|
|
if [ -n "$svcunit" ];then
|
|
|
|
cmd="systemctl start $svcunit"
|
2014-07-04 16:06:56 +00:00
|
|
|
elif [ -n "$svcjob" ];then
|
|
|
|
cmd="initctl start $svcjob";
|
2014-06-08 13:01:15 +00:00
|
|
|
elif [ -n "$svcd" ];then
|
|
|
|
cmd="service $svcd start";
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$cmd" ];then
|
|
|
|
return 127
|
|
|
|
fi
|
|
|
|
|
|
|
|
eval $cmd
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function stopservice {
|
|
|
|
local svcname=$1
|
|
|
|
local cmd=
|
|
|
|
local svcunit=`servicemap $svcname 1`
|
2014-07-04 16:06:56 +00:00
|
|
|
local svcjob=`servicemap $svcname 2`
|
2014-06-08 13:01:15 +00:00
|
|
|
local svcd=`servicemap $svcname 0`
|
|
|
|
|
|
|
|
if [ -n "$svcunit" ];then
|
|
|
|
cmd="systemctl stop $svcunit"
|
2014-07-04 16:06:56 +00:00
|
|
|
elif [ -n "$svcjob" ];then
|
|
|
|
initctl status $svcjob | grep stop
|
|
|
|
if [ "$?" = "0" ] ; then
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
cmd="initctl stop $svcjob"
|
|
|
|
fi
|
2014-06-08 13:01:15 +00:00
|
|
|
elif [ -n "$svcd" ];then
|
2014-07-04 16:06:56 +00:00
|
|
|
cmd="service $svcd stop"
|
2014-06-08 13:01:15 +00:00
|
|
|
fi
|
2014-07-04 16:06:56 +00:00
|
|
|
|
|
|
|
echo $cmd
|
2014-06-08 13:01:15 +00:00
|
|
|
|
|
|
|
if [ -z "$cmd" ];then
|
|
|
|
return 127
|
|
|
|
fi
|
|
|
|
|
|
|
|
eval $cmd
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function restartservice {
|
|
|
|
local svcname=$1
|
|
|
|
local cmd=
|
|
|
|
local svcunit=`servicemap $svcname 1`
|
2014-07-04 16:06:56 +00:00
|
|
|
local svcjob=`servicemap $svcname 2`
|
2014-06-08 13:01:15 +00:00
|
|
|
local svcd=`servicemap $svcname 0`
|
|
|
|
|
|
|
|
if [ -n "$svcunit" ];then
|
|
|
|
cmd="systemctl restart $svcunit"
|
2014-07-04 16:06:56 +00:00
|
|
|
elif [ -n "$svcjob" ];then
|
|
|
|
initctl status $svcjob | grep stop
|
|
|
|
if [ "$?" = "0" ];then
|
|
|
|
cmd= "initctl start $svcjob"
|
|
|
|
else
|
|
|
|
cmd="initctl restart $svcjob"
|
|
|
|
fi
|
2014-06-08 13:01:15 +00:00
|
|
|
elif [ -n "$svcd" ];then
|
2014-07-04 16:06:56 +00:00
|
|
|
cmd="service $svcd restart"
|
2014-06-08 13:01:15 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$cmd" ];then
|
|
|
|
return 127
|
|
|
|
fi
|
|
|
|
|
|
|
|
eval $cmd
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function checkservicestatus {
|
|
|
|
local svcname=$1
|
|
|
|
|
|
|
|
local svcunit=`servicemap $svcname 1`
|
2014-07-04 16:06:56 +00:00
|
|
|
local svcjob=`servicemap $svcname 2`
|
2014-06-08 13:01:15 +00:00
|
|
|
local svcd=`servicemap $svcname 0`
|
|
|
|
|
|
|
|
local output=
|
|
|
|
local retcode=3
|
|
|
|
|
|
|
|
if [ -n "$svcunit" ];then
|
|
|
|
output=$(systemctl show --property=ActiveState $svcunit|awk -F '=' '{print $2}')
|
|
|
|
if echo $output|grep -E -i "^active$";then
|
|
|
|
retcode=0
|
|
|
|
elif echo $output|grep -E -i "^inactive$";then
|
|
|
|
retcode=1
|
|
|
|
elif echo $output|grep -E -i "^failed$";then
|
|
|
|
retcode=2
|
|
|
|
fi
|
2014-07-04 16:06:56 +00:00
|
|
|
elif [ -n "$svcjob" ];then
|
|
|
|
output=$(initctl status $svcjob)
|
|
|
|
if echo $output|grep -i "waiting";then
|
|
|
|
retcode=2
|
|
|
|
elif echo $output|grep -i "running";then
|
|
|
|
retcode=0
|
|
|
|
fi
|
2014-06-08 13:01:15 +00:00
|
|
|
elif [ -n "$svcd" ];then
|
|
|
|
output=$(service $svcd status)
|
|
|
|
retcode=$?
|
|
|
|
echo $output
|
|
|
|
# if echo $output|grep -E -i "(stopped|not running)";then
|
|
|
|
# retcode=1
|
|
|
|
# elif echo $output|grep -E -i "running";then
|
|
|
|
# retcode=0
|
|
|
|
# fi
|
|
|
|
else
|
|
|
|
retcode=127
|
|
|
|
fi
|
2014-07-04 16:06:56 +00:00
|
|
|
#echo $svcunit-----$svcd
|
2014-06-08 13:01:15 +00:00
|
|
|
return $retcode
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function enableservice {
|
|
|
|
local svcname=$1
|
|
|
|
local cmd=
|
|
|
|
local svcunit=`servicemap $svcname 1`
|
2014-07-04 16:06:56 +00:00
|
|
|
local svcjob=`servicemap $svcname 2`
|
2014-06-08 13:01:15 +00:00
|
|
|
local svcd=`servicemap $svcname 0`
|
|
|
|
|
|
|
|
if [ -n "$svcunit" ];then
|
|
|
|
cmd="systemctl enable $svcunit"
|
2014-07-04 16:06:56 +00:00
|
|
|
elif [ -n "$svcjob" ];then
|
|
|
|
cmd="update-rc.d $svcjob defaults"
|
2014-06-08 13:01:15 +00:00
|
|
|
elif [ -n "$svcd" ];then
|
|
|
|
command -v chkconfig >/dev/null 2>&1
|
|
|
|
if [ $? -eq 0 ];then
|
2014-07-04 16:06:56 +00:00
|
|
|
cmd="chkconfig $svcd on"
|
2014-06-08 13:01:15 +00:00
|
|
|
else
|
|
|
|
command -v update-rc.d >/dev/null 2>&1
|
|
|
|
if [ $? -eq 0 ];then
|
|
|
|
cmd="update-rc.d $svcd defaults"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$cmd" ];then
|
|
|
|
return 127
|
|
|
|
fi
|
|
|
|
|
|
|
|
eval $cmd
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function disableservice {
|
|
|
|
local svcname=$1
|
|
|
|
local cmd=
|
|
|
|
local svcunit=`servicemap $svcname 1`
|
2014-07-04 16:06:56 +00:00
|
|
|
local svcjob=`servicemap $svcname 2`
|
2014-06-08 13:01:15 +00:00
|
|
|
local svcd=`servicemap $svcname 0`
|
|
|
|
|
|
|
|
if [ -n "$svcunit" ];then
|
|
|
|
cmd="systemctl disable $svcunit"
|
2014-07-04 16:06:56 +00:00
|
|
|
elif [ -n "svcjob" ];then
|
|
|
|
cmd="update-rc.d -f $svcd remove"
|
2014-06-08 13:01:15 +00:00
|
|
|
elif [ -n "$svcd" ];then
|
|
|
|
command -v chkconfig >/dev/null 2>&1
|
|
|
|
if [ $? -eq 0 ];then
|
|
|
|
cmd="chkconfig $svcd off";
|
|
|
|
else
|
|
|
|
command -v update-rc.d >/dev/null 2>&1
|
|
|
|
if [ $? -eq 0 ];then
|
|
|
|
cmd="update-rc.d -f $svcd remove"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$cmd" ];then
|
|
|
|
return 127
|
|
|
|
fi
|
|
|
|
|
|
|
|
eval $cmd
|
|
|
|
}
|