#!/bin/bash
######################
#int
CHECK=`rpm -qa rsync|wc -l`
HOSTIP="192.168.1.0/24"
#rsync
PWD="123456"
USER="rsync_umbe"
PWD_PATH="/etc/rsyncd/rsync.pwd"
RSYNC_USER="rsync"

#loadsys functions
[ -f /etc/init.d/functions ] && . /etc/init.d/functions
RETVAL=0

#check rsync
if [ "$CHECK" -eq 1 ];then
action "Rsync is installed" /bin/true
else
echo "error:rsync in not install"
echo "yum install -y rsync"
yum install rsync -y >>/tmp/rsync_install.log
echo "-------------------" >>/tmp/rsync_install.log
action "rsync in installed" /bin/true
fi

#edit rsync.conf

if [ ! -f /etc/rsyncd.conf ];then
cat >>/etc/rsyncd.conf< #rsync_config_________start
##rsyncd.conf start##
uid = $RSYNC_USER
gid = $RSYNC_USER
use chroot = no
max connections = 200
timeout = 600
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsyncd.lock
log file = /var/log/rsync.log
ignore errors
read only = false
hosts allow= $HOSTIP
hosts deny= 0.0.0.0/32
auth users = $USER
secrets file = $PWD_PATH

[www]
path = /home/wwwroot/sync/
#[blog]
#path
#[bbs]
#path
EOF
action "config is complate" /bin/true
fi
#created rsync catallogue
if [ ! -d /home/wwwroot/sync ];then
mkdir -p /home/wwwroot/sync
chowd -R $RSYNC_USER.$RSYNC_USER /home/wwwroot/sync
fi
#created rsync passwd
if [ ! -f /etc/rsyncd/rsync.pwd ];then
echo "$USER:$PWD" >>/etc/rsyncd/rsync.pwd 0
chmod 600 /etc/rsyncd/rsync.pwd
fi
action "rsync configure successful" /bin/true

##START IP RSYNC
rsync --daemon
[ `ps -ef|grep rsync|grep -v grep|wc -l` -eq 1 ] && {
action "rsync cofigure seccessful" /bin/true
exit $RETVAL
}

Last modification:July 22, 2019
如果觉得我的文章对你有用,请随意赞赏