mirror of
https://github.com/rancher/os.git
synced 2025-08-10 11:03:16 +00:00
Add noformat and RAID installer types
This commit is contained in:
parent
5987d713a4
commit
2fc1d3fa5f
@ -115,8 +115,8 @@ func runInstall(image, installType, cloudConfig, device, append string, force, r
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cmd := exec.Command("system-docker", "run", "--net=host", "--privileged", "--volumes-from=user-volumes", image,
|
cmd := exec.Command("system-docker", "run", "--net=host", "--privileged", "--volumes-from=user-volumes",
|
||||||
"-d", device, "-t", installType, "-c", cloudConfig, "-a", append)
|
"--volumes-from=command-volumes", image, "-d", device, "-t", installType, "-c", cloudConfig, "-a", append)
|
||||||
cmd.Stdout, cmd.Stderr = os.Stdout, os.Stderr
|
cmd.Stdout, cmd.Stderr = os.Stdout, os.Stderr
|
||||||
if err := cmd.Run(); err != nil {
|
if err := cmd.Run(); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
FROM ubuntu:16.04
|
FROM ubuntu:16.04
|
||||||
ENV DEBIAN_FRONTEND noninteractive
|
ENV DEBIAN_FRONTEND noninteractive
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get install --no-install-recommends -y udev grub2 parted kexec-tools && \
|
apt-get install --no-install-recommends -y udev grub2 parted kexec-tools extlinux syslinux-common && \
|
||||||
rm -rf /var/lib/apt/*
|
rm -rf /var/lib/apt/*
|
||||||
|
|
||||||
COPY ./build/vmlinuz ./build/initrd /dist/
|
COPY ./build/vmlinuz ./build/initrd /dist/
|
||||||
|
@ -27,6 +27,7 @@ DIST=${DIST:-/dist}
|
|||||||
CLOUD_CONFIG=${CLOUD_CONFIG:-"${SCRIPTS_DIR}/conf/empty.yml"}
|
CLOUD_CONFIG=${CLOUD_CONFIG:-"${SCRIPTS_DIR}/conf/empty.yml"}
|
||||||
CONSOLE=tty0
|
CONSOLE=tty0
|
||||||
BASE_DIR="/mnt/new_img"
|
BASE_DIR="/mnt/new_img"
|
||||||
|
BOOT=boot/
|
||||||
# TODO: Change this to a number so that users can specify.
|
# TODO: Change this to a number so that users can specify.
|
||||||
# Will need to make it so that our builds and packer APIs remain consistent.
|
# Will need to make it so that our builds and packer APIs remain consistent.
|
||||||
PARTITION=${PARTITION:=${DEVICE}1}
|
PARTITION=${PARTITION:=${DEVICE}1}
|
||||||
@ -46,18 +47,28 @@ format_device()
|
|||||||
mkfs.ext4 -F -i 4096 -L RANCHER_STATE ${PARTITION}
|
mkfs.ext4 -F -i 4096 -L RANCHER_STATE ${PARTITION}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_dev()
|
||||||
|
{
|
||||||
|
if [ -z "$(which ros)" ]; then
|
||||||
|
lsblk -n -o label $1
|
||||||
|
else
|
||||||
|
ros dev LABEL=${1}
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
mount_device()
|
mount_device()
|
||||||
{
|
{
|
||||||
local label=RANCHER_STATE
|
LABEL=RANCHER_STATE
|
||||||
local raw="${1:-false}"
|
local raw="${1:-false}"
|
||||||
|
|
||||||
mkdir -p ${BASE_DIR}
|
mkdir -p ${BASE_DIR}
|
||||||
|
|
||||||
if [ "$(lsblk -o label|grep RANCHER_BOOT | wc -l)" -gt "0" ]; then
|
if [ -n "$(get_dev RANCHER_BOOT)" ]; then
|
||||||
label=RANCHER_BOOT
|
LABEL=RANCHER_BOOT
|
||||||
|
BOOT=
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local mount_opts="-L ${label}"
|
local mount_opts="-L ${LABEL}"
|
||||||
if [ "${raw}" == "true" ]; then
|
if [ "${raw}" == "true" ]; then
|
||||||
device_defined ${DEVICE}
|
device_defined ${DEVICE}
|
||||||
mount_opts=${PARTITION}
|
mount_opts=${PARTITION}
|
||||||
@ -69,7 +80,21 @@ mount_device()
|
|||||||
|
|
||||||
create_boot_dirs()
|
create_boot_dirs()
|
||||||
{
|
{
|
||||||
mkdir -p ${BASE_DIR}/boot/grub
|
mkdir -p ${BASE_DIR}/${BOOT}grub
|
||||||
|
mkdir -p ${BASE_DIR}/${BOOT}syslinux
|
||||||
|
}
|
||||||
|
|
||||||
|
install_syslinux() {
|
||||||
|
dd bs=440 count=1 if=/usr/lib/syslinux/mbr/mbr.bin of=${DEVICE}
|
||||||
|
cp /usr/lib/syslinux/modules/bios/* ${BASE_DIR}/${BOOT}syslinux
|
||||||
|
extlinux --install ${BASE_DIR}/${BOOT}syslinux
|
||||||
|
}
|
||||||
|
|
||||||
|
install_syslinux_raid() {
|
||||||
|
dd bs=440 count=1 if=/usr/lib/syslinux/mbr/mbr.bin of=/dev/sda
|
||||||
|
dd bs=440 count=1 if=/usr/lib/syslinux/mbr/mbr.bin of=/dev/sdb
|
||||||
|
cp /usr/lib/syslinux/modules/bios/* ${BASE_DIR}/${BOOT}syslinux
|
||||||
|
extlinux --install --raid ${BASE_DIR}/${BOOT}syslinux
|
||||||
}
|
}
|
||||||
|
|
||||||
install_grub() {
|
install_grub() {
|
||||||
@ -77,7 +102,7 @@ install_grub() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
grub2_config(){
|
grub2_config(){
|
||||||
local grub_cfg=${BASE_DIR}/boot/grub/grub.cfg
|
local grub_cfg=${BASE_DIR}/${BOOT}grub/grub.cfg
|
||||||
local append_line="${1}"
|
local append_line="${1}"
|
||||||
cat >${grub_cfg} <<EOF
|
cat >${grub_cfg} <<EOF
|
||||||
set default="0"
|
set default="0"
|
||||||
@ -86,8 +111,8 @@ set timeout="1"
|
|||||||
|
|
||||||
menuentry "RancherOS-current" {
|
menuentry "RancherOS-current" {
|
||||||
set root=(hd0,msdos1)
|
set root=(hd0,msdos1)
|
||||||
linux /boot/vmlinuz-${VERSION}-rancheros ${KERNEL_ARGS} ${append_line}
|
linux /${BOOT}vmlinuz-${VERSION}-rancheros ${KERNEL_ARGS} ${append_line}
|
||||||
initrd /boot/initrd-${VERSION}-rancheros
|
initrd /${BOOT}initrd-${VERSION}-rancheros
|
||||||
}
|
}
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
@ -97,23 +122,48 @@ if [ ! -z ${ROLLBACK_VERSION} ]; then
|
|||||||
cat >>${grub_cfg} <<EOF
|
cat >>${grub_cfg} <<EOF
|
||||||
menuentry "RancherOS-rollback" {
|
menuentry "RancherOS-rollback" {
|
||||||
set root=(hd0,msdos1)
|
set root=(hd0,msdos1)
|
||||||
linux /boot/vmlinuz-${ROLLBACK_VERSION}-rancheros ${KERNEL_ARGS} ${append_line}
|
linux /${BOOT}vmlinuz-${ROLLBACK_VERSION}-rancheros ${KERNEL_ARGS} ${append_line}
|
||||||
initrd /boot/initrd-${ROLLBACK_VERSION}-rancheros
|
initrd /${BOOT}initrd-${ROLLBACK_VERSION}-rancheros
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
syslinux_config(){
|
||||||
|
local syslinux_cfg=${BASE_DIR}/${BOOT}syslinux/syslinux.cfg
|
||||||
|
local append_line="${1}"
|
||||||
|
cat >${syslinux_cfg} <<EOF
|
||||||
|
DEFAULT RancherOS-current
|
||||||
|
|
||||||
|
LABEL RancherOS-current
|
||||||
|
LINUX ../vmlinuz-${VERSION}-rancheros
|
||||||
|
APPEND ${KERNEL_ARGS} ${append_line}
|
||||||
|
INITRD ../initrd-${VERSION}-rancheros
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
if [ ! -z ${ROLLBACK_VERSION} ]; then
|
||||||
|
cat >>${syslinux_cfg} <<EOF
|
||||||
|
LABEL RancherOS-rollback
|
||||||
|
LINUX ../vmlinuz-${ROLLBACK_VERSION}-rancheros
|
||||||
|
APPEND ${KERNEL_ARGS} ${append_line}
|
||||||
|
INITRD ../initrd-${ROLLBACK_VERSION}-rancheros
|
||||||
|
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
install_rancher()
|
install_rancher()
|
||||||
{
|
{
|
||||||
cp ${DIST}/initrd ${BASE_DIR}/boot/initrd-${VERSION}-rancheros
|
cp ${DIST}/initrd ${BASE_DIR}/${BOOT}initrd-${VERSION}-rancheros
|
||||||
cp ${DIST}/vmlinuz ${BASE_DIR}/boot/vmlinuz-${VERSION}-rancheros
|
cp ${DIST}/vmlinuz ${BASE_DIR}/${BOOT}vmlinuz-${VERSION}-rancheros
|
||||||
}
|
}
|
||||||
|
|
||||||
pvgrub_config()
|
pvgrub_config()
|
||||||
{
|
{
|
||||||
local grub_file=${BASE_DIR}/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
|
||||||
@ -124,8 +174,8 @@ hiddenmenu
|
|||||||
|
|
||||||
title RancherOS ${VERSION}-(current)
|
title RancherOS ${VERSION}-(current)
|
||||||
root (hd0)
|
root (hd0)
|
||||||
kernel /boot/vmlinuz-${VERSION}-rancheros ${KERNEL_ARGS} ${append_line}
|
kernel /${BOOT}vmlinuz-${VERSION}-rancheros ${KERNEL_ARGS} ${append_line}
|
||||||
initrd /boot/initrd-${VERSION}-rancheros
|
initrd /${BOOT}initrd-${VERSION}-rancheros
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
@ -134,8 +184,8 @@ if [ ! -z ${ROLLBACK_VERSION} ]; then
|
|||||||
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 ${KERNEL_ARGS} ${append_line}
|
kernel /${BOOT}/vmlinuz-${ROLLBACK_VERSION}-rancheros ${KERNEL_ARGS} ${append_line}
|
||||||
initrd /boot/initrd-${ROLLBACK_VERSION}-rancheros
|
initrd /${BOOT}initrd-${ROLLBACK_VERSION}-rancheros
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -173,6 +223,16 @@ if [ -n ${ENV} ]; then
|
|||||||
install_grub
|
install_grub
|
||||||
"${SCRIPTS_DIR}/seed-data" ${BASE_DIR} ${CLOUD_CONFIG} ${FILES}
|
"${SCRIPTS_DIR}/seed-data" ${BASE_DIR} ${CLOUD_CONFIG} ${FILES}
|
||||||
;;
|
;;
|
||||||
|
"noformat")
|
||||||
|
mount_device
|
||||||
|
create_boot_dirs
|
||||||
|
install_syslinux
|
||||||
|
;;
|
||||||
|
"raid")
|
||||||
|
mount_device
|
||||||
|
create_boot_dirs
|
||||||
|
install_syslinux_raid
|
||||||
|
;;
|
||||||
"bootstrap")
|
"bootstrap")
|
||||||
CONSOLE=ttyS0
|
CONSOLE=ttyS0
|
||||||
mount_device true
|
mount_device true
|
||||||
@ -190,15 +250,16 @@ if [ -n ${ENV} ]; then
|
|||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -e ${BASE_DIR}/boot/append ]; then
|
if [ -e ${BASE_DIR}/${BOOT}append ]; then
|
||||||
PRESERVED_APPEND=$(cat ${BASE_DIR}/boot/append)
|
PRESERVED_APPEND=$(cat ${BASE_DIR}/${BOOT}append)
|
||||||
fi
|
fi
|
||||||
if [ "${APPEND}" = "" ]; then
|
if [ "${APPEND}" = "" ]; then
|
||||||
APPEND="${PRESERVED_APPEND}"
|
APPEND="${PRESERVED_APPEND}"
|
||||||
fi
|
fi
|
||||||
echo "${APPEND}" > ${BASE_DIR}/boot/append
|
echo "${APPEND}" > ${BASE_DIR}/${BOOT}append
|
||||||
|
|
||||||
grub2_config "${APPEND}"
|
grub2_config "${APPEND}"
|
||||||
|
syslinux_config "${APPEND}"
|
||||||
pvgrub_config "${APPEND}"
|
pvgrub_config "${APPEND}"
|
||||||
install_rancher
|
install_rancher
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user