Automatically run `shell` command when opening crosh ( CTRL + ATL + T )

1,923 views
Skip to first unread message

Romuald Brillout

unread,
Oct 13, 2014, 3:37:37 PM10/13/14
to chromium-...@chromium.org
I extensively use a chroot with crosh.
I therefore keep typing "shell<enter>" throughout the day.

I'd like to automate that and make it that when I open a crosh it automatically runs the `shell` command.
I've been looking for a script that get's executed when a crosh opens but without luck.

Any help would be greatly appreciated

Mike Frysinger

unread,
Oct 13, 2014, 3:43:25 PM10/13/14
to rom...@gmail.com, Chromium OS discuss
by design, crosh does not allow customization like this.  if you've modified the rootfs, then you could simply change the crosh script itself -- load up /usr/bin/crosh.  you could also do a hack like:
 - cp /usr/bin/crosh /usr/local/bin/
 - edit /usr/local/bin/crosh to do what you want
 - mount --bind /usr/local/bin/crosh /usr/bin/crosh

that mount command will get reset next time you reboot, but you'd only have to run it once, and you could automate it a bit by putting a check in your ~/.bash_profile ... that way the first time you have to type "shell", but subsequent ones you wouldn't have to.

also note that there's tab completion, so typing "sh<tab><enter>" is only 4 keystrokes ;).
-mike

--
--
Chromium OS discuss mailing list: chromium-...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-os-discuss?hl=en


Romuald Brillout

unread,
Oct 13, 2014, 5:20:36 PM10/13/14
to chromium-...@chromium.org, rom...@gmail.com
changing /usr/bin/crosh did the trick.
Awesome! thanks.

To not make this only a thank post and for future readers;

 - I added `cmd_shell` right before the `repl` call in `/usr/bin/crosh`
 - to make `/usr/bin/crosh` writable;
   - $ sudo /usr/share/vboot/bin/make_dev_ssd.sh --remove_rootfs_verification #eventually add --partitions n
   - reboot
   - $ sudo crossystem dev_boot_signed_only=0
   - $ sudo mount -o remount,rw /

DennisLfromGA

unread,
Oct 14, 2014, 12:19:42 PM10/14/14
to chromium-...@chromium.org, rom...@gmail.com
Sorry if the answers to these questions are self-evident but - 
  • Is 'cmd_shell' a function you added to 'crosh'?
  • If so, what is it?
I've done a little work in this area to kick-off a 'crouton' chroot.
If you're interested, you can check it out here - Autostart crouton chroot at ChromeOS startup

Thanx,
-DennisL

DennisLfromGA

unread,
Oct 16, 2014, 11:33:51 AM10/16/14
to chromium-...@chromium.org, rom...@gmail.com
Nevermind, found it in 'crosh-dev'...
Reply all
Reply to author
Forward
0 new messages