droplets.sh 747 B

123456789101112131415161718192021222324
  1. # fixed
  2. apt 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. add-apt-repository ppa:longsleep/golang-backports -y
  10. apt install golang-1.21 -y
  11. apt install golang -y
  12. curl -H "Authorization: token $token" -XPOST http://hubgit.cn/api/v1/user/keys -H 'content-type: application/json' -d"{\"title\":\"slave$now\", \"key\": \"$key\"}"
  13. ssh-keygen -F hubgit.cn || ssh-keyscan hubgit.cn >~/.ssh/known_hosts
  14. # changed
  15. git clone root@hubgit.cn:ben/be-vpn.git
  16. cd be-vpn
  17. chmod +x ./scripts/openvpn-install.sh
  18. export AUTO_INSTALL=y && ./scripts/openvpn-install.sh
  19. go build ./cmd/slave.go
  20. nohup ./slave &