Advertisement
Guest User

generate DotCloud ssh -D bash script

a guest
Jan 28th, 2012
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #! /bin/bash
  2. printf "输入 DotCloud 认用名字: " >&2
  3. read
  4. AppID="${REPLY}.www"
  5. key="$HOME/.dotcloud/dotcloud.key"
  6. lport=7070
  7. rport=$(dotcloud info "$AppID" | sed '/ssh:\/\/.*/!d;s/^.*\/\///' | cut -d: -f2)
  8. host=$(dotcloud info "$AppID" | sed '/ssh:\/\/.*/!d;s/^.*\/\///' | cut -d: -f1)
  9. script_name="$HOME/${REPLY}_ssh"
  10.  
  11. if [ ! -f "$key" ] ; then
  12. echo "You do not have $key, I can\'t make ssh script" >&2
  13. exit 5
  14. fi
  15. if [ -z "$host" ] ; then
  16. echo "Your DotCloud APPID seems not found. Fail to make ssh script." >&2
  17. exit 6
  18. fi
  19.  
  20. echo "ssh -i $key -vNfD $lport $host -p $rport" > "$script_name"
  21. [ $? -eq 0 ] && chmod 755 "$script_name" && echo "$script_name is made."
  22. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement