From 489f7cd23cb0261a5ebf3ebe9c4074f13e7f0ea8 Mon Sep 17 00:00:00 2001 From: Nico Dietrich Date: Fri, 21 Apr 2006 12:09:16 +0000 Subject: Added a function to make the script dir the pwd mkdxsinitrd and ld4-inst can now be called from everywhere, including the possibility to call them by a (soft) link git-svn-id: http://svn.openslx.org/svn/openslx/ld4@193 95ad53e4-c205-0410-b2fa-d234c58c8868 --- installer/ld4-inst | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'installer') diff --git a/installer/ld4-inst b/installer/ld4-inst index 94b2265d..e30334f8 100755 --- a/installer/ld4-inst +++ b/installer/ld4-inst @@ -9,6 +9,7 @@ # Copyright: (c) 2003, 2006 - RZ Universitaet Freiburg # # Version: 0.2.0d +DEBUG=2 header() { echo @@ -16,6 +17,39 @@ header() { echo } +# This function makes the directory of this script to the present working directory +# It is called within precheck() +# Does also work when called by a link. FIXME: Breaks when called by a link to a link +goto_script_dir() +{ + [ $DEBUG -ge 2 ] && echo "Aufgerufen wurde $0, checking if it is a link" + calleddetails=`ls -l $0` # get the file flags (e.g. lrwxrwxrwx) + [ $DEBUG -ge 2 ] && echo $calleddetails + index=`expr index "$calleddetails" "l"` + + calleddir=${0%/*} # Strip the filename from path + [ $DEBUG -ge 2 ] && echo "Wechsele ins Verzeichnis des aufgerufenen scripts/links ($calleddir)" + cd $calleddir + + + if [ $index -eq 1 ]; then + [ $DEBUG -ge 2 ] && echo "It is a link" + + script=`echo $calleddetails | awk '{print $NF}'` + [ $DEBUG -ge 2 ] && echo "The script is: $script" + hasslash=`expr index "$script" "/"` + if [ $hasslash -ne 0 ]; then + scriptdir=${script%/*} + [ $DEBUG -ge 2 ] && echo "Following link to $scriptdir" + cd $scriptdir + else + [ $DEBUG -ge 2 ] && echo "It is in the same directory as the link" + fi + fi + [ $DEBUG -ge 2 ] && pwd + +} + # check needed things for installation precheck() { @@ -24,7 +58,10 @@ precheck() { echo -e "\nYou don't have the needed permission. Please rerun as root user!\n" exit 1 fi - + + # switch pwd to this scripts location + goto_script_dir + # check for existing programs: # rsync (server-side) which rsync >/dev/null -- cgit v1.2.3-55-g7522