2013-01-23 17:28:19 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# network root script for anaconda.
|
|
|
|
# runs in the "online" hook, every time an interface comes online.
|
|
|
|
|
|
|
|
command -v getarg >/dev/null || . /lib/dracut-lib.sh
|
|
|
|
|
|
|
|
# initqueue/online hook passes interface name as $1
|
|
|
|
netif="$1"
|
|
|
|
|
|
|
|
# get repo info
|
|
|
|
splitsep ":" "$root" prefix repo
|
|
|
|
|
|
|
|
# no repo? non-net root? we're not needed here.
|
|
|
|
[ "$prefix" = "anaconda-net" ] && [ -n "$repo" ] || return 0
|
|
|
|
# already done? don't run again.
|
|
|
|
[ -e /dev/root ] && return 0
|
|
|
|
|
|
|
|
# user requested a specific network device, but this isn't it - bail out
|
|
|
|
[ -n "$ksdevice" ] && [ "$ksdevice" != "$netif" ] && return 0
|
|
|
|
# user didn't request a specific device, so the first one online wins!
|
|
|
|
[ -z "$ksdevice" ] && ksdevice="$netif"
|
|
|
|
|
|
|
|
command -v config_get >/dev/null || . /lib/anaconda-lib.sh
|
|
|
|
|
|
|
|
case $repo in
|
|
|
|
nfs*)
|
|
|
|
. /lib/nfs-lib.sh
|
|
|
|
info "anaconda mounting NFS repo at $repo"
|
|
|
|
str_starts "$repo" "nfsiso:" && repo=nfs:${repo#nfsiso:}
|
2015-05-30 11:20:59 +00:00
|
|
|
|
|
|
|
# Replace hex space with a real one. All uses of repo need to be quoted
|
|
|
|
# after this point.
|
|
|
|
repo=${repo//\\x20/ }
|
|
|
|
|
2016-04-10 04:00:00 +00:00
|
|
|
# Convert nfs4 to nfs:nfsvers=4
|
|
|
|
#
|
|
|
|
# The reason for this is because anaconda's nfs and dracut's nfs are different.
|
|
|
|
# dracut expects options at the end, anaconda puts them after nfs:
|
|
|
|
# dracut's nfs_to_var has a special case to handle anaconda's nfs: form but not nfs4:
|
|
|
|
if str_starts "$repo" "nfs4:"; then
|
|
|
|
repo=nfs:${repo#nfs4:}
|
|
|
|
nfs_to_var "$repo" $netif
|
|
|
|
if ! strstr "$options" "vers="; then
|
|
|
|
repo="nfs:${options:+$options,}nfsvers=4:$server:$path"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
# HACK: work around some Mysterious NFS4 Badness (#811242 and friends)
|
|
|
|
# by defaulting to nfsvers=3 when no version is requested
|
|
|
|
nfs_to_var "$repo" $netif
|
|
|
|
if ! strstr "$options" "vers="; then
|
|
|
|
repo="nfs:${options:+$options,}nfsvers=3:$server:$path"
|
|
|
|
fi
|
|
|
|
# END HACK. FIXME: Figure out what is up with nfs4, jeez
|
2013-01-23 17:28:19 +00:00
|
|
|
fi
|
|
|
|
if [ "${repo%.iso}" == "$repo" ]; then
|
|
|
|
mount_nfs "$repo" "$repodir" "$netif" || warn "Couldn't mount $repo"
|
|
|
|
anaconda_live_root_dir $repodir
|
|
|
|
else
|
|
|
|
iso="${repo##*/}"
|
|
|
|
mount_nfs "${repo%$iso}" "$repodir" "$netif" || \
|
|
|
|
warn "Couldn't mount $repo"
|
|
|
|
anaconda_live_root_dir $repodir $iso
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
http*|ftp*)
|
|
|
|
. /lib/url-lib.sh
|
|
|
|
info "anaconda fetching installer from $repo"
|
|
|
|
treeinfo=$(fetch_url $repo/.treeinfo) && \
|
|
|
|
stage2=$(config_get stage2 mainimage < $treeinfo)
|
|
|
|
if [ -z "$treeinfo" -o -z "$stage2" ]; then
|
|
|
|
warn "can't find installer mainimage path in .treeinfo"
|
2016-04-10 04:00:00 +00:00
|
|
|
stage2="images/install.img"
|
2013-01-23 17:28:19 +00:00
|
|
|
fi
|
2016-04-10 04:00:00 +00:00
|
|
|
if runtime=$(fetch_url $repo/$stage2) || runtime=$(fetch_url $repo/LiveOS/squashfs.img); then
|
2013-01-23 17:28:19 +00:00
|
|
|
# NOTE: Should be the same as anaconda_auto_updates()
|
|
|
|
updates=$(fetch_url $repo/images/updates.img)
|
|
|
|
[ -n "$updates" ] && unpack_updates_img $updates /updates
|
|
|
|
product=$(fetch_url $repo/images/product.img)
|
2014-04-07 12:38:09 +00:00
|
|
|
[ -n "$product" ] && unpack_updates_img $product /updates
|
2016-04-10 04:00:00 +00:00
|
|
|
anaconda_mount_sysroot $runtime
|
|
|
|
else
|
|
|
|
warn "Could not retrieve stage2 image from $repo using $netif"
|
2013-01-23 17:28:19 +00:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
warn "unknown network repo URL: $repo"
|
|
|
|
return 1
|
|
|
|
;;
|
|
|
|
esac
|