Commit e777f9d5 authored by Nikos Skalkotos's avatar Nikos Skalkotos
Browse files

Remove hardcoded FLOPPY_DEV in helper

Check the cmdline of the kernel to determine what device to check
for find the rules file
parent 107e56e0
......@@ -62,15 +62,17 @@ prepare_helper() {
read -a cmdline < /proc/cmdline
for item in "${cmdline[@]}"; do
key=$(cut -d= -f1 <<< "$item")
val=$(cut -d= -f2 <<< "$item")
if [ "$key" = "hypervisor" ]; then
val=$(cut -d= -f2 <<< "$item")
hypervisor="$val"
fi
if [ "$key" = "rules_dev" ]; then
export RULES_DEV="$val"
fi
done
case "$hypervisor" in
kvm)
FLOPPY_DEV=/dev/fd0
exec {RESULT_FD}> /dev/ttyS1
add_cleanup close_fd ${RESULT_FD}
exec {MONITOR_FD}> /dev/ttyS2
......@@ -81,7 +83,6 @@ prepare_helper() {
iptables -P OUTPUT DROP
ip6tables -P OUTPUT DROP
ip link set eth0 up
FLOPPY_DEV=/dev/xvdc
domid=$(xenstore-read domid)
exec {RESULT_FD}> >(xargs -l1 xenstore-write /local/domain/0/snf-image-helper/$domid)
add_cleanup close_fd ${RESULT_FD}
......
......@@ -51,24 +51,24 @@ fi
prepare_helper
if [ ! -b "$FLOPPY_DEV" ]; then
log_error "Floppy device is not present!"
if [ ! -b "$RULES_DEV" ]; then
log_error "Device file hosting the rules file: \`$RULES_DEV' does not exist"
fi
floppy=$(mktemp -d --tmpdir floppy.XXXXXX)
add_cleanup rmdir "$floppy"
rules=$(mktemp -d --tmpdir rules.XXXXXX)
add_cleanup rmdir "$rules"
$MOUNT $FLOPPY_DEV $floppy
add_cleanup umount "$floppy"
$MOUNT $RULES_DEV $rules
add_cleanup umount "$rules"
if [ -f "$floppy/rules" ]; then
source "$floppy/rules"
if [ -f "$rules/rules" ]; then
source "$rules/rules"
else
log_error "Floppy does not contain \`rules\' file"
log_error "$RULES_DEV does not contain \`rules\' file"
fi
if [ -f "$floppy/unattend.xml" ]; then
export SNF_IMAGE_UNATTEND="$floppy/unattend.xml"
if [ -f "$rules/unattend.xml" ]; then
export SNF_IMAGE_UNATTEND="$rules/unattend.xml"
fi
if [ -n "$SNF_IMAGE_PROPERTIES" ]; then
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment