#!/bin/bash
##############################################################
# File Name: Rsync.sh
# Version: V1.0
# Author: Da Kai
# Organization: http://dakaige517.blog.51cto.com
# Created Time : 2017-06-25 13:06:27
# Description:This is a shell script to install the rsync service
##############################################################
. /etc/init.d/functions
function install_check(){
rpm -qa rsync
if [ $? -eq 0 ]
then
action "Rsync is installed" /bin/true
else
echo "Rsync is not installed"
yum install rsync -y
fi
}
function install(){
if [ -f /etc/rsyncd.conf ]
then
echo "/etc/rsyncd.conf is exist."
else
cat >/etc/rsyncd.conf</etc/rsync.password
chmod 600 /etc/rsync.password
fi
rsync --daemon
if [ $? -eq 0 ]
then
action "Rsync service is successfully to start." /bin/true
echo 'rsync --daemon' >>/etc/rc.local
else
action "Rsync service is failed to start" /bin/false
fi
ps -ef|grep "rsync --daemon"
if [ $? -eq 0 ]
then
action "Rsync service is running." /bin/true
else
action "Rsync service is not running." /bin/false
fi
}
function add_modul(){
echo -e "Usage:\n[backup]\npath = /backup/"
echo "-------添加模块---------"
read -p "请添加模块名称: " name
read -p "请添加模块相对应的位置(目录)path = " directory
mkdir -p $directory
cat >>/etc/rsyncd.conf<