-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change original lun wwid to the new one after migration.
- Loading branch information
ltomasik
committed
Aug 9, 2016
1 parent
d9f76e6
commit e1a704b
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# migrate lun_wwid_mapping | ||
|
||
# skip if no mappings | ||
test -s "$LUN_WWID_MAP" || return 0 | ||
|
||
Log "TAG-15-migrate-wwid: $LUN_WWID_MAP" | ||
|
||
# create the SED_SCRIPT | ||
SED_SCRIPT="" | ||
while read old_wwid new_wwid device ; do | ||
SED_SCRIPT="$SED_SCRIPT;/${old_wwid}/s/${old_wwid}/${new_wwid}/g" | ||
done < <(sort -u $LUN_WWID_MAP) | ||
|
||
# debug line: | ||
Log "$SED_SCRIPT" | ||
|
||
# now run sed | ||
pushd $TARGET_FS_ROOT >&8 | ||
# the funny [] around the first letter make sure that shopt -s nullglob removes this file from the list if it does not exist | ||
# the files without a [] are mandatory, like fstab | ||
for file in [e]tc/elilo.conf \ | ||
[e]tc/fstab | ||
do | ||
|
||
#[[ -d "$file" ]] && continue # skip directory | ||
[[ ! -f "$file" ]] && continue # skip directory and file not found | ||
# sed -i bails on symlinks, so we follow the symlink and patch the result | ||
# on dead links we warn and skip them | ||
# TODO: maybe we must put this into a chroot so that absolute symlinks will work correctly | ||
if test -L "$file" ; then | ||
if linkdest="$(readlink -f "$file")" ; then | ||
# if link destination is residing on /proc we skip it silently | ||
echo $linkdest | grep -q "^/proc" && continue | ||
LogPrint "Patching '$linkdest' instead of '$file'" | ||
file="$linkdest" | ||
else | ||
LogPrint "Not patching dead link '$file'" | ||
continue | ||
fi | ||
fi | ||
|
||
LogPrint "Patching file '$file'" | ||
sed -i "$SED_SCRIPT" "$file" | ||
StopIfError "Patching '$file' with sed failed." | ||
done | ||
|
||
popd >&8 |