View Single Post
Old 02-24-2012, 01:01 PM   #48
geekmaster
Carpe diem, c'est la vie.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
Sample code

For those curious about the code inside the downloads I provided in the original (first) post in this thread, here it is:

RUNME.sh
Code:
#!/bin/sh
EIPS=/usr/sbin/eips
$EIPS -p
sleep 1
$EIPS 11 18 "                          "
$EIPS 11 19 "   RUNME.sh is running.   "
$EIPS 11 20 "                          "
sleep 3
Notice that "eips -p" displays a pretty pattern on the eInk display.

mntus.params (inside data.tar.gz)
Code:
MNTUS_PART_START=16
MNTUS_PART_OFFSET=8192
MNTUS_FATSIZE=32

## use actual size from fdisk (minus 8KB offset):
let MNTUS_PART_SIZE="`fdisk -l|grep FAT32|awk '{print $4}'`-8"

## if invalid size (normal during main boot),
## then use known size for each serial number:
if [ $MNTUS_PART_SIZE -lt 1000000 ]; then
  SER4=`grep Serial /proc/cpuinfo|cut -b12-15`
  case $SER4 in
  "B004"|"B005"       ) MNTUS_PART_SIZE=3567224 ;; # DX
  "B006"|"B008"|"B00A") MNTUS_PART_SIZE=3205336 ;; # K3
  "B009"              ) MNTUS_PART_SIZE=3510232 ;; # DXG
  "B00E"              ) MNTUS_PART_SIZE=1423352 ;; # K4 (mini)
  "B00F"|"B011"       ) MNTUS_PART_SIZE=3377144 ;; # K5 (touch)
  *)
    ## unknown size, exit may erase USB Drive!
    eips -c
    eips  5 28 "This $SER4 Kindle is not supported..."
    eips 10 30 "(${MNTUS_PART_SIZE}KB USB Drive)"
    eips  7 32 "Removing installer files..."
    sleep 8
    ;;                   
  esac
fi

mount -o rw,noatime,nodiratime,offset=8192 /dev/mmcblk0p4 /mnt/us
[ -f /mnt/us/RUNME.sh -a ! -f /mnt/us/RUNME.done ] && (
  touch /mnt/us/RUNME.done
  sh /mnt/us/RUNME.sh 2>&1 >/mnt/us/RUNME.out
)
umount -d /mnt/us
Notice that the *real* USB drive may not be mounted when this code runs. In fact, when booting from the main system partition, it is probably not detected, or shows up as a 0-byte "fake storage" device (for charging). That is why this script mounts the drive before calling RUNME.sh. Please do NOT modify this script unless you know EXACTLY what you are doing.

Notice also, that one of my "if - then - fi" blocks is missing the "if" and the "then" and the "fi". They are optional. I used them in the first one to make it easier to understand, because it has a case statement inside it.

Also, the "Removing installer files..." message is obsolete. I forgot to delete that line from the script file when I simplified it by using RUNME.done instead.

Although my code starts out large like the startup scripts in the kindles, I like to condense it down to "short and sweet" with white-space only where needed for clarification, as can be seen in the sample scripts above.

UPDATE: This looks like a useful addition to any RUNME.sh code:
https://www.mobileread.com/forums/sho...0&postcount=17


Last edited by geekmaster; 02-24-2012 at 02:03 PM.
geekmaster is offline   Reply With Quote