Linux Automation One-click Configuration rsync

Source: Internet
Author: User
Tags auth rsync

function Introduction

1, one-click Configuration rsync

2, does not support multi-module or multi-user

3,-a All random

4, do not add-a need to manually enter the account password

5, the progress bar is only good-looking, does not represent the real progress


#!/bin/bash
Usersuiji= ' Uuidgen | Cut-c 1-10 '
Passwdsuiji= ' Uuidgen | Cut-c 1-10 '
Jindutiao () {
Counter=0
_r=0
_c= ' tput cols '
_procec= ' tput cols '
Tput Cup $_c $_r
printf "["
While [$COUNTER-LT 100]
Do
Counter= ' expr $COUNTER + 1 '
Sleep 0.1
printf "="
_r= ' expr $_r + 1 '
_c= ' expr $_c + 1 '
Tput Cup $_PROCEC 101
printf "]%d%%" $COUNTER
Tput Cup $_c $_r
Done
printf "\ n"
}
If ["$" = = "-A"];then
echo "Fully automatic configuration ....."
Jindutiao
#第一步配置rsync配置文件
Cat >/etc/rsyncd.conf<<eof
UID = rsync
GID = rsync
Use chroot = no
Max connections = 200
Timeout = 300
PID file =/var/run/rsyncd.pid
Lock file =/var/run/rsync.lock
Log file =/var/log/rsyncd.log
Ignore errors
[$usersuiji]
Comment = "Backup dir by Oldboy"
Read Only = False
List = False
Hosts allow = 172.16.1.0/24
Hosts Deny = 0.0.0.0/32
Auth users = $usersuiji
Secrets file =/etc/rsync.password
Path = $usersuiji
Eof
#第二步, create a puppet user to perform rsync
Useradd-s/sbin/nologin-m rsync >>/dev/null
#第三步, create a directory that stores data from each other
CD/&& mkdir $usersuiji
#第四步更改文件权限
Chown-r Rsync.rsync $usersuiji
#第五步创建密码文件及密码
echo $usersuiji: $passwdsuiji >/etc/rsync.password
#第六步修改密码配置文件的权限
chmod 600/etc/rsync.password
#第七步启动rsync
Rsync--daemon
echo "Account number: $usersuiji"
echo "Password: $passwdsuiji"
echo "Backup directory:/$usersuiji"
echo "Module: $usersuiji"
elif ["$ = =" "];then
echo "In Configuration"
Read-p "Please set up your users:" User
Read-p "Please set your password:" passwd
Read-p "Please enter your module:" Mokuai
CD/
Read-p "Please enter your backup directory:" dir
#第一步配置rsync配置文件
Cat >/etc/rsyncd.conf<<eof
UID = rsync
GID = rsync
Use chroot = no
Max connections = 200
Timeout = 300
PID file =/var/run/rsyncd.pid
Lock file =/var/run/rsync.lock
Log file =/var/log/rsyncd.log
Ignore errors
[$mokuai]
Comment = "Backup dir by Oldboy"
Read Only = False
List = False
Hosts allow = 172.16.1.0/24
Hosts Deny = 0.0.0.0/32
Auth users = $user
Secrets file =/etc/rsync.password
Path = $dir
Eof
#第二步, create a puppet user to perform rsync
Useradd-s/sbin/nologin-m rsync >>/dev/null
#第三步, create a directory that stores data from each other
CD/&& mkdir $dir
#第四步更改文件权限
Chown-r Rsync.rsync $dir
#第五步创建密码文件及密码
echo $user: $PASSW >/etc/rsync.password
#第六步修改密码配置文件的权限
chmod 600/etc/rsync.password
#第七步启动rsync
Rsync--daemon
Else
echo "Spec your input"
Fi

Linux Automation One-click Configuration 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.