ubuntu22.sh 1.0 KB

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