autoinstall, fix version check

This commit is contained in:
sawka 2022-09-24 22:42:52 -07:00
parent 982d600d9b
commit bf4fa2031b
4 changed files with 8 additions and 3 deletions

View File

@ -473,6 +473,7 @@ func RemoteNewCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (ss
if !sstore.IsValidConnectMode(connectMode) {
return nil, fmt.Errorf("/remote:new invalid connectmode %q: valid modes are %s", connectMode, formatStrs([]string{sstore.ConnectModeStartup, sstore.ConnectModeAuto, sstore.ConnectModeManual}, "or", false))
}
autoInstall := resolveBool(pk.Kwargs["autoinstall"], true)
var isSudo bool
if sudoStr != "" {
isSudo = true
@ -522,6 +523,7 @@ func RemoteNewCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (ss
RemoteUser: remoteUser,
RemoteHost: remoteHost,
ConnectMode: connectMode,
AutoInstall: autoInstall,
SSHOpts: sshOpts,
RemoteOpts: remoteOpts,
}

View File

@ -678,7 +678,7 @@ func (msh *MShellProc) Launch() {
if err == context.Canceled {
err = fmt.Errorf("forced disconnection")
}
if semver.MajorMinor(mshellVersion) != semver.MajorMinor(MShellVersion) {
if err == nil && semver.MajorMinor(mshellVersion) != semver.MajorMinor(MShellVersion) {
err = fmt.Errorf("mshell version is not compatible current=%s remote=%s", MShellVersion, mshellVersion)
}
if err != nil {

View File

@ -127,8 +127,8 @@ func UpsertRemote(ctx context.Context, r *RemoteType) error {
maxRemoteIdx := tx.GetInt(query)
r.RemoteIdx = int64(maxRemoteIdx + 1)
query = `INSERT INTO remote
( remoteid, physicalid, remotetype, remotealias, remotecanonicalname, remotesudo, remoteuser, remotehost, connectmode, initpk, sshopts, remoteopts, lastconnectts, archived, remoteidx) VALUES
(:remoteid,:physicalid,:remotetype,:remotealias,:remotecanonicalname,:remotesudo,:remoteuser,:remotehost,:connectmode,:initpk,:sshopts,:remoteopts,:lastconnectts,:archived,:remoteidx)`
( remoteid, physicalid, remotetype, remotealias, remotecanonicalname, remotesudo, remoteuser, remotehost, connectmode, autoinstall, initpk, sshopts, remoteopts, lastconnectts, archived, remoteidx) VALUES
(:remoteid,:physicalid,:remotetype,:remotealias,:remotecanonicalname,:remotesudo,:remoteuser,:remotehost,:connectmode,:autoinstall,:initpk,:sshopts,:remoteopts,:lastconnectts,:archived,:remoteidx)`
tx.NamedExecWrap(query, r.ToMap())
return nil
})

View File

@ -681,6 +681,7 @@ func EnsureLocalRemote(ctx context.Context) error {
RemoteUser: user.Username,
RemoteHost: hostName,
ConnectMode: ConnectModeStartup,
AutoInstall: true,
SSHOpts: &SSHOpts{Local: true},
}
err = UpsertRemote(ctx, localRemote)
@ -714,6 +715,7 @@ func AddTest01Remote(ctx context.Context) error {
SSHIdentity: "/Users/mike/aws/mfmt.pem",
},
ConnectMode: ConnectModeStartup,
AutoInstall: true,
}
err = UpsertRemote(ctx, testRemote)
if err != nil {
@ -745,6 +747,7 @@ func AddTest02Remote(ctx context.Context) error {
SSHUser: "test2",
},
ConnectMode: ConnectModeStartup,
AutoInstall: true,
}
err = UpsertRemote(ctx, testRemote)
if err != nil {