mirror of
https://github.com/rancher/os.git
synced 2025-07-18 09:01:03 +00:00
use extlinux instead of grub2
This commit is contained in:
parent
ab6cba20ff
commit
a60eb06307
@ -1,9 +1,8 @@
|
|||||||
FROM debian:jessie
|
FROM alpine
|
||||||
|
RUN apk update && apk add coreutils util-linux bash parted syslinux e2fsprogs
|
||||||
COPY ./scripts/installer /scripts
|
COPY ./scripts/installer /scripts
|
||||||
COPY ./scripts/version /scripts/
|
COPY ./scripts/version /scripts/
|
||||||
RUN /scripts/bootstrap
|
|
||||||
|
|
||||||
COPY ./dist/artifacts/vmlinuz /dist/vmlinuz
|
COPY ./dist/artifacts/vmlinuz ./dist/artifacts/initrd /dist/
|
||||||
COPY ./dist/artifacts/initrd /dist/initrd
|
|
||||||
|
|
||||||
ENTRYPOINT ["/scripts/lay-down-os"]
|
ENTRYPOINT ["/scripts/lay-down-os"]
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
|
||||||
|
|
||||||
apt-get update
|
|
||||||
apt-get install -y grub2 parted
|
|
@ -2,10 +2,11 @@
|
|||||||
set -e -x
|
set -e -x
|
||||||
|
|
||||||
. $(dirname $0)/version
|
. $(dirname $0)/version
|
||||||
|
VERSION=${VERSION:?"VERSION not set"}
|
||||||
|
|
||||||
while getopts "i:f:c:d:t:r:o:p:" OPTION
|
while getopts "i:f:c:d:t:r:o:p:" OPTION
|
||||||
do
|
do
|
||||||
case $OPTION in
|
case ${OPTION} in
|
||||||
i) DIST="$OPTARG" ;;
|
i) DIST="$OPTARG" ;;
|
||||||
f) FILES="$OPTARG" ;;
|
f) FILES="$OPTARG" ;;
|
||||||
c) CLOUD_CONFIG="$OPTARG" ;;
|
c) CLOUD_CONFIG="$OPTARG" ;;
|
||||||
@ -56,43 +57,41 @@ mount_device()
|
|||||||
mount_opts=${PARTITION}
|
mount_opts=${PARTITION}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mount $mount_opts ${BASE_DIR}
|
mount ${mount_opts} ${BASE_DIR}
|
||||||
trap "umount ${BASE_DIR}" EXIT
|
trap "umount ${BASE_DIR}" EXIT
|
||||||
}
|
}
|
||||||
|
|
||||||
create_boot_dirs()
|
create_boot_dirs()
|
||||||
{
|
{
|
||||||
mkdir -p ${BASE_DIR}/boot/grub
|
mkdir -p ${BASE_DIR}/boot/grub
|
||||||
|
mkdir -p ${BASE_DIR}/boot/extlinux
|
||||||
}
|
}
|
||||||
|
|
||||||
install_grub() {
|
install_extlinux() {
|
||||||
grub-install --boot-directory=${BASE_DIR}/boot ${DEVICE}
|
extlinux -i ${BASE_DIR}/boot/extlinux
|
||||||
|
dd if=/usr/share/syslinux/mbr.bin of=${DEVICE}
|
||||||
}
|
}
|
||||||
|
|
||||||
grub2_config(){
|
extlinux_config(){
|
||||||
local grub_cfg=${BASE_DIR}/boot/grub/grub.cfg
|
local extlinux_conf=${BASE_DIR}/boot/extlinux/extlinux.conf
|
||||||
local append_line="${1}"
|
local append_line="${1}"
|
||||||
cat >$grub_cfg <<EOF
|
cat >${extlinux_conf} <<EOF
|
||||||
set default="0"
|
default ros
|
||||||
set timeout="1"
|
label ros
|
||||||
#set fallback=1
|
kernel /boot/vmlinuz-${VERSION}-rancheros
|
||||||
|
initrd /boot/initrd-${VERSION}-rancheros
|
||||||
menuentry "RancherOS-current" {
|
append ${append_line} console=ttyS0 console=tty0
|
||||||
set root=(hd0,msdos1)
|
|
||||||
linux /boot/vmlinuz-${VERSION}-rancheros ${append_line} console=ttyS0 console=tty0
|
|
||||||
initrd /boot/initrd-${VERSION}-rancheros
|
|
||||||
}
|
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
if [ ! -z $ROLLBACK_VERSION ]; then
|
if [ ! -z ${ROLLBACK_VERSION} ]; then
|
||||||
sed -i 's/^#set/set/' ${grub_cfg}
|
sed -i 's/^#set/set/' ${extlinux_conf}
|
||||||
cat >>$grub_cfg <<EOF
|
cat >>${extlinux_conf} <<EOF
|
||||||
menuentry "RancherOS-rollback" {
|
label ros-fallback
|
||||||
set root=(hd0,msdos1)
|
kernel /boot/vmlinuz-${ROLLBACK_VERSION}-rancheros
|
||||||
linux /boot/vmlinuz-${ROLLBACK_VERSION}-rancheros ${append_line} console=ttyS0 console=tty0
|
initrd /boot/initrd-${ROLLBACK_VERSION}-rancheros
|
||||||
initrd /boot/initrd-${ROLLBACK_VERSION}-rancheros
|
append ${append_line} console=ttyS0 console=tty0
|
||||||
}
|
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -100,15 +99,15 @@ fi
|
|||||||
|
|
||||||
install_rancher()
|
install_rancher()
|
||||||
{
|
{
|
||||||
cp ${DIST}/initrd /mnt/new_img/boot/initrd-${VERSION}-rancheros
|
cp ${DIST}/initrd ${BASE_DIR}/boot/initrd-${VERSION}-rancheros
|
||||||
cp ${DIST}/vmlinuz /mnt/new_img/boot/vmlinuz-${VERSION}-rancheros
|
cp ${DIST}/vmlinuz ${BASE_DIR}/boot/vmlinuz-${VERSION}-rancheros
|
||||||
}
|
}
|
||||||
|
|
||||||
pvgrub_config()
|
pvgrub_config()
|
||||||
{
|
{
|
||||||
local grub_file=/mnt/new_img/boot/grub/menu.lst
|
local grub_file=${BASE_DIR}/boot/grub/menu.lst
|
||||||
local append_line="${1}"
|
local append_line="${1}"
|
||||||
cat > $grub_file<<EOF
|
cat > ${grub_file}<<EOF
|
||||||
default 0
|
default 0
|
||||||
timeout 0
|
timeout 0
|
||||||
#fallback 1
|
#fallback 1
|
||||||
@ -122,9 +121,9 @@ initrd /boot/initrd-${VERSION}-rancheros
|
|||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
if [ ! -z $ROLLBACK_VERSION ]; then
|
if [ ! -z ${ROLLBACK_VERSION} ]; then
|
||||||
sed -i 's/^#\(fallback\)/\1/' $grub_file
|
sed -i 's/^#\(fallback\)/\1/' ${grub_file}
|
||||||
cat >> $grub_file<<EOF
|
cat >> ${grub_file}<<EOF
|
||||||
title RancherOS ${ROLLBACK_VERSION}-(rollback)
|
title RancherOS ${ROLLBACK_VERSION}-(rollback)
|
||||||
root (hd0)
|
root (hd0)
|
||||||
kernel /boot/vmlinuz-${ROLLBACK_VERSION}-rancheros ${append_line} console=ttyS0 console=tty0
|
kernel /boot/vmlinuz-${ROLLBACK_VERSION}-rancheros ${append_line} console=ttyS0 console=tty0
|
||||||
@ -145,21 +144,21 @@ if [ -n ${ENV} ]; then
|
|||||||
case ${ENV} in
|
case ${ENV} in
|
||||||
"generic")
|
"generic")
|
||||||
format_and_mount
|
format_and_mount
|
||||||
install_grub
|
install_extlinux
|
||||||
/scripts/seed-data $BASE_DIR $CLOUD_CONFIG $FILES
|
/scripts/seed-data ${BASE_DIR} ${CLOUD_CONFIG} ${FILES}
|
||||||
;;
|
;;
|
||||||
"amazon-ebs-pv"|"amazon-ebs-hvm")
|
"amazon-ebs-pv"|"amazon-ebs-hvm")
|
||||||
format_and_mount
|
format_and_mount
|
||||||
if [ "${ENV}" == "amazon-ebs-hvm" ]; then
|
if [ "${ENV}" == "amazon-ebs-hvm" ]; then
|
||||||
install_grub
|
install_extlinux
|
||||||
fi
|
fi
|
||||||
# AWS Networking recommends disabling.
|
# AWS Networking recommends disabling.
|
||||||
/scripts/seed-data $BASE_DIR $CLOUD_CONFIG $FILES
|
/scripts/seed-data ${BASE_DIR} ${CLOUD_CONFIG} ${FILES}
|
||||||
;;
|
;;
|
||||||
"googlecompute")
|
"googlecompute")
|
||||||
format_and_mount
|
format_and_mount
|
||||||
install_grub
|
install_extlinux
|
||||||
/scripts/seed-data $BASE_DIR $CLOUD_CONFIG $FILES
|
/scripts/seed-data ${BASE_DIR} ${CLOUD_CONFIG} ${FILES}
|
||||||
;;
|
;;
|
||||||
"bootstrap")
|
"bootstrap")
|
||||||
mount_device true
|
mount_device true
|
||||||
@ -177,6 +176,6 @@ if [ -n ${ENV} ]; then
|
|||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
grub2_config "${KERNEL_ARGS}"
|
extlinux_config "${KERNEL_ARGS}"
|
||||||
pvgrub_config "${KERNEL_ARGS}"
|
pvgrub_config "${KERNEL_ARGS}"
|
||||||
install_rancher
|
install_rancher
|
||||||
|
@ -39,5 +39,6 @@ p
|
|||||||
1
|
1
|
||||||
|
|
||||||
|
|
||||||
|
a
|
||||||
w
|
w
|
||||||
EOF
|
EOF
|
||||||
|
Loading…
Reference in New Issue
Block a user