From 9f49fc9823b09cac1931b5e459b606398eacde32 Mon Sep 17 00:00:00 2001
From: tjc <tjc@ee4ac58c-ac51-4696-9907-e4b3aa274f04>
Date: Thu, 2 Jul 2009 14:49:43 +0000
Subject: [PATCH] fix so this can be run from other directories

git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@11290 ee4ac58c-ac51-4696-9907-e4b3aa274f04
---
 etc/writedb_entry | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/etc/writedb_entry b/etc/writedb_entry
index 36d83f3ba..2f9dde739 100755
--- a/etc/writedb_entry
+++ b/etc/writedb_entry
@@ -6,10 +6,26 @@
 # writedb_entry -s Pf3D7_01 Pf3D7_05 Pf3D7_07
 #
 
-if [ -z "$ARTEMIS_HOME" ]; then
-  PRG=`readlink -f "$0"`
-  ARTEMIS_HOME=`dirname "$PRG"`/..
-fi
+#if [ -z "$ARTEMIS_HOME" ]; then
+#  PRG=`readlink -f "$0"`
+#  echo $PRG
+#  ARTEMIS_HOME=`dirname "$PRG"`/..
+#fi
+
+PRG=$0
+progname=`basename $0`
+
+while [ -h "$PRG" ] ; do
+  ls=`ls -ld "$PRG"`
+  link=`expr "$ls" : '.*-> \(.*\)$'`
+  if expr "$link" : '.*/.*' > /dev/null; then
+    PRG="$link"
+  else
+    PRG="`dirname $PRG`/$link"
+  fi
+done
+
+ARTEMIS_HOME=`dirname "$PRG"`/..
 
 CLASSPATH="$ARTEMIS_HOME:$ARTEMIS_HOME/lib/biojava.jar:$ARTEMIS_HOME/lib/jemAlign.jar:$ARTEMIS_HOME/lib/jakarta-regexp-1.2.jar:$ARTEMIS_HOME/lib/macos.jar:$ARTEMIS_HOME/lib/postgresql-8.1-407.jdbc2ee.jar:$ARTEMIS_HOME/lib/chado-14-interface.jar:$CLASSPATH"
 
-- 
GitLab