Add WW_HISTFILE to control shell history location during wwctl image shell
Co-authored-by: Christian Goll <cgoll@suse.com> Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
committed by
Christian Goll
parent
609dc286ef
commit
7f317dff82
@@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
- Added `UniqueField` template function. #829
|
||||
- Added `wwctl image build --syncuser`. #1321
|
||||
- Added support for a DNSSEARCH netdev tag in network configuration overlays. #1256
|
||||
- Added `WW_HISTFILE` to control shell history location during `wwctl image shell`. #1732
|
||||
|
||||
### Changed
|
||||
|
||||
|
||||
@@ -170,6 +170,8 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) {
|
||||
return fmt.Errorf("failed to mount /run: %w", err)
|
||||
}
|
||||
|
||||
os.Setenv("PATH", "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin")
|
||||
|
||||
var ps1Base string
|
||||
if v, ok := os.LookupEnv("WW_PS1"); ok {
|
||||
ps1Base = v
|
||||
@@ -177,10 +179,16 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) {
|
||||
ps1Base = `\w\$ `
|
||||
os.Setenv("WW_PS1", ps1Base)
|
||||
}
|
||||
|
||||
os.Setenv("PS1", fmt.Sprintf("%s %s", ps1Prefix, ps1Base))
|
||||
os.Setenv("PATH", "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin")
|
||||
os.Setenv("HISTFILE", "/dev/null")
|
||||
|
||||
var histfile string
|
||||
if v, ok := os.LookupEnv("WW_HISTFILE"); ok {
|
||||
histfile = v
|
||||
} else {
|
||||
histfile = "/dev/null"
|
||||
os.Setenv("WW_HISTFILE", histfile)
|
||||
}
|
||||
os.Setenv("HISTFILE", histfile)
|
||||
|
||||
wwlog.Debug("Exec: %s %s", args[1], args[1:])
|
||||
return syscall.Exec(args[1], args[1:], os.Environ())
|
||||
|
||||
@@ -306,6 +306,16 @@ construct the final ``PS1`` variable for the shell.
|
||||
# env WW_PS1="\u@\h:\w\$ " wwctl image shell rockylinux-9
|
||||
[warewulf:rockylinux-9] root@rocky:/$
|
||||
|
||||
Shell history
|
||||
-------------
|
||||
|
||||
By default, Warewulf image shell sessions don't retain history; but you can
|
||||
specify a history file by specifing ``WW_HISTFILE``. Note that this file is
|
||||
stored within the image; you may want to exclude it when the image is built.
|
||||
(See :ref:`exclude`.)
|
||||
|
||||
.. _exclude:
|
||||
|
||||
Excluding Files from an Image
|
||||
-----------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user