- #! /bin/bash
- echo "Please input the new ip:"
- read ip
- echo "please input the web ip:"
- read webip
- echo "please input the db ip:"
- read dbip
- ip1=`echo $ip|awk -F'.' '{print $1"."$2"."$3}'`
- ip2=$ip1.0\/24
- change(){
- sed -i "s#\(^hosts.*\)#& $ip2#g" $1
- }
- addip() {
- scp $1:/etc/rsyncd.conf /tmp/$1-rsyncd.conf >/dev/null
- if grep -q "$ip2" /tmp/$1-rsyncd.conf; then
- echo "$1 has been added the new ip."
- else
- change /tmp/$1-rsyncd.conf
- scp /tmp/$1-rsyncd.conf $1:/etc/rsyncd.conf >/dev/null && echo "$1 add new ip done."
- fi
- }
- addip $webip
- addip $dbip
- if grep -q $ip2 /etc/rsyncd.conf; then
- echo ""
- else
- change /etc/rsyncd.conf
- fi
- 最新活动: 2016-02-25 17:27
- 浏览: 2979
- 关注: 0 人
编辑回复