您好,登錄后才能下訂單哦!
這篇文章主要講解了“怎么搭建Rsync服務(wù)端”,文中的講解內(nèi)容簡(jiǎn)單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來(lái)研究和學(xué)習(xí)“怎么搭建Rsync服務(wù)端”吧!
#!/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<<EOF ######rsync_config_______________start #created by oldboy 15:01 2007-6-25 #QQ 1151887353 blog:http://dakaige517.blog.51cto.com ##rsyncd.conf start## 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 [backup] path = /backup/ ignore errors read only = false list = false hosts allow = 172.16.1.0/24 #hosts deny = 0.0.0.0/32 auth users = rsync_backup secrets file = /etc/rsync.password #rsync_config_______________end EOF fi awk -F: '{print $1}' /etc/passwd|grep rsync if [ $? -eq 0 ] then echo "rsync is exist" else useradd rsync -s /sbin/nologin -M fi if [ -d /backup ] then echo "/backup is exist." else mkdir -p /backup chown rsync.rsync /backup fi if [ -f /etc/rsync.password ] then echo "/etc/rsync.password is exist." else echo "rsync_backup:123456" >/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 "請(qǐng)?zhí)砑幽K名稱(chēng): " name read -p "請(qǐng)?zhí)砑幽K相對(duì)應(yīng)的位置(目錄)path = " directory mkdir -p $directory cat >>/etc/rsyncd.conf<<EOF $name path = $directory EOF echo "----- 模塊添加成功---- -" } install_check install add_modul
感謝各位的閱讀,以上就是“怎么搭建Rsync服務(wù)端”的內(nèi)容了,經(jīng)過(guò)本文的學(xué)習(xí)后,相信大家對(duì)怎么搭建Rsync服務(wù)端這一問(wèn)題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是億速云,小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。