sync.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/bash
  2. ############### 一键安装RslSync脚本 ###############
  3. #Author:xiaoz.me
  4. #Update:2017-03-27
  5. #Help:https://www.xiaoz.me/archives/8219
  6. ####################### END #######################
  7. #搜索是否存在RslSync文件夹
  8. isf=$(find /home -name 'RslSync')
  9. #判断文件夹是否存在
  10. if [ "$isf" != "" ]
  11. #已经存在
  12. then
  13. echo "Is already installed!"
  14. #不存在,开始安装
  15. else
  16. mkdir -p /home/RslSync
  17. cd /home/RslSync
  18. wget https://soft.hixz.org/linux/resilio-sync_x64.tar.gz --no-check-certificate
  19. tar -zxf resilio-sync_x64.tar.gz
  20. rm -rf resilio-sync_x64.tar.gz
  21. ./rslsync --dump-sample-config > sync.conf
  22. declare user=$(cat sync.conf|grep 'login')
  23. declare upass=$(cat sync.conf|grep ",\"password\"")
  24. read -p "请输入用户名:" newuser
  25. suser=${newuser}
  26. declare newuser=",\"login\" : \"${newuser}\""
  27. read -p "请设置密码:" newpass
  28. spass=${newpass}
  29. declare newpass=",\"password\" : \"${newpass}\""
  30. sed -i "s%${user}%${newuser}%g" sync.conf
  31. sed -i "s%${upass}%${newpass}%g" sync.conf
  32. #设置alias
  33. echo "alias mysync='/home/RslSync/mysync.sh'" >> ~/.bashrc
  34. ./rslsync --config sync.conf
  35. echo "############################# 安装成功 #############################"
  36. echo "访问地址:http://IP:8888/"
  37. echo "用户名:"${suser}
  38. echo "密码:"${spass}
  39. echo "帮助中心:https://www.xiaoz.me/archives/8219"
  40. fi