#!/bin/bash # # Copyright (C) 2009 "Cobra" from # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # # Startup-script for josm: # - gets always the newest version of josm-latest.jar # - backs up old versions (useful when the new one doesn't work properly) # - passes all arguments to josm - you can pass files to open with josm, e.g. 'josm trace0*.gpx trace10.gpx' # - sets environment variables, passes correct parameters to java and use alsa instead of oss # # configuration (just below these comments): # - change archive-directory if desired # - adjust number of desired backups # - do you use compiz? Then uncomment that line. # - adjust amount of RAM available to josm # - if you want to change or add some parameters for java look at the last line # # ToDo: # - add possibility to configure a proxy and to select a certain version of java # - add possibility to select an older revision and run it # - detect automatically if compiz is running # - add some help (e.g. via --help) # # where should this script save josm-latest.jar to? dir=~/bin/josm-archive # how many old versions should be backed up? numbackup=3 # fix for use with compiz, uncomment next line if you *do* use compiz #export AWT_TOOLKIT=MToolkit # how many memory should java assign to josm? mem=1024M # if $dir doesn't exist, create it (initial setup): if [ -d $dir ]; then : else mkdir -p $dir; echo "directory $dir does not exist; creating it..." fi cd $dir # get revision number of newest local version: if ls josm-*.jar > /dev/null; then latestlocalrev=`ls josm*.jar | cut -d '-' -f 2 | cut -d '.' -f 1 | grep -v latest | tail -n 1` else latestlocalrev=0 fi # get revision number of backed up versions oldestrev=`ls josm*.jar | cut -d '-' -f 2 | cut -d '.' -f 1 | grep -v latest | head -n 1` # count backed up versions numsaved=`ls josm*.jar | grep -c ''` # get revision number of "latest" latestrev=`wget -qO - http://josm.openstreetmap.de/version | grep latest | cut -d ' ' -f 2` # download current revision of "latest" if newest local revision is older than the current revision of "latest" if [ $latestlocalrev -lt $latestrev ] then echo latest local version is $latestlocalrev, latest available version is $latestrev - starting download... wget -O $dir/josm-$latestrev.jar -N http://josm.openstreetmap.de/download/josm-latest.jar # delete oldest file if enough newer ones are present if [ $numsaved -gt $numbackup ] then rm $dir/josm-$oldestrev.jar fi else echo local version $latestlocalrev is already uptodate fi # start josm: use alsa instead of oss, enable 2D-acceleration, set maximum amount of memory used for josm to 1024MB and pass all arguments to josm: cd $OLDPWD echo starting josm... # aoss java -jar -Xmx$mem -Dsun.java2d.opengl=true $dir/josm-$latestrev.jar $* & java -jar -Xmx$mem $dir/josm-$latestrev.jar $* &