=================================================================== RCS file: /cvs/palm/manage_pre/manage_pre,v retrieving revision 1.1 retrieving revision 1.4 diff -u -r1.1 -r1.4 --- palm/manage_pre/manage_pre 2009/08/12 19:13:52 1.1 +++ palm/manage_pre/manage_pre 2009/08/20 22:40:49 1.4 @@ -1,10 +1,12 @@ #!/bin/sh -# $Id: manage_pre,v 1.1 2009/08/12 18:13:52 andrew Exp $ +# $Id: manage_pre,v 1.4 2009/08/20 21:40:49 andrew Exp $ -local _pre_label='Pre' -local _ipod_label='iPod' +local _pre_id='Palm, Pre, 0316' +#local _pre_label='Pre' +#local _ipod_label='iPod' local _mount_dir='/mnt/pre' local _name=`basename $0` +local _unison_config='vogonpa' local _action="$*" case "$_name" in @@ -31,9 +33,9 @@ exit 1 fi - local _label=`disklabel ${_dev} 2>/dev/null | awk '/^label:/ { print $2 }'` - if [ X"$_label" != X"$_pre_label" -a X"$_label" != X"$_ipod_label" ]; then - echo "Pre not labeled properly [$_label]" >&2 + local _id=`dmesg | grep "^$_dev at " | tail -1 | sed -e 's/.*.*$//'` + if [ X"$_id" != X"$_pre_id" ]; then + echo "Pre [$_dev] not correct id [$_id]" >&2 exit 2 fi @@ -48,12 +50,12 @@ local _mounted=`is_mounted $_dev` if [ X"" != X"$_mounted" ]; then /bin/sync - /sbin/umount $_dev && echo Unmounted Pre + $SUDO /sbin/umount $_dev && echo Unmounted Pre else echo Not mounted fi - /bin/eject $_dev 2> /dev/null && echo Ejected Pre - rmdir $_mount_dir 2> /dev/null + $SUDO /bin/eject $_dev 2> /dev/null && echo Ejected Pre + $SUDO rmdir $_mount_dir 2> /dev/null } mount() { @@ -62,10 +64,10 @@ echo Already mounted: ${_mounted%% type*} return fi - mkdir -p $_mount_dir - chgrp users $_mount_dir - chmod g+w $_mount_dir - /sbin/mount $_dev $_mount_dir && echo Mounted Pre on $_mount_dir + $SUDO mkdir -p $_mount_dir + $SUDO chgrp users $_mount_dir + $SUDO chmod g+w $_mount_dir + $SUDO /sbin/mount $_dev $_mount_dir && echo Mounted Pre on $_mount_dir } synchronize() { @@ -75,15 +77,16 @@ return 1 fi - echo Would have syncd + echo Synchronizing Pre #if [ -e /usr/local/bin/rsync ]; then #rsync -rv --delete --size-only --exclude '*.pid' \ #.backgrounds/vogonpa/ /mnt/pre/wallpapers_mine/ #fi - #if [ -e /usr/local/bin/unison ]; then - #/usr/local/bin/unison voganpa - #fi + + if [ -e /usr/local/bin/unison ]; then + /usr/local/bin/unison $_unison_config -auto -batch -ui text + fi } local _dev=`find_pre`