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 \
93 --exclude /lib
/modules
/$krel/build \
94 --exclude /lib
/modules
/$krel/source ||
exit 1
95 scp modules-
$krel.
tar.gz root@
$host:/tmp ||
exit 1
96 SSH root@
$host "rm \-rf /lib/modules/$krel " ||
exit 1
97 SSH root@
$host " tar mzxf /tmp/modules-$krel.tar.gz -C / "||
exit 1
98 SSH root@
$host "mkinitrd \-f /boot/initrd-$krel.img $krel $MKINITRD_OPT" ||
exit 1
99 SSH root@
$host " wall 'modules was intalled to /lib/modules/$krel'"
100 rm -f modules-
$krel.
tar.gz
105 if [ $boot_proto == "pxe" ] ;then
106 echo "$BOOT_OPTS" |
egrep "[^[:space:]]+"
108 echo "Err: 'BOOT_OPTS' is empty. You must specify correct boot options"
111 cp arch
/$ARCH/boot
/bzImage vmlinuz-
$krel ||
exit 1
112 vmlinuz-
$krel root@
$PXE_SERVER:/$PXE_ROOT/$PXE_KERNEL_DIR/vmlinuz-
$krel \
114 rm -f vmlinuz-
$krel ||
exit 1
115 SSH root@
$PXE_SERVER " chmod 0444 /$PXE_ROOT/$PXE_KERNEL_DIR/vmlinuz-$krel"
116 if [ $mkinitrd == "y" ]; then
117 echo "Using initrd from different host is realy errorprone way."
118 echo "kernel probably can't boot with this initrd image"
119 scp initrd-
$krel.img root@
$PXE_SERVER:/$PXE_ROOT/$PXE_KERNEL_DIR ||
exit 1
120 SSH root@
$PXE_SERVER " chmod 0444 /$PXE_ROOT/$PXE_KERNEL_DIR/initrd-$krel.img "
122 SSH root@
$PXE_SERVER " vzt-pxe-boot $host add vmlinuz-$krel initrd-$krel.img '$BOOT_OPTS' $title"
138 ssh root@
${host} test /boot
/${kernel_img} ||
{
139 cho
"Kernel image : /boot/${kernel_img} not found";
143 ssh root@
${host} test /boot
/${initrd_img} ||
{
144 echo "initrd image :/boot/${initrd_img} not found" ;
148 if [ -z "$boot_opt" ]; then
151 args
='--args=$boot_opt'
153 SSH root@
${host} grubby
--remove-kernel=/boot
/${kernel_img} \
154 --add-kernel=/boot
/${kernel_img} \
155 --initrd=/boot
/${initrd_img} \
156 $args --title="${title_text}"
158 if [ $ret -ne 0 ] ;then
159 echo "Error while grub setup"
161 echo "savedefault --default=0 --once" | \
162 ssh root@
$host "grub --batch"
163 SSH root@
$host " wall 'grub: savedefault --default=/boot/\
164 ${kernel_img} --once'"
171 ##### local boot #####
172 if [ $boot_proto == "local" ]; then
173 cp arch
/$ARCH/boot
/bzImage vmlinuz-
$krel ||
exit
174 scp vmlinuz-
$krel root@
$host:/boot
/vmlinuz-
$krel ||
exit 1
175 rm -f vmlinuz-
$krel ||
exit 1
177 scp System.map root@
$host:/boot
/System.map-
$krel ||
exit 1
178 SSH root@
$host "rm -rf /boot/System.map" ||
exit 1
179 SSH root@
$host "ln -s /boot/System.map-$krel /boot/System.map"
181 SSH root@
$host "wall 'new kernel was intalled to /boot/vmlinuz-$krel'"
182 if [ $mkinitrd == "y" ]; then
183 SSH root@
$host "mkinitrd \-f /boot/initrd-$krel.img $krel $MKINITRD_OPT" ||
exit 1
185 grub_setup
$host vmlinuz-
$krel initrd-
$krel.img
$title $BOOT_OPTS \
186 #SSH root@$host " ls -l "
190 echo "Bad boot protocol" ;