Saturday, August 1, 2015

Re: [pcgen] pcgen.sh for v6.05.03 on Linux Mint 17

 

On 08/01/2015 11:47 AM, Darth Borehd darth.borehd@gmail.com [pcgen] wrote:
 
Can you post your script here?
I imagine so.  I haven't done serious script programming in quite some time, and possibly never at this level of complexity, so I don't know what the important differences are.

DS/DL

=================================

#!/bin/sh
cd `dirname $0`

# java.awt.Desktop.browse should be available and setting BROWSER is not needed anymore
if [ "x$BROWSER" = x ]
then
    case "$WINDOWMANAGER" in
        *kde ) BROWSER=kde-open ;;
        *gdm ) BROWSER=gnome-open ;;
        * ) BROWSER=netscape ;;
    esac
fi

available_memory="unknown"
default_min_memory=256
default_max_memory=512

# Linux /proc/meminfo
if [ -e "/proc/meminfo" ]; then
    available_memory=$(grep MemFree: /proc/meminfo | awk '{ print $2; }')
    echo "Available memory: $available_memory kB"

# BSD (thus MacOSX) memory command line should be in /usr/bin/vm_stat
elif [ -x /usr/bin/vm_stat ]; then
    # Mach Virtual Memory Statistics: (page size of 4096 bytes)
    # Pages free:                         713087.
    BLOCK_SIZE=$(vm_stat | grep 'page size of' | cut -d ' ' -f 8);
    FREE_BLOCKS=$(vm_stat | grep 'Pages free' | awk '{ print $3; }' | sed -e 's/\.//');
    FREE_SPACE=$(($FREE_BLOCKS * $BLOCK_SIZE))
    available_memory=$(($FREE_SPACE / 1024))

    echo "Available memory: $available_memory kB"
else
    echo "Could not detect available memory. Will stick to default of $available_memory kB"
fi

# Test if the value is numeric before performing arithmetic on it
if [ $available_memory -eq $available_memory 2> /dev/null ]; then

    # We go with the defaults if memory is too low
    if [ $available_memory -gt 1048576 ]; then
        echo "There is more than 1 GB of free memory available. Will raise memory limits."
        echo "Will take a quarter as low limit and half as upper limit:"
        default_min_memory=$(($available_memory/1024/4))
        default_max_memory=$(($available_memory/1024/2))
    else
        echo "There is less than 1 GB of free memory available. Will keep default memory limits"
    fi

    echo "min: $default_min_memory MB, max: $default_max_memory MB"
fi

# To load all sources takes more than the default 64MB.
javaargs="-Xms${default_min_memory}m -Xmx${default_max_memory}m"
pcgenargs=""
whosearg=java

while [ "x$1" != x ]
do
    case "$1" in
    -h ) cat <<EOM
usage: $0 [java-options] [-- pcgen-options]
    For java options, try 'java -h' and 'java -X -h'.
    Useful java property defines:
        -DBROWSER=/path/to/browser
        -Dpcgen.filter=/path/to/filter.ini
        -Dpcgen.options=/path/to/options.ini
    This script recognizes the BROWSER environment variable.
EOM
        exit 0
        ;;
    -- ) whosearg=pcgen
        ;;
    * ) if [ "$whosearg" = java ]
        then
            javaargs="$javaargs $1"
        else
            pcgenargs="$pcgenargs $1"
        fi
        ;;
    esac
    shift
done

# PCGen related properties:
#
# pcgen.filter  - the full path to the file name containing the filter settings
# pcgen.options - the full path to the file name containing the options
#
# Both of these properties are optional.  Default behaviour is to get the
# files from the "user.dir" directory.
#
# Additional properties:
#     -DBROWSER="$BROWSER"
#     -Dpcgen.filter=/path/to/filter.ini
#     -Dpcgen.options=/path/to/options.ini

exec java -DBROWSER="$BROWSER" $javaargs -jar ./pcgen.jar $pcgenargs

__._,_.___

Posted by: Doug Limmer <adventure@mailworks.org>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (5)
Related Lists
PCGen&#39;s release site: http://pcgen.sourceforge.net
PCGen&#39;s Mailing Lists and Links: http://wiki.pcgen.org/Mailing_Lists_and_PCGen_Links
PCGen&#39;s autobuild: http://www.pcgen.org/autobuilds/
PCGen&#39;s JIRA Tracker: http://jira.pcgen.org

PCGen Forum: http://groups.pcgen.org


PCGen List File Help: http://tech.groups.yahoo.com/group/PCGenListFileHelp/
(for assistance in creating new homebrew or official list files)

PCGen Experimental: http://tech.groups.yahoo.com/group/pcgen_experimental/
(for new official data source development)

.

__,_._,___

No comments:

Post a Comment