``` #!/bin/bash ##Edit by wangsuipeng ##Date 2016/10/20 ## Rsync 服务器端脚本 ## 脚本说明:如果系统中已存在rsyncd.conf文件,在该文件后面追加配置项, ## 如果不存在,则新建该文件,并添加配置项 ## 操作说明:执行过本脚本以后,需要做客户端配置 ##项目名 read -p "The Project name:[Not username]" PRO_NAME ##客户端IP read -p "The Client IP:" PRO_BACK_IP ##项目存放位置(类似/opt/appl/project) read -p "The Project path:[/opt/appl/project]" PRO_PATH ##项目用户UID PRO_UID=`stat -c %u $PRO_PATH` ##配置文件 RSYNC_CFG=/etc/rsyncd.conf ##密码文件 PASS_CFG=/etc/rsyncd.pass yum -y install rsync xinetd > /dev/null 2>&1 ##存在rsyncd.conf文件 EXCFG() { cat >> $RSYNC_CFG < $RSYNC_CFG < $PASS_CFG if grep -q "rsync:$PRO_BACK_IP:allow" /etc/hosts.allow then # exit 0 ---直接退出脚本 echo else echo "rsync:$PRO_BACK_IP:allow" >> /etc/hosts.allow fi if grep -q "\byes\b" /etc/xinetd.d/rsync then sed -i 's/yes/no/g' /etc/xinetd.d/rsync fi service xinetd restart if grep -q "\b873\b" /etc/sysconfig/iptables then # exit 0 ---直接退出脚本 echo else iptables -I INPUT 1 -p tcp -m state --state NEW -m tcp --dport 873 -j ACCEPT && service iptables save && service iptables restart fi ```