#!/bin/bash

#==================================================
# This shell script is intended to be placed in
# /usr/bin/ and should be run to start a GNUmed
# client.
#
# $Source: /sources/gnumed/gnumed/gnumed/dists/Linux/gnumed,v $
# $Id: gnumed,v 1.22.2.1 2009/03/28 14:43:17 ncq Exp $
# license: GPL
# Karsten Hilbert, Sebastian Hilbert, Andreas Tille
#--------------------------------------------------

# for debugging this script
# set -x

OPTIONS=$@


# The system-wide configuration file for backend profiles.
SYSCONF="/etc/gnumed/gnumed-client.conf"
if [ ! -e ${SYSCONF} ] ; then
	echo "Global config file ${SYSCONF} missing."
	exit 1
fi


# source systemwide startup extension shell script if it exists
if [ -r /etc/gnumed/gnumed-startup-local.sh ] ; then
	. /etc/gnumed/gnumed-startup-local.sh
fi


# source local startup extension shell script if it exists
if [ -r ${HOME}/.gnumed/scripts/gnumed-startup-local.sh ] ; then
	. ${HOME}/.gnumed/scripts/gnumed-startup-local.sh
fi


# packages which install the GNUmed python modules into a path not
# already accessible for imports via sys.path (say, /usr/share/gnumed/)
# may need to adjust PYTHONPATH appropriately here
#export PYTHONPATH="${PYTHONPATH}:/usr/share/gnumed/"


# now run the client
python -m Gnumed.wxpython.gnumed ${OPTIONS}

# sync the discs just in case
sync

#==================================================
# $Log: gnumed,v $
# Revision 1.22.2.1  2009/03/28 14:43:17  ncq
# - add example on how to adjust PYTHONPATH and when it is needed
#
# Revision 1.22  2009/02/20 15:43:56  ncq
# - cleanup
#
# Revision 1.21  2009/02/20 10:45:44  ncq
# - get rid of all the gnumed.py detection logic by
#   using python -m as suggested by Josselin Mouette
# - also, no more "gnumed-debug" and no more CONFFILE_ARG
#
# Revision 1.20  2008/12/12 16:37:02  ncq
# - sync discs after running gnumed client just in case
#
# Revision 1.19  2008/10/22 12:24:27  ncq
# - no more checking for --conf-file, now done in gnumed.py
#
# Revision 1.18  2008/08/31 18:05:41  ncq
# - no more CONFFILE checking as that's done by GNUmed proper now
#
# Revision 1.17  2008/08/31 14:49:26  ncq
# - disambiguate CONFFILE
#
# Revision 1.16  2008/08/31 14:37:49  ncq
# - fix looping over gnumed.py path candidates
#
# Revision 1.15  2008/08/29 20:55:18  ncq
# - actually act on not finding gnumed.py
#
# Revision 1.14  2008/08/01 10:32:41  ncq
# - /bin/sh -> /bin/bash
#
# Revision 1.13  2008/07/22 13:55:58  ncq
# - better way of finding gnumed.py as suggested by Ruthard Baudach
#
# Revision 1.12  2008/03/29 16:23:11  ncq
# - whitespace fix
#
# Revision 1.11  2008/02/25 17:44:55  ncq
# - cleanup
# - support a few pathes for gnumed.py, included from downstream packages
#
# Revision 1.10  2008/01/01 13:53:35  ncq
# - should not need touching user config file anymore
#
# Revision 1.9  2007/09/24 18:37:45  ncq
# - fix startup script directory error as noticed by Andreas
#
# Revision 1.8  2007/05/22 13:49:52  ncq
# - exit with 1 when something goes wrong
#
# Revision 1.7  2007/04/27 13:30:07  ncq
# - better location for user-local shell include
#
# Revision 1.6  2007/04/05 17:21:18  ncq
# - pull in some logic from Debian startup script
# - cleanup for system-wide config file
#
# Revision 1.5  2007/03/26 17:18:04  ncq
# - no more --unicode-gettext
# - no more copying /etc/gnumed/gnumed.conf
#
# Revision 1.4  2005/07/11 16:55:27  ncq
# - allow systemwide startup extension shell script, too
#
# Revision 1.3  2005/07/11 16:53:03  ncq
# - include user-local startup shell script
# - use cp -R
#
# Revision 1.2  2005/07/11 16:46:41  ncq
# - make more dumb but more robust
#
