ubuntu22.sh 868 B

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