site-add 663 B

123456789101112131415161718192021222324252627282930
  1. #!/bin/bash
  2. if [[ "$1" != "" ]] && [[ "$2" != "" ]]; then
  3. root="";
  4. stype="";
  5. if [[ "$3" != "" ]];then
  6. root="$3";
  7. fi;
  8. echo -e "\nType:\n (1) ssh\n (2) ftp\n (3) rsync";
  9. while [[ ! $stype =~ ^1|2|3$ ]]; do
  10. read stype;
  11. done;
  12. case $stype in
  13. 1)
  14. stype="ssh";
  15. ;;
  16. 2)
  17. stype="ftp";
  18. ;;
  19. 3)
  20. stype="rsync";
  21. ;;
  22. esac;
  23. read -s -p "Password:" pass;
  24. file=`dirname $BASH_SOURCE`/../etc/sites.d/$1@$2;
  25. touch $file;
  26. echo "sites+=(\"[username]='$1' [host]='$2' [password]='$(echo $pass | gpg -c | base64)' [root]='$root' [type]='$stype'\")" > $file;
  27. echo -e "Site $1@$2 created";
  28. else
  29. echo "Usage: $0 <username> <hostname> [<root directory>]"
  30. fi;