summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNico Dietrich2006-04-25 21:22:23 +0200
committerNico Dietrich2006-04-25 21:22:23 +0200
commit37e0f4a3e376d02c600e0f29d3e9895926b2b149 (patch)
tree41149190aa332b9430cfb64ed4c3d9b5036249af
parentnew Xdialog, rightcheck disabled because 'test' sux (diff)
downloadcore-37e0f4a3e376d02c600e0f29d3e9895926b2b149.tar.gz
core-37e0f4a3e376d02c600e0f29d3e9895926b2b149.tar.xz
core-37e0f4a3e376d02c600e0f29d3e9895926b2b149.zip
Both scripts can now be called by nested symlinks
git-svn-id: http://svn.openslx.org/svn/openslx/ld4@195 95ad53e4-c205-0410-b2fa-d234c58c8868
-rwxr-xr-xinitrd/mkdxsinitrd32
-rwxr-xr-xinstaller/ld4-inst33
2 files changed, 36 insertions, 29 deletions
diff --git a/initrd/mkdxsinitrd b/initrd/mkdxsinitrd
index 815298e0..6cdfb30b 100755
--- a/initrd/mkdxsinitrd
+++ b/initrd/mkdxsinitrd
@@ -161,33 +161,37 @@ copy_distro_stuff() {
}
# 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
+# It is called within precheck()
+# Does also work when called by symbolic links (even for nested links).
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
+
+ while index=`expr index "$calleddetails" "l"`;
+ [ $index -eq 1 ]; do
-
- 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" "/"`
+ target=`echo $calleddetails | awk '{print $NF}'`
+ [ $DEBUG -ge 2 ] && echo "The target of the link is: $target"
+ hasslash=`expr index "$target" "/"`
if [ $hasslash -ne 0 ]; then
- scriptdir=${script%/*}
- [ $DEBUG -ge 2 ] && echo "Following link to $scriptdir"
- cd $scriptdir
+ targetpath=${target%/*} # extract the pathname
+ [ $DEBUG -ge 2 ] && echo "Following link to $targetpath"
+ cd $targetpath
else
- [ $DEBUG -ge 2 ] && echo "It is in the same directory as the link"
+ [ $DEBUG -ge 2 ] && echo "It is in the same directory as the link"
fi
- fi
+ targetfile=`basename $target`
+ [ $DEBUG -ge 2 ] && echo "The target file of the link is: $targetfile"
+ calleddetails=`ls -l $targetfile` # get the file flags (e.g. lrwxrwxrwx)
+ [ $DEBUG -ge 2 ] && echo $calleddetails
+ done
[ $DEBUG -ge 2 ] && pwd
}
diff --git a/installer/ld4-inst b/installer/ld4-inst
index e30334f8..37e2a36d 100755
--- a/installer/ld4-inst
+++ b/installer/ld4-inst
@@ -9,7 +9,7 @@
# Copyright: (c) 2003, 2006 - RZ Universitaet Freiburg
#
# Version: 0.2.0d
-DEBUG=2
+DEBUG=0
header() {
echo
@@ -19,33 +19,36 @@ header() {
# 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
+# Does also work when called by a symbolic link. Even works for nested links.
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
+
+ while index=`expr index "$calleddetails" "l"`;
+ [ $index -eq 1 ]; do
-
- 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" "/"`
+ target=`echo $calleddetails | awk '{print $NF}'`
+ [ $DEBUG -ge 2 ] && echo "The target of the link is: $target"
+ hasslash=`expr index "$target" "/"`
if [ $hasslash -ne 0 ]; then
- scriptdir=${script%/*}
- [ $DEBUG -ge 2 ] && echo "Following link to $scriptdir"
- cd $scriptdir
+ targetpath=${target%/*} # extract the pathname
+ [ $DEBUG -ge 2 ] && echo "Following link to $targetpath"
+ cd $targetpath
else
- [ $DEBUG -ge 2 ] && echo "It is in the same directory as the link"
+ [ $DEBUG -ge 2 ] && echo "It is in the same directory as the link"
fi
- fi
+ targetfile=`basename $target`
+ [ $DEBUG -ge 2 ] && echo "The target file of the link is: $targetfile"
+ calleddetails=`ls -l $targetfile` # get the file flags (e.g. lrwxrwxrwx)
+ [ $DEBUG -ge 2 ] && echo $calleddetails
+ done
[ $DEBUG -ge 2 ] && pwd
}