Skip to content

Commit

Permalink
Make gosh default shell
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Koch <[email protected]>
  • Loading branch information
hugelgupf committed Feb 7, 2024
1 parent ec02d47 commit 3ee8b39
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,17 @@ u-root
u-root core boot

# Generate an archive with only these given commands
u-root ./cmds/core/{init,ls,ip,dhclient,wget,cat,elvish}
u-root ./cmds/core/{init,ls,ip,dhclient,wget,cat,gosh}

# Generate an archive with all of the core tools with some exceptions
u-root core -cmds/core/{ls,losetup}

# Generate an archive with a tool outside of u-root
git clone https://github.com/u-root/cpu
u-root ./cmds/core/{init,ls,elvish} ./cpu/cmds/cpud
u-root ./cmds/core/{init,ls,gosh} ./cpu/cmds/cpud

# Generate an archive with a tool outside of u-root, in any PWD
(cd /tmp && GBB_PATH=$UROOT_PATH:$CPU_PATH u-root ./cmds/core/{init,ls,elvish} ./cmds/cpud)
(cd /tmp && GBB_PATH=$UROOT_PATH:$CPU_PATH u-root ./cmds/core/{init,ls,gosh} ./cmds/cpud)
```

The default set of packages included is all packages in
Expand All @@ -100,12 +100,12 @@ checked for existence. For example:
```shell
GBB_PATH=$HOME/u-root:$HOME/u-bmc u-root \
cmds/core/init \
cmds/core/elvish \
cmds/core/gosh \
cmd/socreset

# matches:
# $HOME/u-root/cmds/core/init
# $HOME/u-root/cmds/core/elvish
# $HOME/u-root/cmds/core/gosh
# $HOME/u-bmc/cmd/socreset
```

Expand Down Expand Up @@ -153,7 +153,7 @@ symlink path. **Only `-uinitcmd` accepts command-line arguments, however.** For
example,

```bash
u-root -uinitcmd="echo Go Gopher" ./cmds/core/{init,echo,elvish}
u-root -uinitcmd="echo Go Gopher" ./cmds/core/{init,echo,gosh}

cpio -ivt < /tmp/initramfs.linux_amd64.cpio
# ...
Expand All @@ -178,7 +178,7 @@ Passing command line arguments like above is equivalent to passing the arguments
Additionally, you can pass arguments to uinit via the `uroot.uinitargs` kernel parameters, for example:

```bash
u-root -uinitcmd="echo Gopher" ./cmds/core/{init,echo,elvish}
u-root -uinitcmd="echo Gopher" ./cmds/core/{init,echo,gosh}

cpio -ivt < /tmp/initramfs.linux_amd64.cpio
# ...
Expand All @@ -205,7 +205,7 @@ The command you name must be present in the command set. The following will *not
work*:

```bash
u-root -uinitcmd="echo Go Gopher" ./cmds/core/{init,elvish}
u-root -uinitcmd="echo Go Gopher" ./cmds/core/{init,gosh}
# 2020/04/30 21:05:57 could not create symlink from "bin/uinit" to "echo": command or path "echo" not included in u-root build: specify -uinitcmd="" to ignore this error and build without a uinit
```

Expand All @@ -215,30 +215,30 @@ don't presume to know whether your symlink target is correct or not.
This will build, but not work unless you add a /bin/foobar to the initramfs.

```bash
u-root -uinitcmd="/bin/foobar Go Gopher" ./cmds/core/{init,elvish}
u-root -uinitcmd="/bin/foobar Go Gopher" ./cmds/core/{init,gosh}
```

This will boot the same as the above.

```bash
u-root -uinitcmd="/bin/foobar Go Gopher" -files /bin/echo:bin/foobar -files your-hosts-file:/etc/hosts ./cmds/core/{init,elvish}
u-root -uinitcmd="/bin/foobar Go Gopher" -files /bin/echo:bin/foobar -files your-hosts-file:/etc/hosts ./cmds/core/{init,gosh}
```

The effect of the above command:
* Sets up the uinit command to be /bin/foobar, with 2 arguments: Go Gopher
* Adds /bin/echo as bin/foobar
* Adds your-hosts-file as etc/hosts
* builds in the cmds/core/init, and cmds/core/elvish commands.
* builds in the cmds/core/init, and cmds/core/gosh commands.
The {} are expanded by the shell

This will bypass the regular u-root init and just launch a shell:

```bash
u-root -initcmd=elvish ./cmds/core/{elvish,ls}
u-root -initcmd=gosh ./cmds/core/{gosh,ls}

