diff --git a/cmd/control/autologin.go b/cmd/control/autologin.go index 483255cc..6bb4c00b 100644 --- a/cmd/control/autologin.go +++ b/cmd/control/autologin.go @@ -73,7 +73,9 @@ func autologinAction(c *cli.Context) error { // until I make time to read their source, lets just give us a way to get work done loginBin = "bash" args = append(args, "--login") - os.Setenv("PROMPT_COMMAND", `echo "[`+fmt.Sprintf("Recovery console %s@%s:${PWD}", user, cfg.Hostname)+`]"`) + if mode == "recovery" { + os.Setenv("PROMPT_COMMAND", `echo "[`+fmt.Sprintf("Recovery console %s@%s:${PWD}", user, cfg.Hostname)+`]"`) + } } else { loginBin = "login" args = append(args, "-f", user) @@ -91,7 +93,6 @@ func autologinAction(c *cli.Context) error { //return syscall.Exec(loginBinPath, args, os.Environ()) cmd = exec.Command(loginBinPath, args...) cmd.Env = os.Environ() - cmd.Env = append(cmd.Env, "SVEN", "MORE") cmd.Stderr = os.Stderr cmd.Stdout = os.Stdout diff --git a/cmd/control/console_init.go b/cmd/control/console_init.go index 2f73b4a3..f33a2b3b 100644 --- a/cmd/control/console_init.go +++ b/cmd/control/console_init.go @@ -113,6 +113,23 @@ func consoleInitFunc() error { log.Error(err) } + // write out a profile.d file for the proxy settings. + // maybe write these on the host and bindmount into everywhere? + proxyLines := []string{} + for _, k := range []string{"http_proxy", "HTTP_PROXY", "https_proxy", "HTTPS_PROXY", "no_proxy", "NO_PROXY"} { + if v, ok := cfg.Rancher.Environment[k]; ok { + proxyLines = append(proxyLines, fmt.Sprintf("export %s=%s", k, v)) + } + } + + if len(proxyLines) > 0 { + proxyString := strings.Join(proxyLines, "\n") + proxyString = fmt.Sprintf("#!/bin/sh\n%s\n", proxyString) + if err := ioutil.WriteFile("/etc/profile.d/proxy.sh", []byte(proxyString), 0755); err != nil { + log.Error(err) + } + } + cmd = exec.Command("bash", "-c", `echo $(/sbin/ifconfig | grep -B1 "inet addr" |awk '{ if ( $1 == "inet" ) { print $2 } else if ( $2 == "Link" ) { printf "%s:" ,$1 } }' |awk -F: '{ print $1 ": " $3}') >> /etc/issue`) if err := cmd.Run(); err != nil { log.Error(err) diff --git a/cmd/control/os.go b/cmd/control/os.go index 5084962a..44d6de79 100644 --- a/cmd/control/os.go +++ b/cmd/control/os.go @@ -21,6 +21,7 @@ import ( "github.com/rancher/os/compose" "github.com/rancher/os/config" "github.com/rancher/os/docker" + "github.com/rancher/os/util" "github.com/rancher/os/util/network" ) @@ -104,6 +105,9 @@ func getImages() (*Images, error) { q := u.Query() q.Set("current", config.Version) + if hypervisor := util.GetHypervisor(); hypervisor == "" { + q.Set("hypervisor", hypervisor) + } u.RawQuery = q.Encode() upgradeURL = u.String() diff --git a/init/init.go b/init/init.go index 84177fb0..6385a725 100755 --- a/init/init.go +++ b/init/init.go @@ -452,6 +452,7 @@ func RunInit() error { config.CfgFuncData{"load modules2", loadModules}, config.CfgFuncData{"set proxy env", func(cfg *config.CloudConfig) (*config.CloudConfig, error) { network.SetProxyEnvironmentVariables() + return cfg, nil }}, config.CfgFuncData{"init SELinux", initializeSelinux}, diff --git a/os-config.tpl.yml b/os-config.tpl.yml index da476e96..9402a330 100644 --- a/os-config.tpl.yml +++ b/os-config.tpl.yml @@ -147,6 +147,10 @@ rancher: io.rancher.os.after: cloud-init-execute io.docker.compose.rebuild: always io.rancher.os.console: default + environment: + - HTTP_PROXY + - HTTPS_PROXY + - NO_PROXY net: host uts: host pid: host diff --git a/util/network/network.go b/util/network/network.go index 37e0f9ab..14553f8b 100644 --- a/util/network/network.go +++ b/util/network/network.go @@ -77,6 +77,18 @@ func SetProxyEnvironmentVariables() { log.Errorf("Unable to set NO_PROXY: %s", err) } } + if cfg.Rancher.Network.HTTPProxy != "" { + config.Set("rancher.environment.http_proxy", cfg.Rancher.Network.HTTPProxy) + config.Set("rancher.environment.HTTP_PROXY", cfg.Rancher.Network.HTTPProxy) + } + if cfg.Rancher.Network.HTTPSProxy != "" { + config.Set("rancher.environment.https_proxy", cfg.Rancher.Network.HTTPSProxy) + config.Set("rancher.environment.HTTPS_PROXY", cfg.Rancher.Network.HTTPSProxy) + } + if cfg.Rancher.Network.NoProxy != "" { + config.Set("rancher.environment.no_proxy", cfg.Rancher.Network.NoProxy) + config.Set("rancher.environment.NO_PROXY", cfg.Rancher.Network.NoProxy) + } } func LoadFromNetworkWithCache(location string) ([]byte, error) {