Graphical Shell with ajaxPHPterm

From WebOS Internals
Jump to navigation Jump to search

This article will allow you to use your web browser on your Pre for a terminal using thttp-php and ajaxphpterm. You should have already accessed linux on your Pre and installed an SSH server, and enabled sudo.

1. SSH into your Pre.

2. Install php-thttpd

root@castle:/# /opt/bin/ipkg-opt install php-thttpd

3. Configure php-thttpd

root@castle:/# cat > /opt/etc/thttpd.conf 
dir=/
port=8080
user=root
chroot
nosymlink
novhost
logfile=/opt/var/log/thttpd.log

4. Configure php-thttpd service

root@castle:/# cat > /etc/event.d/optware-thttpd 
description "thttpd Daemon for WebOS"
author "Danny Clark"
version 1.0

# don't start until the WebOS finishes it's normal boot 
# that way no delay is added to the GUI startup
start on stopped finish
stop on runlevel [!2]

# run the daemon
exec /opt/sbin/thttpd -C /opt/etc/thttpd.conf -D
respawn

5. Download and install ajaxPHPterm. Note thttpd requires php files to be mode 644 and executable files to be 755; change permissions where needed after the install.

cd /opt/share/www
wget http://voxel.dl.sourceforge.net/sourceforge/ajaxphpterm/ajaxphpterm.zip
unzip ajaxphpterm.zip
rm ajaxphpterm.zip

6. Restart thttpd-php

/sbin/initctl stop optware-thttpd
/sbin/initctl start optware-thttpd

7. Open up the pre's web browser and go to

http://127.0.0.1:8080/opt/share/www/ajaxphpterm/index.php

This needs verification, and probably more detail in some places (it's working on my device, but text is mostly from IRC conversation).

This is obviously not that secure at all. For one thing, if you change your firewall rules device is wide open. But it's the first way I've found to get access to a local shell that works enough to enter commands and get results (Graphical_Shell_with_WebShell doesn't work for me for some reason).

This procedure, or just rooting your pre and installing stuff, may cause some rooted-pre-issues; read that page to see if those would be acceptable trade-offs to you.

The display size can be made more sensible by adding the following in the head section of index.php:

<meta name="viewport" content="width=device-width" />

Also note that the "cd" command does not work (I think because the shell commands are executed one at a time, eg in separate processes for each command line followed by a return), but you can access and run files in any path - just treat the command line like shell commands in a GNU Make file :-)

Since the shell is so limited and does not support curses / ncurses or any other kind of full screen mode, it's best used just to execute scripts that have been previously created or modified with a text-editor.