slave.sh 736 B

12345678910111213141516171819202122232425262728
  1. #!/bin/bash
  2. yum update -y
  3. ssh-keygen -q -t rsa -N '' -f ~/.ssh/id_rsa <<<y >/dev/null 2>&1
  4. token=b0929fa414cefbb6266b8760fd0c8107421c33c0
  5. key=$(cat ~/.ssh/id_rsa.pub)
  6. echo $key
  7. now=$(date +%Y-%m-%dT%H:%M:%S.%N)
  8. echo $now
  9. curl -H "Authorization: token $token" -XPOST http://hubgit.cn/api/v1/user/keys -H 'content-type: application/json' -d"{\"title\":\"slave$now\", \"key\": \"$key\"}"
  10. yum install git -y
  11. # clone project
  12. ssh-keygen -F hubgit.cn || ssh-keyscan hubgit.cn >>~/.ssh/known_hosts
  13. git clone root@hubgit.cn:ben/be-vpn.git
  14. cd be-vpn
  15. # install openvpn
  16. chmod +x ./scripts/openvpn-install.sh
  17. export AUTO_INSTALL=y && ./scripts/openvpn-install.sh
  18. # install golang
  19. yum install golang -y
  20. go build ./cmd/slave.go
  21. nohup ./slave &