Installing the configuration xinetd Super daemon and rsync is very simple. In the study, I wrote an automated deployment of the script, after testing can be used, has done the basic optimization, although simple, but still want to record, for everyone to reference, look forward to you can help me to guide twos.
The script is as follows:
#! /bin/bash# determine whether to download the installation xinetd service rpm -qa |grep xinetd >/dev/null# if not installed if [ [ $? == 1 ]] thenyum install xinetd -yif [[ $? == 1 ]];thenecho "xinetd download failed! Check to see if your network is unblocked. "exitfiecho " XINETD installed successfully! "fi# See if Rsync installs rpm -qa |grep rsync >/dev/null# if not installed if [[ $? == 1 ]]thenyum install rsync -yif [[ $? == 1 ]];thenecho " rsync Download failed! "exitfiecho " Rsync installed successfully! "fi# configuration operation after installation touch /etc/rsyncd.confcat >>/etc/rsyncd.conf<<eof#rsync_config#created by hq at 2017# #rsyncd. conf start# #uid = rsyncgid = rsyncuse chroot = nomax connections = 200timeout = 300pid file = /var/run/rsyncd.pidlock file = /var/run/rsync.locklog file = /var/log/ rsyncd.logignore errorsread only = falselist = false#hosts allow = 172.16.1.0/24#hosts deny = 0.0.0.0/32auth users = rsync_backupsecrets file = /etc/rsync.password[ backup]comment = "Backup dir by oldboy" path = /backupeof # Create a password file and authorize 600touch /etc/rsync.passwordecho ' rsync_backup:oldboy123 ' >/etc/rsync.passwordchmod 600 /etc/rsync.password# Create rsync user id rsync >/dev/nullif [[ $? == 1 ] ];thenuseradd -m -s /sbin/nologin rsyncelseecho "User already exists! "fi# Create a backup directory and give the rsync owner group mkdir -p /backupchown -r rsync.rsync /backup# Configuration Daemon # See if there are rsyncif [[ -f /etc/xinetd.d/rsync ]];thensed -ri ' [email inside the XINETD.D Protected] (. *disable.*=). *@\1 [email protected] ' /etc/xinetd.d/rsyncelseecho ' no/etc/ Xinetd.d/rsync file Now! ' exitfi# start daemon/etc/init.d/xinetd start >/dev/null echo ' has started xinetd! ' #检查是否开机自启动chk = ' chkconfig |grep xinetd|awk ' nr==1{print $5} ' if [[ $chk == "3:on" ]]thenecho "has been added to boot entry!" "elsechkconfig xinetd onif [[ $? == 0 ]]thenecho " has been added to boot entry! "elseecho " Add boot failed! "fifi# Print status netstat -lntup|grep xinetd# print show account password echo " ******************************************** "echo -e " \033[42;37m rsync backup directory:/backup \033[0m "echo -e " \033[43;37m rsync Remote connection user name: rsync_backup \033[0m "echo -e " \033[44;37m rsync Remote connection user password: oldboy123 \033[ 0m "echo " ******************************************** "
Test results:
Share a script that automates the configuration of xinetd and rsync