-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
164 lines (132 loc) · 6.09 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
package main
import (
"fmt"
"log"
"golang.org/x/crypto/ssh"
)
func main() {
var ip, password string
// Taking input for IP and Password
fmt.Println(`
██████ ███████ ██ ███████ ███████ ████████ ██ █████
██ ██ ██ ██ ██ ██ ██ ██ ██
██ █████ ██ █████ ███████ ██ ██ ███████
██ ██ ██ ██ ██ ██ ██ ██ ██
██████ ███████ ███████ ███████ ███████ ██ ██ ██ ██
██████╗ ███╗ ██╗███████╗ ██████╗██╗ ██╗ ██████╗██╗ ██╗ ███╗ ██╗ ██████╗ ██████╗ ███████╗
██╔═══██╗████╗ ██║██╔════╝ ██╔════╝██║ ██║██╔════╝██║ ██╔╝ ████╗ ██║██╔═══██╗██╔══██╗██╔════╝
██║ ██║██╔██╗ ██║█████╗ ██║ ██║ ██║██║ █████╔╝ ██╔██╗ ██║██║ ██║██║ ██║█████╗
██║ ██║██║╚██╗██║██╔══╝ ██║ ██║ ██║██║ ██╔═██╗ ██║╚██╗██║██║ ██║██║ ██║██╔══╝
╚██████╔╝██║ ╚████║███████╗ ╚██████╗███████╗██║╚██████╗██║ ██╗ ██║ ╚████║╚██████╔╝██████╔╝███████╗
╚═════╝ ╚═╝ ╚═══╝╚══════╝ ╚═════╝╚══════╝╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═══╝ ╚═════╝ ╚═════╝ ╚══════╝
`)
fmt.Println("Enter VPS IP address: ")
fmt.Scanln(&ip)
fmt.Println("Enter VPS password: ")
fmt.Scanln(&password)
// Printing the input values
fmt.Println("VPS IP address:", ip)
fmt.Println("VPS password:", password)
// Configuring SSH client
config := &ssh.ClientConfig{
User: "root",
Auth: []ssh.AuthMethod{
ssh.Password(password),
},
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
}
// Establishing SSH connection
conn, err := ssh.Dial("tcp", ip+":22", config)
if err != nil {
fmt.Println("Failed to dial:", err)
return
}
// Create separate sessions for each command
session1, err := conn.NewSession()
if err != nil {
log.Fatalf("Failed to create session: %v", err)
}
defer session1.Close()
session3, err := conn.NewSession()
if err != nil {
log.Fatalf("Failed to create session: %v", err)
}
defer session3.Close()
session4, err := conn.NewSession()
if err != nil {
log.Fatalf("Failed to create session: %v", err)
}
defer session4.Close()
session5, err := conn.NewSession()
if err != nil {
log.Fatalf("Failed to create session: %v", err)
}
defer session5.Close()
session6, err := conn.NewSession()
if err != nil {
log.Fatalf("Failed to create session: %v", err)
}
defer session6.Close()
session7, err := conn.NewSession()
if err != nil {
log.Fatalf("Failed to create session: %v", err)
}
defer session7.Close()
session8, err := conn.NewSession()
if err != nil {
log.Fatalf("Failed to create session: %v", err)
}
defer session8.Close()
session9, err := conn.NewSession()
if err != nil {
log.Fatalf("Failed to create session: %v", err)
}
defer session9.Close()
// Start the first command
if err := session1.Start("sudo apt update"); err != nil {
log.Fatalf("Failed to start command: %v", err)
}
// Wait for the first command to complete
if err := session1.Wait(); err != nil {
log.Fatalf("Failed to run command: %v", err)
}
// Start the 3 command
if err := session3.Start("sudo apt install curl tar wget clang pkg-config libssl-dev jq build-essential git make ncdu -y"); err != nil {
log.Fatalf("Failed to start command: %v", err)
}
// Wait for the 3 command to complete
if err := session3.Wait(); err != nil {
log.Fatalf("Failed to run command: %v", err)
}
// Start the 4 command
if err := session4.Run("ver=\"1.20.2\" && cd $HOME && wget \"https://golang.org/dl/go$ver.linux-amd64.tar.gz\""); err != nil {
log.Fatalf("Failed to run command: %s", err)
}
// Start the 5 command
if err := session5.Start("sudo rm -rf /usr/local/go"); err != nil {
log.Fatalf("Failed to start command: %v", err)
}
// Wait for the 5 command to complete
if err := session5.Wait(); err != nil {
log.Fatalf("Failed to run command: %v", err)
}
// Start the 6 command
if err := session6.Run("sudo tar -C /usr/local -xzf \"go1.20.2.linux-amd64.tar.gz\" && rm \"go1.20.2.linux-amd64.tar.gz\""); err != nil {
log.Fatalf("Failed to run command: %s", err)
}
// Start the 7 command
if err := session7.Run(`echo "export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin" >> $HOME/.bash_profile; source $HOME/.bash_profile`); err != nil {
log.Fatalf("Failed to run command: %s", err)
}
// Start the command 8
if err := session8.Run(`
cd $HOME;
rm -rf celestia-node;
git clone https://github.com/celestiaorg/celestia-node.git;
cd celestia-node/;
git checkout tags/v0.9.3;
`); err != nil {
log.Fatalf("Failed to run command: %s", err)
}
fmt.Println("Installation complete!")
}