summaryrefslogtreecommitdiffstats
path: root/initrd/mkdxsinitrd
diff options
context:
space:
mode:
authorNico Dietrich2006-04-21 14:09:16 +0200
committerNico Dietrich2006-04-21 14:09:16 +0200
commit489f7cd23cb0261a5ebf3ebe9c4074f13e7f0ea8 (patch)
tree3780bcd1118b75b64fa4489af1070ba4e510fb9f /initrd/mkdxsinitrd
parentBugfix concerning the processing of the dhcp option hw_monitor (diff)
downloadcore-489f7cd23cb0261a5ebf3ebe9c4074f13e7f0ea8.tar.gz
core-489f7cd23cb0261a5ebf3ebe9c4074f13e7f0ea8.tar.xz
core-489f7cd23cb0261a5ebf3ebe9c4074f13e7f0ea8.zip
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
Diffstat (limited to 'initrd/mkdxsinitrd')
-rwxr-xr-xinitrd/mkdxsinitrd36
1 files changed, 36 insertions, 0 deletions
diff --git a/initrd/mkdxsinitrd b/initrd/mkdxsinitrd
index 5f556170..815298e0 100755
--- a/initrd/mkdxsinitrd
+++ b/initrd/mkdxsinitrd
@@ -5,6 +5,7 @@
#
# Author(s): Dirk von Suchodoletz <dirk@goe.net>, 03-04-2006
# Nico Dietrich
+# Felix Endres
#
# Version: 0.3.1g
#
@@ -159,6 +160,38 @@ copy_distro_stuff() {
-regex ".*/\..*" -exec rm -rf {} 2>/dev/null \;
}
+# This function makes the directory of this script to the present working directory
+# 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
+
+}
+
#########################################################################
# End of function declaration
@@ -208,6 +241,9 @@ shift $(expr $OPTIND - 1)
#########################################################################
# End of parameter, argument interpretation
+#Change to the directory this script is located in
+goto_script_dir
+
if [ -z "$INSTDIR" ] ; then
INSTDIR=/tmp/dxs-instrd
fi