@@ -83,8 +83,20 @@ func SetupBotViaSSH(ip string, key []byte) error {
83
83
if ! strings .Contains (output , "Vector" ) {
84
84
return doErr (fmt .Errorf ("the remote device is not a vector" ), "checking if vector" )
85
85
}
86
+ SetupSSHStatus = "Checking if Vector is running CFW..."
87
+ output , err = runCmd (client , "cat /build.prop" )
88
+ if err != nil {
89
+ return doErr (err , "checking if cfw" )
90
+ }
91
+ var doCloud bool = true
92
+ var initCommand string = "mount -o rw,remount / && mount -o rw,remount,exec /data && systemctl stop anki-robot.target"
93
+ if strings .Contains (output , "wire_os" ) {
94
+ initCommand = "mount -o rw,remount,exec /data && systemctl stop anki-robot.target"
95
+ // my cfw already has a wire-pod compatible vic-cloud
96
+ doCloud = false
97
+ }
86
98
SetupSSHStatus = "Running initial commands before transfers (screen will go blank, this is normal)..."
87
- _ , err = runCmd (client , "mount -o rw,remount / && mount -o rw,remount,exec /data && systemctl stop anki-robot.target && mv /anki/data/assets/cozmo_resources/config/server_config.json /anki/data/assets/cozmo_resources/config/server_config.json.bak" )
99
+ _ , err = runCmd (client , initCommand )
88
100
if err != nil {
89
101
if ! strings .Contains (err .Error (), "Process exited with status 1" ) {
90
102
return doErr (err , "initial commands" )
@@ -115,53 +127,55 @@ func SetupBotViaSSH(ip string, key []byte) error {
115
127
if err != nil {
116
128
return doErr (err , "new scp client 2" )
117
129
}
118
- err = scpClient .CopyFile (context .Background (), serverConfig , "/anki/ data/assets/cozmo_resources/config /server_config.json" , "0755" )
130
+ err = scpClient .CopyFile (context .Background (), serverConfig , "/data/data /server_config.json" , "0755" )
119
131
if err != nil {
120
132
return doErr (err , "copying server-config.json" )
121
133
}
122
134
scpClient .Session .Close ()
123
- if runtime .GOOS != "android" && ! vars .Packaged {
124
- cloud , err := os .Open ("../vector-cloud/build/vic-cloud" )
125
- if err != nil {
126
- return doErr (err , "transferring new vic-cloud" )
127
- }
128
- SetupSSHStatus = "Transferring new vic-cloud..."
129
- scpClient , err = scp .NewClientBySSH (client )
130
- if err != nil {
131
- return doErr (err , "new scp client 3" )
132
- }
133
- err = scpClient .CopyFile (context .Background (), cloud , "/anki/bin/vic-cloud" , "0755" )
134
- if err != nil {
135
- time .Sleep (time .Second * 1 )
135
+ if doCloud {
136
+ if runtime .GOOS != "android" && ! vars .Packaged {
137
+ cloud , err := os .Open ("../vector-cloud/build/vic-cloud" )
138
+ if err != nil {
139
+ return doErr (err , "transferring new vic-cloud" )
140
+ }
141
+ SetupSSHStatus = "Transferring new vic-cloud..."
136
142
scpClient , err = scp .NewClientBySSH (client )
137
143
if err != nil {
138
- return doErr (err , "copying vic-cloud " )
144
+ return doErr (err , "new scp client 3 " )
139
145
}
140
146
err = scpClient .CopyFile (context .Background (), cloud , "/anki/bin/vic-cloud" , "0755" )
141
147
if err != nil {
142
- return doErr (err , "copying vic-cloud" )
148
+ time .Sleep (time .Second * 1 )
149
+ scpClient , err = scp .NewClientBySSH (client )
150
+ if err != nil {
151
+ return doErr (err , "copying vic-cloud" )
152
+ }
153
+ err = scpClient .CopyFile (context .Background (), cloud , "/anki/bin/vic-cloud" , "0755" )
154
+ if err != nil {
155
+ return doErr (err , "copying vic-cloud" )
156
+ }
143
157
}
144
- }
145
- } else {
146
- resp , _ := http .Get ("https://github.com/kercre123/wire-pod/raw/main/vector-cloud/build/vic-cloud" )
147
- if err != nil {
148
- return doErr (err , "transferring new vic-cloud" )
149
- }
150
- SetupSSHStatus = "Transferring new vic-cloud..."
151
- scpClient , err = scp .NewClientBySSH (client )
152
- if err != nil {
153
- return doErr (err , "new scp client 3" )
154
- }
155
- err = scpClient .CopyFile (context .Background (), resp .Body , "/anki/bin/vic-cloud" , "0755" )
156
- if err != nil {
157
- time .Sleep (time .Second * 1 )
158
+ } else {
159
+ resp , _ := http .Get ("https://github.com/kercre123/wire-pod/raw/main/vector-cloud/build/vic-cloud" )
160
+ if err != nil {
161
+ return doErr (err , "transferring new vic-cloud" )
162
+ }
163
+ SetupSSHStatus = "Transferring new vic-cloud..."
158
164
scpClient , err = scp .NewClientBySSH (client )
159
165
if err != nil {
160
- return doErr (err , "copying vic-cloud " )
166
+ return doErr (err , "new scp client 3 " )
161
167
}
162
168
err = scpClient .CopyFile (context .Background (), resp .Body , "/anki/bin/vic-cloud" , "0755" )
163
169
if err != nil {
164
- return doErr (err , "copying vic-cloud" )
170
+ time .Sleep (time .Second * 1 )
171
+ scpClient , err = scp .NewClientBySSH (client )
172
+ if err != nil {
173
+ return doErr (err , "copying vic-cloud" )
174
+ }
175
+ err = scpClient .CopyFile (context .Background (), resp .Body , "/anki/bin/vic-cloud" , "0755" )
176
+ if err != nil {
177
+ return doErr (err , "copying vic-cloud" )
178
+ }
165
179
}
166
180
}
167
181
}
@@ -182,17 +196,13 @@ func SetupBotViaSSH(ip string, key []byte) error {
182
196
if err != nil {
183
197
return doErr (err , "new scp client 4" )
184
198
}
185
- err = scpClient .CopyFile (context .Background (), cert , "/anki/etc /wirepod-cert.crt" , "0755" )
199
+ err = scpClient .CopyFile (context .Background (), cert , "/data/data /wirepod-cert.crt" , "0755" )
186
200
if err != nil {
187
201
return doErr (err , "copying wire-pod cert" )
188
202
}
189
203
scpClient .Session .Close ()
190
- _ , err = runCmd (client , "cp /anki/etc/wirepod-cert.crt /data/data/wirepod-cert.crt" )
191
- if err != nil {
192
- return doErr (err , "copying wire-pod cert in robot" )
193
- }
194
204
SetupSSHStatus = "Generating new robot certificate (this may take a while)..."
195
- _ , err = runCmd (client , "chmod +rwx /anki /data/assets/cozmo_resources/config/ server_config.json /anki/bin/vic-cloud / data/data/wirepod-cert.crt /anki/etc /wirepod-cert.crt /data/pod-bot-install.sh && /data/pod-bot-install.sh" )
205
+ _ , err = runCmd (client , "chmod +rwx /data /data/server_config.json /data/data/wirepod-cert.crt /data/pod-bot-install.sh && /data/pod-bot-install.sh" )
196
206
if err != nil {
197
207
return doErr (err , "generating new robot cert" )
198
208
}
0 commit comments