Browse Source

Mod: script

yemingfeng 2 months ago
parent
commit
bf8abefcff
2 changed files with 50 additions and 14 deletions
  1. 1 1
      cmd/slave.go
  2. 49 13
      scripts/ubuntu22.sh

+ 1 - 1
cmd/slave.go

@@ -17,7 +17,7 @@ func main() {
 	vip := flag.Bool("vip", false, "vip if or not")
 	flag.Parse()
 
-	file, err := os.Open("/home/ubuntu/client.ovpn")
+	file, err := os.Open("/root/client.ovpn")
 	if err != nil {
 		log.Fatalf("can not open file, err: %+v", err)
 	}

+ 49 - 13
scripts/ubuntu22.sh

@@ -4,24 +4,60 @@ sed -i "s/#\$nrconf{kernelhints} = -1;/\$nrconf{kernelhints} = -1;/g" /etc/needr
 
 sudo DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y
 
-apt update -y
-ssh-keygen -q -t rsa -N '' -f ~/.ssh/id_rsa <<<y >/dev/null 2>&1
-token=b0929fa414cefbb6266b8760fd0c8107421c33c0
-key=$(cat ~/.ssh/id_rsa.pub)
-echo $key
-now=$(date +%Y-%m-%dT%H:%M:%S.%N)
-echo $now
+cat > /root/.ssh/id_rsa.pub << EOF
+ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDB60cDQjWkBl5hKvQc53mtKSnfEKKCQc5vCq4SRgiseZ+DjYSCHshUHsVW7RtzMMllv3iTTOKcWjkLPxSs7mfTWfMac6LVuMIungsC/Sp1MUwVdzz/9T0geTx0tpuIS+5FCw/iuqJKe31ucaF0UJMUBWRPvMjc5UXAMqKPaSrtTb98sE0398eRWYSa7xrho8y0lWepp5i7fG1fKmRZE4i/yKTtLsPLKhgwvuPgsD+E+fhAmT2zEHZKZ/LRhnfBiB4Pli4aoFV85p7Q9PXwQ+4SsNhA8aYeGLtneVkfWNOSb6xbek7Uz+PN2k5s2gAckZKXVrubgCqZtF+U9aHmwEJYwsbITeB1ZiyRnYDRJ13PKBooV1NftppGUTtnOWqpKtNnztuYQimXQrYQMJb/3N7rQ7GWBkbJ00JYAQ3GXn1ML0qT4oWQmy9SDymROCwd6K5tMjXhiHj5DYnUTO5hhEEKLKNojboCzSWIiKoous/8I0OyyTUE+Fzl5jYRQ4bE9F8=
+EOF
 
-add-apt-repository ppa:longsleep/golang-backports -y
-apt install golang-1.21 -y
-apt install golang -y
-curl -H "Authorization: token $token" -XPOST http://hubgit.cn/api/v1/user/keys -H 'content-type: application/json' -d"{\"title\":\"slave$now\", \"key\": \"$key\"}"
-ssh-keygen -F hubgit.cn || ssh-keyscan hubgit.cn >~/.ssh/known_hosts
+cat > /root/.ssh/id_rsa << EOF
+-----BEGIN OPENSSH PRIVATE KEY-----
+b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn
+NhAAAAAwEAAQAAAYEAwetHA0I1pAZeYSr0HOd5rSkp3xCigkHObwquEkYIrHmfg42Egh7I
+VB7FVu0bczDJZb94k0zinFo5Cz8UrO5n01nzGnOi1bjCLp4LAv0qdTFMFXc8//U9IHk8dL
+abiEvuRQsP4rqiSnt9bnGhdFCTFAVkT7zI3OVFwDKij2kq7U2/fLBNN/fHkVmEmu8a4aPM
+tJVnqaeYu3xtXypkWROIv8ik7S7DyyoYML7j4LA/hPn4QJk9sxB2Smfy0YZ3wYgeD5YuGq
+BVfOae0PT18EPuErDYQPGmHhi7Z3lZH1jTkm+sW3pO1M/jzdpObNoAHJGSl1a7m4AqmbRf
+lPWh5sBCWMLGyE3gdWYskZ2A0SddzygaKFdTX7aaRlE7ZzlqqSrTZ87bmEIpl0K2EDCW/9
+ze60OxlgZGydNCWAENxl59TC9Kk+KFkJsvUg8pkTgsHeiubTI14Yh4+Q2J1EzuYYRBCiyj
+aI26As0liIiqKLrP/CNDssk1BPhc5eY2EUOGxPRfAAAFkM7QvrrO0L66AAAAB3NzaC1yc2
+EAAAGBAMHrRwNCNaQGXmEq9Bznea0pKd8QooJBzm8KrhJGCKx5n4ONhIIeyFQexVbtG3Mw
+yWW/eJNM4pxaOQs/FKzuZ9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GwQ957nJy0Q+DX3cz7VYsWIU6e3JQ9ZH6ptFBMpIm6I4CNNksZLSE2oQZbpuHQ
+Tre+WD7d4xHQ3m1RnFVu1hEiHg+P06WlCzLF6BRIO0AL12rrNQIAuUBDGtXpUPU1iZYV9q
+ImaRV6wIs0T6Mj8KTkv2zFsdAi5mBW1mwH7aGeRCoCGgT0/7IAAADBAMscHxo/jaeaxpf8
+/A/uYhQ9mZiz51Pg5FYNXshkghELJ4Bjbs5g3MtRkGZg8tBHzuZfeYKETRG8Jx2ZaFf5Ea
+gHimVI7a1WNpo4NT2vC4UfSWHn9GojaS7wT6E4O69aFsYk69gvXPgXYNUd32XGCiMVZOrM
+tYfLHTY2lkRbOCDyUpgE08YNSZhmELH/28YZTaB16n+T33tv3pUiazRI3/hxWmu6uW9kVU
+rktMF9+dQdHW38YSkpsOuJNHxD3SmhdQAAAMEA9Gp4ppm1idAbKs6P3obR0hC1pOIHj6aX
+qCUZmxxCe+dhu0zJFGPoHV9wmt9ulGtg4keGOPmjYDaKjDKINeiJh0iq13aCOfB5AJurFX
+V58qf/+Tkr7hi62d3a120pguIG+ch4Ph/MFqKQ3ldTWxAriwsVeJgtOoAYuxMcL8fzAQtL
+VAh7NmBC7pJp0Ct/H5rj/BooOHunfbY1dUqPtjhrkDDPnv3YWHqc0Ue9F/xypQEbX5qUa2
+O5Ewg0+A83ldADAAAAFnJvb3RAbnljMy0wMS12MjAyNTAxMTMBAgME
+-----END OPENSSH PRIVATE KEY-----
+EOF
 
-# changed
+ssh-keygen -F hubgit.cn || ssh-keyscan hubgit.cn >~/.ssh/known_hosts
 git clone root@hubgit.cn:ben/be-vpn.git
 cd be-vpn
 
+apt update -y
+add-apt-repository ppa:longsleep/golang-backports -y
+apt install golang-1.21 -y
+apt install golang -y
+
 chmod +x ./scripts/openvpn-install.sh
 export AUTO_INSTALL=y && ./scripts/openvpn-install.sh