Scripts for the Zaurus


Setup your shell environment:
.bash_profile
. ./.bashrc
[ $TERM == Eterm ] && TERM=xterm
set -o vi

.bashrc
HISTFILE=/home/root/.bash_history
HOME=/home/root
QTDIR=/home/QtPalmtop
QPEDIR=/home/QtPalmtop
PATH=$QPEDIR/bin:/root/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:.
LD_LIBRARY_PATH=$QTDIR/lib:/usr/local/lib
LOGNAME=unknown
OPERA_DIR=$QPEDIR/opera
TZ=CST6CDT
export http_proxy=http://quickening:3128
export HISTFILE HOME QTDIR QPEDIR PATH LD_LIBRARY_PATH PS1 OPERA_DIR TZ
# assuming all applications installed to SD/CF are linked correctly
if [ -d /mnt/cf/opt/QtPalmtop/bin ]; then
        PATH=$PATH:/mnt/cf/opt/QtPalmtop/bin
        LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/mnt/cf/opt/QtPalmtop/lib
fi
if [ -d /mnt/card/usr ]; then
        PATH=$PATH:/mnt/card/usr/bin:/mnt/card/bin
        LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/mnt/card/usr/lib
fi
alias which="type -path"
alias ll="ls -AFl"
new()
  { ls -AFlt $*|more; }
pc()
  { tar -zxOf $1 -K $2|more; }
pv()
  { tar -ztf $1|more; }
px()
  { tar -zxvf $1; }
where()
  { cd; grep -i "$1" RAM SD CF; cd - >/dev/null; }
iv()
  { tar -zOxf $1 ./data.tar.gz|tar -ztvf -;}
lsm()
  { cat /var/log/messages; }  
service()
  { /etc/rc.d/init.d/$1 $2 ;}
PS1='\[\033[1;31m\h:\w\$ \[\033[1;39m '
PS2='\[\033[1;31mmore> \[\033[1;39m '
PS4="+"

Looking at ipk's. 
Original:
list the file contents: tar -zOxf $* ./data.tar.gz  | tar -ztvf -
list all info about the contents:
SIZE="Size: `ls -l $1 | awk '{print $5}'`"
MD5="MD5Sum: `md5sum $1 | cut -d' ' -f1`"
tar -zOxf $* ./control.tar.gz  | tar -zOxf - ./control | sed "/Description: /i\\
$SIZE
"|sed "/Description: /i\\
$MD5
"
if tar -zxOf $1 ./control.tar.gz  | tar -ztf - | grep -q preinst ; then
        echo "preinst() {"
        tar -zxOf $1 ./control.tar.gz  | tar -zxOf - ./preinst
        echo "}"
fi
if tar -zxOf $1 ./control.tar.gz  | tar -ztf - | grep -q postinst ; then
        echo "postinst() {"
        tar -zxOf $1 ./control.tar.gz  | tar -zxOf - ./postinst
        echo "}"
fi
if tar -zxOf $1 ./control.tar.gz  | tar -ztf - | grep -q prerm ; then
        echo "prerm() {"
        tar -zxOf $1 ./control.tar.gz  | tar -zxOf - ./prerm
        echo "}"
fi

Opie:
list the file contents: busybox ar -p $1 control.tar.gz | tar -zxOf -      (note: need busybox 0.60+)
list all info about the ipk: busybox ar -p $1 control.tar.gz | tar -zxOf -

How to play a movie from a Minolta DiMAGE-X:

nice -20 /usr/local/bin/mplayer -cache 8192 -v -benchmark -fs -framedrop -af resample=8000  $*

or regular movies with mplayer:

nice -20 /usr/local/bin/mplayer -cache 8192 -quiet  -fs -framedrop $@ >/dev/null 2>&1

note: mplayer can also stream from urls!

How to add more memory using swap:

dd if=/dev/zero of=/home/root/SwapFile bs=1024 count=8192
mkswap /home/root/SwapFile
swapon /home/root/SwapFile
echo "8 MB swap active."

A substitute locate command.  Remember it is only searching thru ram!

# if lower case, search on strings case insensitive
pat() { echo $1| tr 'a-z' 'A-Z'; }
spat() { echo "[$1`pat $1`]"; }
searchpattern() { for i in `echo $1| sed 's/./& /g'`; do echo -e "`spat $i`\c";done ; }
P=`searchpattern $1`
find / -follow -name \*$P\* 2>/dev/null

My rsync script.  "quicker" is the host mirror.

# synchronize Z to quicker target
# -a = archive
# -v = verbose
# -x = stay in one filesystem
# -e ssh uses ssh instead of rsh
# --exclude excludes paths matching regex
# /home/ copies directory contents to /z
rsync -avxe ssh --exclude='var/*' --exclude='system/*' --exclude='tmp/*' --exclude=/home/swapfile /home/ quicker:/z

Enable a development environment with dev_img:

put this in /etc/fstab:
/mnt/card/dev_img-1.3   /home/userdata/dev      cramfs  rw,loop,noauto  0  0

put this in "develop" script:
mount /home/userdata/dev
MACHTYPE=arm-unknown-linux-gnu
OSTYPE=linux-gnu
PATH=$PATH:/home/userdata/dev/bin
LD_LIBRARY_PATH=/home/userdata/dev/lib:$LD_LIBRARY_PATH

I had to write my own auto-connect script for ethernet over usb on Redhat (handles multiple hosts):

. /etc/hotplug/usbdnet.conf
. /etc/hotplug/usbd.func
route_add() {
        route add -host $GW usbd0
        route delete -net 192.168.129.0/24 usbd0
        route add default gw $GW
}
fix_resolv() {
        if arp -a | grep -q DA:4D:3A:9D:4C:06 ; then
                cp /etc/resolv.home /etc/resolv.conf
        else
                cp /etc/resolv.usbdnet /etc/resolv.conf
        fi
}
restore_resolv() {
        cp /etc/resolv.eth0 /etc/resolv.conf
}

case $1 in
up)
        echo enabling usb0 on `date` >/tmp/usb.log
        usbd_net_if_up >>/tmp/usb.log 2>&1
        route_add >>/tmp/usb.log 2>&1
        fix_resolv && echo resolv.conf fixed >> /tmp/usb.log
        ;;
down)
        usbd_net_if_down
        restore_resolv
        ;;
*)
        exit 1
        ;;
esac


A bunch more scripts here