slave.sh 698 B

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