2 # Install kernel to test host
3 CONFIG
=.vzt
/kernel-install.cfg
6 echo "$0: <host> [OPTS]"
8 echo "Install kernele to test host via ssh or pxe"
10 echo "Install kernel, modules and initrd to host via \
11 ssh and setup local boot loader"
12 echo " $0 my_host.org --all"
13 echo "Install kernel only via ssh and setup local boot loader"
14 echo " $0 my_host.org "
15 echo "Install kernel and setup pxe boot loader"
16 echo " $0 my_host --pxe"
17 echo "Disable pxe boot for host"
18 echo " $0 my_host --pxe --disable"
22 if [ ! -f "$CONFIG" ]; then
23 echo "Cant find .vzt/kernel-install.cfg"
24 echo "you may use example config:"
25 echo " mkdir .vzt; cp /etc/vzt/kernel-install.cfg.example \
26 .vzt/kernel-install.cfg "
30 krel
=`make kernelrelease`
32 if [ ! $?
-eq 0 ]; then
33 echo "Can't get kernel release version"
34 echo "This is probably happend CWD is wrong."
35 echo "do: cd /your/path/to/kernel/linux-tree/"
41 ssh -n -oStrictHostKeyChecking=no
-oBatchMode=yes $@
47 if [ -z "$host" ] ;then
48 echo "Err: Bad arguments"
55 if [ "$1" = "--pxe" ]; then
60 if [ "$1" = "--all" ]; then
66 if [ "$1" = "--suffix" ]; then
72 if [ "$1" = "--initrd" ]; then
77 if [ "$1" = "--disable" ]; then
78 if [ "$boot_proto" = "pxe" ]; then
79 SSH root@
$PXE_SERVER " vzt-pxe-boot $host del"
82 echo "ERR: --disable option valid only for pxe boot mode"
88 echo "Install kernel to $server via protocol: $boot_proto"
90 if [ $modules == "y" ]; then
91 make modules_install ||
exit 1;
92 tar zcf modules-
$krel.
tar.gz
/lib
/modules
/$krel ||
exit 1
93 scp modules-
$krel.
tar.gz root@
$host:/tmp ||
exit 1
94 SSH root@
$host "rm \-rf /lib/modules/$krel " ||
exit 1
95 SSH root@
$host " tar zxf /tmp/modules-$krel.tar.gz -C / "||
exit 1
96 SSH root@
$host "mkinitrd \-f /boot/initrd-$krel.img $krel $MKINITRD_OPT" ||
exit 1
97 rm -f modules-
$krel.
tar.gz
102 if [ $boot_proto == "pxe" ] ;then
103 echo "$BOOT_OPTS" |
egrep "[^[:space:]]+"
105 echo "Err: 'BOOT_OPTS' is empty. You must specify correct boot options"
108 cp arch
/$ARCH/boot
/bzImage vmlinuz-
$krel ||
exit 1
109 vmlinuz-
$krel root@
$PXE_SERVER:/$PXE_ROOT/$PXE_KERNEL_DIR/vmlinuz-
$krel \
111 rm -f vmlinuz-
$krel ||
exit 1
112 SSH root@
$PXE_SERVER " chmod 0444 /$PXE_ROOT/$PXE_KERNEL_DIR/vmlinuz-$krel"
113 if [ $mkinitrd == "y" ]; then
114 echo "Using initrd from different host is realy errorprone way."
115 echo "kernel probably can't boot with this initrd image"
116 scp initrd-
$krel.img root@
$PXE_SERVER:/$PXE_ROOT/$PXE_KERNEL_DIR ||
exit 1
117 SSH root@
$PXE_SERVER " chmod 0444 /$PXE_ROOT/$PXE_KERNEL_DIR/initrd-$krel.img "
119 SSH root@
$PXE_SERVER " vzt-pxe-boot $host add vmlinuz-$krel initrd-$krel.img '$BOOT_OPTS' $title"
135 ssh root@
${host} test /boot
/${kernel_img} ||
{
136 cho
"Kernel image : /boot/${kernel_img} not found";
140 ssh root@
${host} test /boot
/${initrd_img} ||
{
141 echo "initrd image :/boot/${initrd_img} not found" ;
145 if [ -z "$boot_opt" ]; then
148 args
='--args=$boot_opt'
150 ssh root@
${host} grubby
--remove-kernel=/boot
/${kernel_img} \
151 --add-kernel=/boot
/${kernel_img} \
152 --initrd=/boot
/${initrd_img} \
153 $args --title="${title_text}" \
156 if [ $ret -ne 0 ] ;then
157 echo "Error while grub setup"
165 ##### local boot #####
166 if [ $boot_proto == "local" ]; then
167 cp arch
/$ARCH/boot
/bzImage vmlinuz-
$krel ||
exit
168 scp vmlinuz-
$krel root@
$host:/boot
/vmlinuz-
$krel ||
exit 1
169 rm -f vmlinuz-
$krel ||
exit 1
170 if [ $mkinitrd == "y" ]; then
171 SSH root@
$host "mkinitrd \-f /boot/initrd-$krel.img $krel $MKINITRD_OPT" ||
exit 1
173 grub_setup
$host vmlinuz-
$krel initrd-
$krel.img
$title $BOOT_OPTS \
174 #SSH root@$host " ls -l "
178 echo "Bad boot protocol" ;