kickstart/lib/kickstart-root-dir

31 lines
658 B
Plaintext
Raw Permalink Normal View History

#!/bin/bash
_kickstart_readlink() {
(
TARGET_FILE=$1
2015-05-20 20:16:16 +00:00
cd "$(dirname "$TARGET_FILE")"
TARGET_FILE=$(basename "$TARGET_FILE")
while [ -L "$TARGET_FILE" ]
do
2015-05-20 20:16:16 +00:00
TARGET_FILE=$(readlink "$TARGET_FILE")
cd "$(dirname "$TARGET_FILE")"
TARGET_FILE=$(basename "$TARGET_FILE")
done
2015-05-20 20:16:16 +00:00
PHYS_DIR=$(pwd -P)
RESULT=$PHYS_DIR/$TARGET_FILE
2015-05-20 20:16:16 +00:00
echo "$RESULT"
)
}
2015-05-20 20:16:16 +00:00
path_to_kickstart=$(which kickstart)
if [[ $(uname) == "Darwin" ]]; then
resolved_path_to_kickstart_bin=$(_kickstart_readlink "$path_to_kickstart")
else
2015-05-20 20:16:16 +00:00
resolved_path_to_kickstart_bin=$(readlink -f "$path_to_kickstart")
fi
2015-05-20 20:16:16 +00:00
dirname "$(dirname "$resolved_path_to_kickstart_bin")"