Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/remote/connutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ mkdir -p {{.installDir}} || exit 1;
cat > {{.tempPath}} || exit 1;
mv {{.tempPath}} {{.installPath}} || exit 1;
chmod a+x {{.installPath}} || exit 1;
cp {{.installPath}} {{.wavePath}} || exit 1;
`)
var installTemplate = template.Must(template.New("wsh-install-template").Parse(installTemplateRawDefault))

Expand All @@ -116,6 +117,7 @@ func CpWshToRemote(ctx context.Context, client *ssh.Client, clientOs string, cli
"installDir": filepath.ToSlash(filepath.Dir(wavebase.RemoteFullWshBinPath)),
"tempPath": wavebase.RemoteFullWshBinPath + ".temp",
"installPath": wavebase.RemoteFullWshBinPath,
"wavePath": wavebase.RemoteFullWaveBinPath,
}
var installCmd bytes.Buffer
if err := installTemplate.Execute(&installCmd, installWords); err != nil {
Expand Down
8 changes: 7 additions & 1 deletion pkg/util/shellutil/shellutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,15 +409,21 @@ func initCustomShellStartupFilesInternal() error {
return nil
}
wshDstPath := filepath.Join(binDir, "wsh")
waveDstPath := filepath.Join(binDir, "wave")
if runtime.GOOS == "windows" {
wshDstPath = wshDstPath + ".exe"
waveDstPath = waveDstPath + ".exe"
}
err = utilfn.AtomicRenameCopy(wshDstPath, wshFullPath, 0755)
if err != nil {
return fmt.Errorf("error copying wsh binary to bin: %v", err)
}
err = utilfn.AtomicRenameCopy(waveDstPath, wshFullPath, 0755)
if err != nil {
return fmt.Errorf("error copying wave binary to bin: %v", err)
}
wshBaseName := filepath.Base(wshFullPath)
log.Printf("wsh binary successfully copied from %q to %q\n", wshBaseName, wshDstPath)
log.Printf("wsh binary successfully copied from %q to %q and %q\n", wshBaseName, wshDstPath, waveDstPath)
return nil
}

Expand Down
1 change: 1 addition & 0 deletions pkg/wavebase/wavebase.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const ConfigDir = "config"
const RemoteWaveHomeDirName = ".waveterm"
const RemoteWshBinDirName = "bin"
const RemoteFullWshBinPath = "~/.waveterm/bin/wsh"
const RemoteFullWaveBinPath = "~/.waveterm/bin/wave"
const RemoteFullDomainSocketPath = "~/.waveterm/wave-remote.sock"

const AppPathBinDir = "bin"
Expand Down
8 changes: 8 additions & 0 deletions pkg/wslconn/wsl-util.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,15 @@ var installTemplatesRawBash = map[string]string{
"cat": `bash -c 'cat > {{.tempPath}}'`,
"mv": `bash -c 'mv {{.tempPath}} {{.installPath}}'`,
"chmod": `bash -c 'chmod a+x {{.installPath}}'`,
"cp": `bash -c 'cp {{.installPath}} {{.wavePath}}'`,
}

var installTemplatesRawDefault = map[string]string{
"mkdir": `mkdir -p {{.installDir}}`,
"cat": `cat > {{.tempPath}}`,
"mv": `mv {{.tempPath}} {{.installPath}}`,
"chmod": `chmod a+x {{.installPath}}`,
"cp": `cp {{.installPath}} {{.wavePath}}`,
}

func makeCancellableCommand(ctx context.Context, client *wsl.Distro, cmdTemplateRaw string, words map[string]string) (*CancellableCmd, error) {
Expand Down Expand Up @@ -154,6 +156,7 @@ func CpWshToRemote(ctx context.Context, client *wsl.Distro, clientOs string, cli
"installDir": filepath.ToSlash(filepath.Dir(wavebase.RemoteFullWshBinPath)),
"tempPath": wavebase.RemoteFullWshBinPath + ".temp",
"installPath": wavebase.RemoteFullWshBinPath,
"wavePath": wavebase.RemoteFullWaveBinPath,
}

blocklogger.Infof(ctx, "[conndebug] copying %q to remote server %q\n", wshLocalPath, wavebase.RemoteFullWshBinPath)
Expand Down Expand Up @@ -216,6 +219,11 @@ func CpWshToRemote(ctx context.Context, client *wsl.Distro, clientOs string, cli
return err
}

_, err = installStepCmds["cp"].Cmd.Output()
if err != nil {
return err
}

return nil
}

Expand Down
Loading