diff --git a/cmd/state-remote-installer/main.go b/cmd/state-remote-installer/main.go index 6409b8b15e..dc9506fd79 100644 --- a/cmd/state-remote-installer/main.go +++ b/cmd/state-remote-installer/main.go @@ -4,6 +4,7 @@ import ( "fmt" "os" "path/filepath" + "regexp" "runtime/debug" "syscall" "time" @@ -40,6 +41,8 @@ func newParams() *Params { return &Params{} } +var filenameRe = regexp.MustCompile(`(?P[^/\\]+?)_(?P[^/\\_.]+)(\.(?P[^.]+))?$`) + func main() { var exitCode int @@ -96,7 +99,15 @@ func main() { } // Store sessionToken to config - err = cfg.Set(anaConst.CfgSessionToken, "remote_"+constants.RemoteInstallerVersion) + webclientId := "remote_" + constants.RemoteInstallerVersion + if matches := filenameRe.FindStringSubmatch(os.Args[0]); matches != nil { + if index := filenameRe.SubexpIndex("webclientId"); index != -1 { + webclientId = matches[index] + } else { + multilog.Error("Invalid subexpression ID for webclient ID") + } + } + err = cfg.Set(anaConst.CfgSessionToken, webclientId) if err != nil { logging.Error("Unable to set session token: " + errs.JoinMessage(err)) }