[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Xen-users] Startup-Hook Script ?



Hi

> Since function-wise you're trying to achieve what pygrub 
> does, it might be easier to create another pygrub-like script 
> and put it as bootloader on your config file.
> ...
> Attached is bash script that MIGHT work you. This script does 
> not parse grub's config file, so you might need to manually 
> adjust ARGS at the top of the script as needed (my test works 
> fine with empty ARGS though).

Great idea. I didn't know I could implement bootloaders myself.
I merged my block-script with your bootloader-script and it works great.

I parses /boot/grub/menu.lst (inside the domUs-root-partition), reads
"kernel" and "ramdisk" path of the "default"-th entry in the configuration
list, copies those to the dom0, and returns appropiate paths to xen.
Last problem: The "exit 3" does not seem to work correctly. Whenever a
problem exists, xm create just hangs instead of stopping...

For anyone interested I have pasted it below.

Regards,
  Steffen




#!/bin/bash

arg_count=$#
device=${!arg_count}
args=""
output=""
until [ -z "$1" ]
do
  if [ ${1:0:7} = "--args=" ];then
    args=${1:7}
  elif [ ${1:0:9} = "--output=" ];then
    output=${1:9}
  fi
  shift
done

if [ -z "$args" ] || [ -z "$output" ] || [ ! -e "$device" ]
then
  exit 3
fi

mount="$output-mount"
mkdir "$mount"
mount -o ro "$device" "$mount"
if [ $? -gt 0 ];then
  rmdir "$mount"
  exit 3
fi

config=`awk 'BEGIN { x=-1 } $1=="default" { x=$2+1 } $1=="title" { x=x-1 }
  x==0 && $1=="kernel" && $2~/(\/[a-z0-9-]|[\\.a-z0-9-]*)*/ { kernel=$2 }
  x==0 && $1=="initrd" && $2~/(\/[a-z0-9-]|[\\.a-z0-9-]*)*/ { initrd=$2 }
  END { print kernel " " initrd }' < $mount/boot/grub/menu.lst`

kernel=${config% *}
initrd=${config#* }
if [ -z "$kernel" ] || [ -z "$initrd" ] || [ ! -e "$mount$kernel" ] || [ !
-e "$mount$initrd" ]
then
  umount "$mount"
  rmdir "$mount"
  exit 3
fi

echo "$device, $mount, $kernel, $initrd, $output" >>/block.log

cp "$mount$kernel" "$output-kernel"
cp "$mount$initrd" "$output-initrd"

umount "$mount"
rmdir "$mount"

echo -n "linux (kernel $output-kernel)(ramdisk $output-initrd)(args
\"$args\")" >> "$output"

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
Xen-users mailing list
Xen-users@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-users

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.