1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
|
#!/bin/sh -e
# this script is run either chrooted on the server, or by a client with write
# access to the NFS mount point. (much of this code was originally in
# server/ltsp-update-kernels). --vagrant 20060801
if [ -f /etc/ltsp/update-kernels.conf ]; then
. /etc/ltsp/update-kernels.conf
fi
BOOT=${BOOT:-"/boot"}
SUB_ARCH=${SUB_ARCH:-"$(uname -m)"}
VENDOR=${VENDOR:-"$(lsb_release -i -s)"}
case $0 in
/etc/kernel/post*.d*) QUIET=true
esac
msg() {
if [ "$QUIET" != "true" ]; then
echo $@
fi
}
if [ -z "$CHROOT_NAME" ]; then
# FIXME: replace with a common function
CHROOT_NAME="$(dpkg --print-installation-architecture)"
fi
if [ -z "$BOOTPROMPT_OPTS" ]; then
if [ "$VENDOR" = "Ubuntu" ]; then
BOOTPROMPT_OPTS="quiet splash"
else
BOOTPROMPT_OPTS="root=/dev/nfs ip=dhcp"
fi
fi
if [ -f /usr/lib/yaboot/yaboot ]; then
cp -a -v /usr/lib/yaboot/yaboot $BOOT
cat > $BOOT/yaboot.conf <<EOF
timeout=0
default=ltsp
root=/dev/ram
image=/ltsp/$CHROOT_NAME/vmlinux
label=ltsp
initrd=/ltsp/$CHROOT_NAME/initrd.img
append="$BOOTPROMPT_OPTS"
EOF
else
msg "Skipping yaboot configuration. install yaboot package if you need it."
fi
if [ -f /usr/lib/syslinux/pxelinux.0 ]; then
PXECFG=$BOOT/pxelinux.cfg
cp /usr/lib/syslinux/pxelinux.0 $BOOT
if [ ! -d $PXECFG ]; then
mkdir $PXECFG
fi
if [ -z "$PXELINUX_CMDLINE" ]; then
PXELINUX_CMDLINE="DEFAULT vmlinuz ro initrd=initrd.img $BOOTPROMPT_OPTS"
fi
cat > $PXECFG/default <<EOF
$PXELINUX_CMDLINE
EOF
else
msg "Skipping PXE configuration. Install the syslinux package if you need it."
fi
# allow specifying a specific kernel image to update, from kernel postinst
if [ -f "$2" ]; then
ALL_KERNELS="$2"
else
ALL_KERNELS="$(find $BOOT -type f -name 'vmlinu*')"
fi
# look for symlinks, too, and put them after the "real" kernels
ALL_KERNELS="$ALL_KERNELS $(find $BOOT -type l -name 'vmlinu*')"
for kernel in $ALL_KERNELS ; do
basename=$(basename "$kernel")
initrd=initrd.img
nbi=nbi.img
case $basename in
vmlinuz|vmlinux)
# USE DEFAULT
;;
vmlinu*.old)
initrd=$initrd.old
nbi=$nbi.old
;;
vmlinuz*)
version=${basename##vmlinuz-}
initrd=$initrd-$version
nbi=$nbi-$version
;;
vmlinux*)
version=${basename##vmlinux-}
initrd=$initrd-$version
nbi=$nbi-$version
;;
esac
if [ -L "$kernel" ]; then
basename="$(readlink $kernel)"
if [ -f "$BOOT/$basename" ]; then
case $basename in
vmlinuz*)
version=${basename##vmlinuz-}
;;
vmlinux*)
version=${basename##vmlinux-}
;;
esac
case $SUB_ARCH in
sparc*)
realnbi="nbi.img-$version-$SUB_ARCH"
;;
*)
realnbi="nbi.img-$version"
;;
esac
if [ -f "$BOOT/$realnbi" ]; then
ln -sf $realnbi $BOOT/$nbi
fi
fi
else
if which mkelf-linux >/dev/null; then
if [ -z "$MKELF_LINUX_OPTS" ]; then
MKELF_LINUX_OPTS="--ip=dhcp"
fi
if [ -f "$BOOT/$initrd" ]; then
mkelf-linux $MKELF_LINUX_OPTS -o $BOOT/$nbi $kernel $BOOT/$initrd
else
mkelf-linux $MKELF_LINUX_OPTS -o $BOOT/$nbi $kernel
fi
else
if [ -z "$mkelf_seen" ]; then
msg "Skipping etherboot images. Install the mknbi package if you need them."
mkfelf_seen=true
fi
fi
if which netabootwrap >/dev/null; then
if [ -f "$BOOT/$initrd" ]; then
netabootwrap -t $BOOT/$nbi -k $kernel -i $BOOT/$initrd
else
netabootwrap -t $BOOT/$nbi -k $kernel
fi
else
if [ -z "$netabootwrap_seen" ]; then
msg "Skipping netabootwrap images. Install the aboot package if you need them."
netabootwrap_seen=true
fi
fi
if which elftoaout >/dev/null ; then
piggyback_cmd=""
case $SUB_ARCH in
sparc64) piggyback_cmd=piggyback64 ;;
sparc32) piggyback_cmd=piggyback32 ;;
esac
sysmap=$BOOT/System.map-$version
nbi=$nbi-$SUB_ARCH
# TODO: proper tempfile handline
gzip -cd $kernel > $nbi.tmp
elftoaout -o $nbi $nbi.tmp
if [ -f "$BOOT/$initrd" ]; then
$piggyback_cmd $BOOT/$nbi $sysmap $BOOT/$initrd
else
$piggyback_cmd $BOOT/$nbi $sysmap
fi
else
if [ -z "$sparc_piggyback_seen" ]; then
msg "Skipping sparc piggyback images. Install the sparc-utils package if you need them."
sparc_piggyback_seen=true
fi
fi
fi
done
|