1#!/bin/sh 2cd `dirname $0` 3 4# java.awt.Desktop.browse should be available and setting BROWSER is not needed anymore 5if [ "x$BROWSER" = x ] 6then 7 case "$WINDOWMANAGER" in 8 *kde ) BROWSER=kde-open ;; 9 *gdm ) BROWSER=gnome-open ;; 10 * ) BROWSER=netscape ;; 11 esac 12fi 13 14available_memory="unknown" 15default_min_memory=256 16default_max_memory=512 17 18# Linux /proc/meminfo 19if [ -e "/proc/meminfo" ]; then 20 available_memory=$(grep MemFree: /proc/meminfo | awk '{ print $2; }') 21 echo "Available memory: $available_memory kB" 22 23# BSD (thus MacOSX) memory command line should be in /usr/bin/vm_stat 24elif [ -x /usr/bin/vm_stat ]; then 25 # Mach Virtual Memory Statistics: (page size of 4096 bytes) 26 # Pages free: 713087. 27 BLOCK_SIZE=$(vm_stat | grep 'page size of' | cut -d ' ' -f 8); 28 FREE_BLOCKS=$(vm_stat | grep 'Pages free' | awk '{ print $3; }' | sed -e 's/\.//'); 29 FREE_SPACE=$(($FREE_BLOCKS * $BLOCK_SIZE)) 30 available_memory=$(($FREE_SPACE / 1024)) 31 32 echo "Available memory: $available_memory kB" 33else 34 echo "Could not detect available memory. Will stick to default of $available_memory kB" 35fi 36 37# Test if the value is numeric before performing arithmetic on it 38if [ $available_memory -eq $available_memory 2> /dev/null ]; then 39 40 # We go with the defaults if memory is too low 41 if [ $available_memory -gt 1048576 ]; then 42 echo "There is more than 1 GB of free memory available. Will raise memory limits." 43 echo "Will take a quarter as low limit and half as upper limit:" 44 default_min_memory=$(($available_memory/1024/4)) 45 default_max_memory=$(($available_memory/1024/2)) 46 else 47 echo "There is less than 1 GB of free memory available. Will keep default memory limits" 48 fi 49 50 echo "min: $default_min_memory MB, max: $default_max_memory MB" 51fi 52 53# To load all sources takes more than the default 64MB. 54javaargs="-Xms${default_min_memory}m -Xmx${default_max_memory}m" 55pcgenargs="" 56whosearg=java 57 58while [ "x$1" != x ] 59do 60 case "$1" in 61 -h ) cat <<EOM 62usage: $0 [java-options] [-- pcgen-options] 63 For java options, try 'java -h' and 'java -X -h'. 64 Useful java property defines: 65 -DBROWSER=/path/to/browser 66 -Dpcgen.filter=/path/to/filter.ini 67 -Dpcgen.options=/path/to/options.ini 68 This script recognizes the BROWSER environment variable. 69EOM 70 exit 0 71 ;; 72 -- ) whosearg=pcgen 73 ;; 74 * ) if [ "$whosearg" = java ] 75 then 76 javaargs="$javaargs $1" 77 else 78 pcgenargs="$pcgenargs $1" 79 fi 80 ;; 81 esac 82 shift 83done 84 85# PCGen related properties: 86# 87# pcgen.filter - the full path to the file name containing the filter settings 88# pcgen.options - the full path to the file name containing the options 89# 90# Both of these properties are optional. Default behaviour is to get the 91# files from the "user.dir" directory. 92# 93# Additional properties: 94# -DBROWSER="$BROWSER" 95# -Dpcgen.filter=/path/to/filter.ini 96# -Dpcgen.options=/path/to/options.ini 97 98exec java -DBROWSER="$BROWSER" $javaargs -jar ./pcgen.jar $pcgenargs 99