Gwd-start

From GeneWeb
Jump to: navigation, search
#!/bin/sh

# Directory where to store GeneWeb base
BASE_DIR="$HOME/Genealogy/GeneWeb-Bases"

# Directory where to store GeneWeb distributions 
VERS="GeneWeb-7.00-Mac"
BIN_DIR="$HOME/Genealogy/GeneWeb"

# Name of the base to open at start-up
DEFAULTBASE="basename"
# Language to use (de/en/es/fr/it/lv/sv) 
# if not in the list will be en
LANG=fr

# Shutdown daemon already running
killall gwd
killall gwsetup
killall gwstp

# Verify language
case "$LANG" in
  de*) LANG=de;;
  es*) LANG=es;;
  fr*) LANG=fr;;
  it*) LANG=it;;
  lv*) LANG=lv;;
  sv*) LANG=sv;;
  *) LANG=en;;
esac
DIR="$(dirname "$0")"
cd "$DIR"
export LANG

echo "Testing Bin Dir"
if [ -d $BIN_DIR ]; then
	echo "Bin Dir OK"
else
	echo
	if test "$LANG" = "fr"; then
 		echo "BIN_DIR n'existe pas"
	else
  		echo "BIN_DIR does not exist"
	fi
  	exit
fi

echo "Testing Base Dir"
if [ -d $BASE_DIR ]; then
	echo "Base Dir OK"
else
	echo
	if test "$LANG" = "fr"; then
 		echo "BASE_DIR n'existe pas"
	else
  		echo "BASE_DIR does not exist"
	fi
  	exit
fi

cd "$BASE_DIR"
if [ -f gwd.log ]; then
  mv gwd.log gwd.log.old
fi

# Starting gwsetup
if test "$LANG" = "fr"; then
  echo "Demarrage de gwsetup..."
else
  echo Starting gwsetup...
fi
"$BIN_DIR/$VERS/gw/gwsetup" -gd "$BIN_DIR/$VERS/gw" -lang $LANG > "$BIN_DIR/$VERS/gw/gwsetup.log" 2>&1 &
if test "`ps auw | grep gwsetup | wc -l`" -ne 2; then
  if test "$LANG" = "fr"; then echo Echec gwsetup; else echo Failed gwsetup; fi
  cat
  exit 1
fi

# Starting gwd
if test "$LANG" = "fr"; then
  echo "Demarrage de gwd..."
else
  echo "Starting gwd..."
fi
"$BIN_DIR/$VERS/gw/gwd" -allowed_tags "$BASE_DIR/tags.txt" -hd "$BIN_DIR/$VERS/gw" -bd "$BASE_DIR" -robot_xcl 1000,1 > "$BIN_DIR/$VERS/gw/gwd.log" 2>&1 &
if test "`ps auw | grep gwd | wc -l`" -ne 2; then
  if test "$LANG" = "fr"; then echo Echec gwd; else echo Failed gwd; fi
  cat
  exit 1
fi

# Updating nldb
if test "$LANG" = "fr"; then
  echo "Demarrage de update_nldb ..."
else
  echo "Starting update_nldb ..."
fi
# you may want to insert here appropriate lines according to your existing bases
#echo "Base $DEFAULTBASE"
#./update_nldb $BASE_DIR/$DEFAULTBASE.gwb

if test "$LANG" = "fr"; then
  echo "Gardez cette fenêtre ouverte tant que"
  echo "vous voulez utiliser GeneWeb dans votre"
  echo "navigateur"
else
  echo "Keep this window open while you"
  echo "are using GeneWeb on your browser"
fi

sleep 2

# Open the starting page
open "$BIN_DIR/$VERS/START.htm"