Skip to content

Commit de5aff6

Browse files
authored
[UNW-176] Ensure Root logs into the Source dir (SSH) (#10)
* Update .bashrc to ensure Root logs into the source dir (whatever it is) * Better comment
1 parent 7ecea65 commit de5aff6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

cmd/ssh.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,14 @@ func ensureHosts(e types.Exec, identityFile string) {
168168
func handleCopySourceDir(isNew bool, e types.Exec, privKey string) error {
169169
// TODO: Wait until port is open before cleaning up the source code
170170

171+
const dstPath = "/home/unweave"
171172
if !config.NoCopySource && isNew {
172173
dir, err := config.GetActiveProjectPath()
173174
if err != nil {
174175
ui.Errorf("Failed to get active project path. Skipping copying source directory")
175176
return fmt.Errorf("failed to get active project path: %v", err)
176177
}
177-
if err := copySource(e.ID, dir, "/home/ubuntu", *e.Connection, privKey); err != nil {
178+
if err := copySource(e.ID, dir, dstPath, *e.Connection, privKey); err != nil {
178179
fmt.Println(err)
179180
}
180181
} else {
@@ -264,6 +265,8 @@ func copySourceUnTar(srcPath, dstPath string, connectionInfo types.ConnectionInf
264265
"-o", "UserKnownHostsFile=/dev/null",
265266
"-i", prvKeyPath,
266267
fmt.Sprintf("%s@%s", connectionInfo.User, connectionInfo.Host),
268+
// ensure dstPath exist and root logs into that path
269+
fmt.Sprintf("mkdir -p %s && echo 'cd %s' > /root/.bashrc &&", dstPath, dstPath),
267270
fmt.Sprintf("tar -xzf %s -C %s && rm -rf %s", srcPath, dstPath, srcPath),
268271
)
269272

0 commit comments

Comments
 (0)