码迷,mamicode.com
首页 > 其他好文 > 详细

batch configure ip address

时间:2018-02-06 10:16:30      阅读:105      评论:0      收藏:0      [点我收藏+]

标签:echo   art   one   false   add   print   action   top   res   

RETVAL=0
oper(){
if [ "$1" == "del" ];then
list=echo{10..1}
else
list=echo{1..10}
fi
for ip in $list;do
if [ $ip -eq 5 ];then
continue
fi
ip addr $1 192.168.1.$ip/14 dev eth0 label eth0:$ip &>/dev/null
RETVAL=$?
if [ $RETVAL -eq 0 ];then
action "$1 $ip" /bin/true
else
action "$1 $ip" /bin/false
fi
done
return $RETVAL
}

case "$1" in
start)
oper add
RETVAL=$?
;;
stop)
oper del
RETVAL=$?
;;
restart)
oper del
sleep 2
oper add
RETVAL=$?
;;
*)
printf "USAGE:$0 {start|stop|restart}\n"
esac
exit $RETVAL

batch configure ip address

标签:echo   art   one   false   add   print   action   top   res   

原文地址:http://blog.51cto.com/546136/2069254

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!