[webshell] Command line access from web browser

af123

Administrator
Staff member
Here's a new package that gives you command line access to your Humax from a web browser as an alternative to using telnet. Once installed, it's accessed via the Diagnostics menu using the icon that will appear at the bottom right. It even works in maintenance mode (although there is no menu bar at the top then) and I've successfully used it to run a disk check.

I've had this running on my box for 6 months or so without problems but one of the people testing it on their box has reported that it does strange things in Safari with old versions of IOS (fine with IOS 9 though). Thanks to Black Hole for testing this over the past few months and prompting me to finish it!

Restart required following installation.

upload_2016-2-8_12-48-16.png
 
Last edited:
Very nice... but I need a major edit of my standard references now! This will make it much easier for network novices to access the command line.
 
I tried installing it from the WebIf and up popped a box that said "Internal server error".
Installed OK from the command line.
(Your image is broken as well in post #1)
 
Last edited:
It even works in maintenance mode (although there is no menu bar at the top then) and I've successfully used it to run a disk check.
How? All I can get is a minimal page saying the system is in maintenance mode.

Is there a chicken and egg situation here? To run in maintenance mode, presumably the support system has to be in Flash. Fair enough. If the idea is to make it easy for novices to run disk repair, they will need to be instructed to install CF and then webshell, but assuming the disk has gone read-only this will require the command line to achieve in the first place - so the novice will have to be instructed on obtaining the command line via Telnet anyway.

Maybe there's not much rewriting for me to do after all.

Regardless, for other purposes it's a lot more convenient than breaking out a Telnet session.

(Using iOS7 on an iPad 3, in the early development there were no line feeds in the terminal emulator. The release version won't do lower case input - everything comes out upper case, so it is impossible to type "cli"! I have since updated to iOS9 - which was pretty painless for a change - and it works fine.)
 
Aha! I think af123 has tried to re-use an image upload from a conversation I am party to - which is why I can see it but nobody else (except him of course).

He needs to upload the image to the topic post separately!

PS: as I was a beta tester, I loaded webshell by command line.
 
Is there a chicken and egg situation here? To run in maintenance mode, presumably the support system has to be in Flash. Fair enough. If the idea is to make it easy for novices to run disk repair, they will need to be instructed to install CF and then webshell, but assuming the disk has gone read-only this will require the command line to achieve in the first place - so the novice will have to be instructed on obtaining the command line via Telnet anyway.
Yes there is. For someone installing the CFW in order to repair their disk they will have to use telnet as they will be unable to install the webshell package or any of the things on which it depends. It does install to flash but I'm reluctant to embed it in the firmware update file itself.
 
My prompt comes out as:
\[\033[01;32m\]\h\[\033[01;34m\] \w \# \[\033[00m\]
It definitely supports colour and emulates a VT100 terminal. I'm surprised those colour codes don't work as colour in general does (vim syntax highlighting, ls --colour for example).
It also doesn't respect the expert Telnet setting and forces you through the tmenu stuff.
I don't intend to use that setting for this - I imagine that expert users aren't likely to use it in preference to real telnet/ssh anyway.
 
Yes there is. For someone installing the CFW in order to repair their disk they will have to use telnet as they will be unable to install the webshell package or any of the things on which it depends. It does install to flash but I'm reluctant to embed it in the firmware update file itself.
Fine. So how did you manage to run it in maintenance mode?
 
Fine. So how did you manage to run it in maintenance mode?
As long as it is installed before you go into maintenance mode the web shell will work.. not with the current test version of CFW 3.10 though as the built-in page supersedes it.
 
It definitely supports colour and emulates a VT100 terminal. I'm surprised those colour codes don't work as colour in general does (vim syntax highlighting, ls --colour for example).
I added a third clause to the test in the script in /mod/etc/profile/ so it now reads:
Code:
if [ "$0" = '-sh' -o "$0" = '-/bin/sh' -o "$0" = '/bin/sh' ]; then
Is there a more elegant way to do this?

And can the colour be user tweaked to white on black instead of the other way round?
I don't intend to use that setting for this - I imagine that expert users aren't likely to use it in preference to real telnet/ssh anyway.
Whatever, but can you strike the 'stupid' message then which tells you otherwise:
Code:
...
srma - Set return-to-manufacturer (RMA) mode.                                                                        
diag - Run a diagnostic.                                                                                              
  cli - System command line (advanced users).                                                                          
                                                                                                                      
Please select option: cli                                                                                              
                                                                                                                      
-----------------------------------------------------------------------                                                
Now starting a system command prompt. You can make this the default by                                                
enabling 'Expert mode telnet server' on the web interface settings page.                                              
-----------------------------------------------------------------------                                                
                                                                                                                      
Humax HDR-Fox T2 (humax) 1.03.12/3.03                                                                                
                                                                                                                      
To return to the menu, type: exit                                                                                      
                                                                                                                      
humax ~ #
 
I added a third clause to the test in the script in /mod/etc/profile/ so it now reads:
Code:
if [ "$0" = '-sh' -o "$0" = '-/bin/sh' -o "$0" = '/bin/sh' ]; then
Is there a more elegant way to do this?
Ah, I remember this now, you have a custom profile script to launch the /mod version of the shell with more capabilities.

I suppose this would be more elegant:

Code:
if [ "`echo $0 | cut -d/ -f4`" = busybox ]; then
        export HOME=/mod
        export PS1="\[\033[01;32m\]\h\[\033[01;34m\] \w \# \[\033[00m\]"
else
        [ -x /mod/bin/busybox/sh ] && exec /mod/bin/busybox/sh -l
fi
 
And can the colour be user tweaked to white on black instead of the other way round?

Yes, drop this into /mod/webif/plugin/webshell/vt100.css

Code:
#vt100 #scrollable { background-color: black; }
#vt100 .ansiDef { color: white; }
#vt100 .bgAnsiDef { background-color: black; }
#vt100 #scrollable.inverted .ansiDef { color: black; }
#vt100 #scrollable.inverted .bgAnsiDef { background-color: white; }

and change the startup script (/mod/etc/init.d/S85webshell) to include the --css option (which will be there by default in the next version along with an example style sheet that won't be overwritten on updates)

Code:
case "$1" in
        start)
                /mod/boot/2/webshell/shellinaboxd -t \
                    --css=/mod/webif/plugin/webshell/vt100.css \
                    --unixdomain-only=/tmp/.shellbox.sock:root:root:755 \
                    -s /cli/menu:root:root:/:/bin/tmenu &
 
Back
Top