#!/bin/sh DIR=$(mktemp -d -t pluckerXXXXXX) trap "rm -rf $DIR" 0 2 3 15 FILE="$1" case $FILE in *.zip) BASE=`basename $FILE .zip` unzip -d $DIR -o $FILE ;; *.gpx) BASE=`basename $FILE .gpx` cp $FILE $DIR ;; *) echo "unknown extension" ; exit 1 ;; esac cd $DIR if ! [ -e $BASE.gpx ] ; then echo "$BASE.gpx not found" exit 1 fi NAME="$2" if [ -z "$NAME" ] ; then case $BASE in # extract name from filename *_*) NAME=$(echo "$BASE" | cut -d _ -f 2-) ;; # extract name from end of this script *) NAME=$(grep "^$BASE" $0 | cut -d ' ' -f 2-) ;; esac fi if [ -z "$NAME" ] && [ -t 1 ] ; then # ask for name and save it read -p "Enter name for $BASE: " NAME [ "$NAME" ] && echo "$BASE $NAME" >> $0 fi if [ -z "$NAME" ] ; then # use base as name NAME="$BASE" fi if [ "$NAME" != "$BASE" ] ; then for f in $BASE* ; do ln "$f" "$(echo $f | sed -e "s/^$BASE/$NAME/")" done fi to_e61 () { test -d /media/e61 || pmount /dev/disk/by-uuid/1AFF-7785 e61 cp -av "$NAME.gpx" /media/e61/gpx pumount e61 } to_html () { gpsbabel -c utf-8 -i gpx -f $BASE.gpx -o html,logs -F $BASE-utf8.html iconv -c -f utf8 -t latin1 $BASE-utf8.html > $HOME/$BASE.html || : } to_plucker () { gpsbabel -c utf-8 -i gpx -f $BASE.gpx -o html,logs -F $BASE-utf8.html iconv -c -f utf8 -t latin1 $BASE-utf8.html > $BASE.html || : # --url-pattern=$BASE.html --stayondomain plucker-build \ --doc-name="$NAME" --category="Geocaching" \ --charset=utf-8 \ --bpp=16 --maxwidth=160 --maxheight=160 --alt-maxwidth=320 --alt-maxheight=320 \ --maxdepth=1 \ --doc-file=$PWD/$BASE --home-url=$PWD/$BASE.html ls -lh $BASE.pdb pilot-xfer -D/PALM/programs/Plucker/$BASE.pdb -i $BASE.pdb } to_viking () { viking.sh $BASE*.gpx } to_gps () { lsmod | grep -q garmin || sudo modprobe garmin_gps gpsbabel -i gpx -f $BASE.gpx -f $BASE-wpts.gpx -o garmin -F /dev/ttyUSB0 } to_gpx () { cp -av "$NAME"*.gpx $HOME/projects/geocaching/gpx } to_db () { rsync -Pavz "$NAME"*.gpx kepler.df7cb.de:projects/geocaching/gcdb/gpx ssh kepler.df7cb.de projects/geocaching/gcdb/gc.pl projects/geocaching/gcdb/gpx/"$NAME"*.gpx } if test -t 1 ; then while true ; do echo "\033[1m$BASE: $NAME\033[0m" read -p 'Open with (e)61 (h)tml (p)lucker (v)iking (g)ps gp(x) gc(d)b (q)uit? ' answer case $answer in e) to_e61 ;; h) to_html ;; p) to_plucker ;; v) to_viking ;; g) to_gps ;; x) to_gpx ;; d) to_db ;; q) exit 0 ;; *) echo "huh?" ;; esac done else to_viking fi exit 0 __DATA__ 1948630 Gefunden_von_Myon 2296729 Blieskastel 2620316 Krefeld 2740763 Duisburg 2428267 Koeln 1948628 Moenchengladbach