Share a script that automates the configuration of xinetd and rsync

Source: Internet
Author: User
Tags rsync

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.