#!/bin/sh ## This script dynamically loads the visor module, uses pilot-xfer to synchronize or install files, and unloads the visor module ## author: Andrew Ittner andrew.ittner@usa.net ## $LastChangedDate: 2008-11-07 11:11:08 -0800 (Fri, 07 Nov 2008) $ ## NOTES: # assumes that the visor module has been blacklisted (/etc/modprobe.d/blacklist) or is NOT IN USE by another program (i.e. VMWare) # see the ## CONSTANTS ## section for what to change for this script # must have one and only one parameter if [ -z $1 ] then echo "proper usage: $0 -i (install) OR -s (sync)" exit 1 fi ## CONSTANTS ## # install: where files to install exist dirinstall=~/dl/palmos/toinstall # backup: where to place backed-up files dirbackup=~/data/t5backup t5install() { # switch extensions to lowercase mmv -r "*.*" "#1.#l2" # check if /dev/ttyUSB# is available ls -lXgohF --color=auto /dev/ttyU* # transfer *.p?? files to T5 pilot-xfer -i $dirinstall/*.p?? # TODO: return pilot-xfer error } t5sync() { # check if /dev/ttyUSB# is available ls -lXgohF --color=auto /dev/ttyU* ## backup T5 to /home/aji/data/t5backup echo "synchronizing T5 to $dirbackup" pilot-xfer -s $dirbackup # TODO: return pilot-xfer error } # get kernel version varuname=$(uname -r) echo "kernel version: $varuname; /lib/modules/$varuname/kernel/etc..." # check if usbserial module loaded lsmod|grep -i 'usbserial' varCheck=$? # if lsmod failed, then must load usbserial module for visor module to work properly (apparently doesn't load it automagically) if [ "$varCheck" -ne 0 ] then echo '-=-WARNING: usbserial module not loaded.-=-' echo '-=-Must be ROOT to insert usbserial module.-=-' sudo insmod /lib/modules/$varuname/kernel/drivers/usb/serial/usbserial.ko # to prevent unknown symbols errors # TODO: check if insmod worked... varresult=$? if [ "$varresult" -ne 0 ] then echo "insmod usbserial failed" else echo "insmod usbserial succeeded" fi fi # check if visor module loaded lsmod|grep -i 'visor' varCheck=$? if [ "$varCheck" -ne 0 ] then echo '-=-WARNING: visor module not loaded.-=-' echo '-=-Must be ROOT to insert visor module.-=-' sudo insmod /lib/modules/$varuname/kernel/drivers/usb/serial/visor.ko # insmod /lib/modules/2.6.12-9-amd64-generic/kernel/drivers/usb/serial/visor.ko # check if insmod worked... varresult=$? if [ "$varresult" -ne 0 ] then echo "insmod visor failed" else echo "insmod visor succeeded" fi fi echo -e "\nStart Hotsync on your PDA" sleep 2s echo -e "Press [enter] when ready" read var1 # sync (backup) or install? varActionParam=$1 case "$varActionParam" in "-i") echo "action: INSTALL" t5install;; "-s") echo "action: SYNC" t5sync;; *) echo "$varActionParam is not supported; exiting" exit 2;; esac varResult=$? echo "Result: $varResult" # remove visor module sudo rmmod visor echo "rmmod visor returned $?" # TODO: ask to remove all *.p?? files from ~/dl/palmos/toinstall/ exit 0