Fix case where user is root
authorAlex Pyrgiotis <apyrgio@grnet.gr>
Fri, 1 Feb 2013 18:47:30 +0000 (20:47 +0200)
committerFilippos Giannakos <philipgian@grnet.gr>
Mon, 11 Mar 2013 09:39:46 +0000 (11:39 +0200)
In this case, /home/root/... path doesn't exist, so we use a hacky way
to get the scripts' path.

arch-scripts/grep_xseg.sh
arch-scripts/init.sh
arch-scripts/make_xseg.sh

index 082cc8f..194c3ff 100755 (executable)
@@ -6,8 +6,11 @@
 
 set -e #exit on error
 
+# Find script location
+ARCH_SCRIPTS=$(dirname "$(readlink /proc/$$/fd/255)")
+
 #Include basic functions
-source /home/$(logname)/archipelago/arch-scripts/init.sh
+source $ARCH_SCRIPTS/init.sh
 
 SED_XSEG=$(echo "${XSEG}/" | sed 's/\//\\\//g')
 INCLUDE="--include=*.c --include=*.h"
index 2088987..7a66d19 100644 (file)
@@ -16,5 +16,6 @@ grn_echo(){
        echo -e "${txtgrn}${1}${txtrst}"
 }
 
-XSEG=/home/$(logname)/archipelago/xseg
+#ARCH_SCRIPTS must be already set by the caller function
+XSEG=$ARCH_SCRIPTS/../xseg
 
index 8a12c60..ec48a61 100755 (executable)
@@ -6,8 +6,11 @@
 
 set -e  #exit on error
 
+# Find script location
+ARCH_SCRIPTS=$(dirname "$(readlink /proc/$$/fd/255)")
+
 #Include basic functions
-source /home/$(logname)/archipelago/arch-scripts/init.sh
+source $ARCH_SCRIPTS/init.sh
 
 PIPE="1>/dev/null"