dvt_check script to copy /etc and some other interesting directories:#!/bin/sh # cd to sdcard cd /mnt/extsdcard mkdir -p asus_ea800 cd asus_ea800 cp /userStyle.css . cp /wac_tch . mkdir -p bin cp /bin/ts_* bin cp -Ppr /etc etc cp -Ppr /eTablet eTablet mkdir -p sbin cp /sbin/firmware.sh sbin mkdir -p usr/local cp -Ppr /usr/local/eTablet usr/local/eTablet mkdir -p usr/sbin cp /usr/sbin/formatuser.sh usr/sbin cp /usr/sbin/scanuser.sh usr/sbin cp /usr/sbin/sdcoldplugin usr/sbinThe folder
/usr/local/eTablet contains a pretty large file that actually takes a long time to copy (the external card slot seems to have a very slow write speed), but I couldn't find an easy way to exclude just this file so I just let it work for an hour or two.When going through the files, I noticed a script
/etc/udev/scripts/sdautomount.sh. It makes sense that this script is called every time the external SD card is mounted, but lets check just to be sure.hans:~/ea800/files/etc/$ ls udev/rules.d 05-udev-early.rules 11_sd_auto_mount.rules hans:~/ea800/files/etc/$ cat udev/rules.d/11_sd_auto_mount.rules KERNELS=="mmc01",KERNEL=="mss/blk*",SUBSYSTEM=="block",ACTION=="add",RUN+="/etc/udev/scripts/sdautomount.sh %k /mnt/extsdcard" KERNEL=="mss/blk*",SUBSYSTEM=="block",ACTION=="remove",RUN+="/etc/udev/scripts/sdautoumount.sh %k /mnt/extsdcard"
So any time the external SD card is added the script
/etc/udev/scripts/sdautomount.sh is run, with the device path and the mountpoint as arguments. When unmounting, the script /etc/udev/scripts/sdautoumount.sh is run.So my idea was to add a line like
/mnt/extsdcard/my_scriptTo the end of
/etc/udev/scripts/sdautomount.sh so that myscript is run every time an external SD card is inserted. But when I checked the contents of the default script:hans:~/ea800/files/etc/$ cat udev/scripts/sdautomount.sh #!/bin/sh pathName="$1" mountPoint="$2" umount $mountPoint mkdir -p $mountPoint mount -t vfat -o sync,utf8=1 /dev/$pathName $mountPoint $mountPoint/./ASUS_ETABLE_HOPPER_TEST &Notice the last line: the script already tries to run a script on the external SD card called
ASUS_ETABLE_HOPPER_TEST! An engineer at Asus probably added this line to do make testing and, lucky for us, forgot to take it out. So instead of dvt_check I can now name my shell scripts ASUS_ETABLE_HOPPER_TEST and it will run without rebooting. (Note: a quick google search shows I'm not the first one to discover this, but it's still a nice find :P).Shell scripts good, interactive shell better!
With the ability to run scripts as root you can do anything you want in Linux, however it is not necessarily the most efficient way to do things. So next up I tried to get an interactive shell running on the device. Like many other embedded Linux devices, the Eee Note uses BusyBox to provide the common Unix utilities. Luckily BusyBox also a telnet server daemon. So one could use the following
ASUS_ETABLE_HOPPER_TEST script to listen for incoming connections:telnetd &This script has two problems however. Firstly this will cause the shell to execute
/etc/profile, which contains much of the startup functionality of the Eee Note. The result is that when opening a shell, many startup processes get executed again, causing to Eee Note to freak out. So we need to prevent the shell from executing /etc/profile. This is simply done by passing an extra argument to telnetd:telnetd -l /bin/sh &Now the shell will be started as a non-login shell, causing it to skip
/etc/profileThe second problem is that telnetd gets started every time you insert the external SD card. So if we insert, remove it again and insert it a second time, telnetd will run twice. We could use a simple check to detect if telnetd is running already, but a more elegant solution is to start telnetd on startup:
#! /bin/sh if [ -z "`grep telnetd /etc/init.d/rcS`" ] then echo "/usr/sbin/telnetd -l /bin/sh &" >> /etc/init.d/rcS fi
Disclaimer
- Executing this script will modify files on your Eee Note, this may very well void your warranty.
- Execuring the scripts on this blog is AT YOUR OWN RISK, only do it you know what you are doing. I am in no way responsible for any damage done to your Eee Note by executing scripts from this blog, either directly or indirectly.
Security warning
The telnet daemon will listen for incoming connections and will grant root access to anyone that can connect to your Eee Note. This means that it is no longer safe to connect to a wifi access point unless you are absolutely sure that you trust everyone on the network! On public access points and company or university networks this usually means THE WHOLE INTERNET, since every device is assigned a unique ip-address. If use your Eee Note to connect to untrusted networks, use a less permanent way to start the telnet daemon, or use the uninstall script below before connecting.Run this script once and reboot the device to start the Eee Note. You don't need the SD card from this point on :P
Connecting to the Eee Note can be done using either wifi or usb. I recommend usb since it is more secure.
To connect over usb just connect the Eee Note to your Linux PC with the included usb to micro-usb cable (On Windows, putty will probably work, but I have not tested it). Select the 'Eee Note Sync Mode' option on your Eee Note. On you computer, open a terminal and type:
ifconfig usb0 169.254.2.2 telnet 169.254.2.1
The first line creates a usb network interface with ip address 169.254.2.2, you can replace the ip with any address in the 169.254.2.0/8 subnet except 169.254.2.1 (which is the Eee Notes address). You will need root access to do this so use sudo if necessary.
The second line connects to the Eee Note and will give you an interactive shell. Be carefull, you are now root on the Eee Note!
You may need to install telnet using your package manager, most distributions include a package called telnet, Arch Linux bundles telnet in the inetutils package.
Uninstall script
To uninstall this hack run the following two commands on the Eee Note (either from over telnet or using aASUS_ETABLE_HOPPER_TEST script):cat /etc/init.d/rcS | grep -v telnetd > /etc/init.d/rcS2 mv /etc/init.d/rcS2 /etc/init.d/rcS chmod a+x /etc/init.d/rcS
and reboot the Eee Note.