Skip to content

Commit

Permalink
Enable Bash colors
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaswarynyca authored Dec 14, 2020
2 parents 3f5ee14 + bf35656 commit 93de612
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions cmd/control/console_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,35 @@ func createHomeDir(homedir string, uid, gid int) {
}
}

func enableBashRC(homedir string, uid, gid int) {
if _, err := os.Stat(homedir + "/.bash_logout"); os.IsNotExist(err) {
if err := util.FileCopy("/etc/skel/.bash_logout", homedir+"/.bash_logout"); err != nil {
log.Error(err)
}
if err := os.Chown(homedir+"/.bash_logout", uid, gid); err != nil {
log.Error(err)
}
}

if _, err := os.Stat(homedir + "/.bashrc"); os.IsNotExist(err) {
if err := util.FileCopy("/etc/skel/.bashrc", homedir+"/.bashrc"); err != nil {
log.Error(err)
}
if err := os.Chown(homedir+"/.bashrc", uid, gid); err != nil {
log.Error(err)
}
}

if _, err := os.Stat(homedir + "/.profile"); os.IsNotExist(err) {
if err := util.FileCopy("/etc/skel/.profile", homedir+"/.profile"); err != nil {
log.Error(err)
}
if err := os.Chown(homedir+"/.profile", uid, gid); err != nil {
log.Error(err)
}
}
}

func consoleInitFunc() error {
cfg := config.LoadConfig()

Expand Down Expand Up @@ -248,6 +277,11 @@ sudo ros service up docker-compose
log.Error(err)
}

// Enable Bash colors
enableBashRC("/root", 0, 0)
enableBashRC(rancherHome, 1100, 1100)
enableBashRC(dockerHome, 1101, 1101)

os.Setenv("TERM", "linux")

respawnBinPath, err := exec.LookPath("respawn")
Expand Down

0 comments on commit 93de612

Please sign in to comment.