cpio -ivt < /tmp/initramfs.linux_amd64.cpio
# ...
# lrwxrwxrwx 0 root root 9 Dec 31 1969 init -> bbin/elvish
# lrwxrwxrwx 0 root root 9 Dec 31 1969 init -> bbin/gosh

qemu-system-x86_64 -kernel $KERNEL -initrd /tmp/initramfs.linux_amd64.cpio -nographic -append "console=ttyS0"
# ...
Expand Down
2 changes: 1 addition & 1 deletion cmds/core/sshd/const_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
package main

var (
shells = [...]string{"bash", "zsh", "elvish"}
shells = [...]string{"bash", "zsh", "gosh", "elvish"}
shell = "/bin/sh"
)
2 changes: 1 addition & 1 deletion integration/gotests/gotest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func TestGoTest(t *testing.T) {
vmtest.RunGoTestsInVM(t, pkgs,
vmtest.WithVMOpt(
vmtest.WithMergedInitramfs(uroot.Opts{
DefaultShell: "elvish",
DefaultShell: "gosh",
Commands: uroot.BusyBoxCmds(
"github.com/u-root/u-root/cmds/core/*",
),
Expand Down
6 changes: 3 additions & 3 deletions templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ var templates = map[string][]string{
"github.com/u-root/u-root/cmds/core/dhclient",
"github.com/u-root/u-root/cmds/core/dmesg",
"github.com/u-root/u-root/cmds/core/echo",
"github.com/u-root/u-root/cmds/core/elvish",
"github.com/u-root/u-root/cmds/core/find",
"github.com/u-root/u-root/cmds/core/free",
"github.com/u-root/u-root/cmds/core/gosh",
"github.com/u-root/u-root/cmds/core/gpgv",
"github.com/u-root/u-root/cmds/core/grep",
"github.com/u-root/u-root/cmds/core/gzip",
Expand Down Expand Up @@ -91,8 +91,8 @@ var templates = map[string][]string{
"github.com/u-root/u-root/cmds/core/dhclient",
"github.com/u-root/u-root/cmds/core/dmesg",
"github.com/u-root/u-root/cmds/core/echo",
"github.com/u-root/u-root/cmds/core/elvish",
"github.com/u-root/u-root/cmds/core/free",
"github.com/u-root/u-root/cmds/core/gosh",
"github.com/u-root/u-root/cmds/core/grep",
"github.com/u-root/u-root/cmds/core/init",
"github.com/u-root/u-root/cmds/core/insmod",
Expand Down Expand Up @@ -121,8 +121,8 @@ var templates = map[string][]string{
"github.com/u-root/u-root/cmds/core/dd",
"github.com/u-root/u-root/cmds/core/dhclient",
"github.com/u-root/u-root/cmds/core/dmesg",
"github.com/u-root/u-root/cmds/core/elvish",
"github.com/u-root/u-root/cmds/core/find",
"github.com/u-root/u-root/cmds/core/gosh",
"github.com/u-root/u-root/cmds/core/grep",
"github.com/u-root/u-root/cmds/core/id",
"github.com/u-root/u-root/cmds/core/init",
Expand Down
2 changes: 1 addition & 1 deletion u-root.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func init() {
case "plan9":
sh = ""
default:
sh = "elvish"
sh = "gosh"
}

build = flag.String("build", "gbb", "u-root build format (e.g. bb/gbb or binary).")
Expand Down

0 comments on commit 3ee8b39

Please sign in to comment.