1
0
mirror of https://github.com/rancher/os.git synced 2025-09-19 09:22:40 +00:00

Merge pull request #532 from rancher/revert-524-installer-alpine

Revert "Installer image based on Alpine"
This commit is contained in:
Ivan Mikushin
2015-08-27 15:02:01 +05:00
4 changed files with 50 additions and 47 deletions

View File

@@ -1,8 +1,9 @@
FROM alpine
RUN apk update && apk add coreutils util-linux bash parted syslinux e2fsprogs
FROM debian:jessie
COPY ./scripts/installer /scripts
COPY ./scripts/version /scripts/
RUN /scripts/bootstrap
COPY ./dist/artifacts/vmlinuz ./dist/artifacts/initrd /dist/
COPY ./dist/artifacts/vmlinuz /dist/vmlinuz
COPY ./dist/artifacts/initrd /dist/initrd
ENTRYPOINT ["/scripts/lay-down-os"]

6
scripts/installer/bootstrap Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y grub2 parted

View File

@@ -2,11 +2,10 @@
set -e -x
. $(dirname $0)/version
VERSION=${VERSION:?"VERSION not set"}
while getopts "i:f:c:d:t:r:o:p:" OPTION
do
case ${OPTION} in
case $OPTION in
i) DIST="$OPTARG" ;;
f) FILES="$OPTARG" ;;
c) CLOUD_CONFIG="$OPTARG" ;;
@@ -21,7 +20,6 @@ done
DIST=${DIST:-/dist}
CLOUD_CONFIG=${CLOUD_CONFIG:-/scripts/conf/empty.yml}
CONSOLE=tty0
BASE_DIR="/mnt/new_img"
# 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.
@@ -58,41 +56,43 @@ mount_device()
mount_opts=${PARTITION}
fi
mount ${mount_opts} ${BASE_DIR}
mount $mount_opts ${BASE_DIR}
trap "umount ${BASE_DIR}" EXIT
}
create_boot_dirs()
{
mkdir -p ${BASE_DIR}/boot/grub
mkdir -p ${BASE_DIR}/boot/extlinux
}
install_extlinux() {
extlinux -i ${BASE_DIR}/boot/extlinux
dd if=/usr/share/syslinux/mbr.bin of=${DEVICE}
install_grub() {
grub-install --boot-directory=${BASE_DIR}/boot ${DEVICE}
}
extlinux_config(){
local extlinux_conf=${BASE_DIR}/boot/extlinux/extlinux.conf
grub2_config(){
local grub_cfg=${BASE_DIR}/boot/grub/grub.cfg
local append_line="${1}"
cat >${extlinux_conf} <<EOF
default ros
label ros
kernel /boot/vmlinuz-${VERSION}-rancheros
initrd /boot/initrd-${VERSION}-rancheros
append ${append_line} console=${CONSOLE}
cat >$grub_cfg <<EOF
set default="0"
set timeout="1"
#set fallback=1
menuentry "RancherOS-current" {
set root=(hd0,msdos1)
linux /boot/vmlinuz-${VERSION}-rancheros ${append_line} console=ttyS0 console=tty0
initrd /boot/initrd-${VERSION}-rancheros
}
EOF
if [ ! -z ${ROLLBACK_VERSION} ]; then
sed -i 's/^#set/set/' ${extlinux_conf}
cat >>${extlinux_conf} <<EOF
label ros-fallback
kernel /boot/vmlinuz-${ROLLBACK_VERSION}-rancheros
initrd /boot/initrd-${ROLLBACK_VERSION}-rancheros
append ${append_line} console=${CONSOLE}
if [ ! -z $ROLLBACK_VERSION ]; then
sed -i 's/^#set/set/' ${grub_cfg}
cat >>$grub_cfg <<EOF
menuentry "RancherOS-rollback" {
set root=(hd0,msdos1)
linux /boot/vmlinuz-${ROLLBACK_VERSION}-rancheros ${append_line} console=ttyS0 console=tty0
initrd /boot/initrd-${ROLLBACK_VERSION}-rancheros
}
EOF
fi
@@ -100,15 +100,15 @@ fi
install_rancher()
{
cp ${DIST}/initrd ${BASE_DIR}/boot/initrd-${VERSION}-rancheros
cp ${DIST}/vmlinuz ${BASE_DIR}/boot/vmlinuz-${VERSION}-rancheros
cp ${DIST}/initrd /mnt/new_img/boot/initrd-${VERSION}-rancheros
cp ${DIST}/vmlinuz /mnt/new_img/boot/vmlinuz-${VERSION}-rancheros
}
pvgrub_config()
{
local grub_file=${BASE_DIR}/boot/grub/menu.lst
local grub_file=/mnt/new_img/boot/grub/menu.lst
local append_line="${1}"
cat > ${grub_file}<<EOF
cat > $grub_file<<EOF
default 0
timeout 0
#fallback 1
@@ -117,17 +117,17 @@ hiddenmenu
title RancherOS ${VERSION}-(current)
root (hd0)
kernel /boot/vmlinuz-${VERSION}-rancheros ${append_line} console=${CONSOLE}
kernel /boot/vmlinuz-${VERSION}-rancheros ${append_line} console=ttyS0 console=tty0
initrd /boot/initrd-${VERSION}-rancheros
EOF
if [ ! -z ${ROLLBACK_VERSION} ]; then
sed -i 's/^#\(fallback\)/\1/' ${grub_file}
cat >> ${grub_file}<<EOF
if [ ! -z $ROLLBACK_VERSION ]; then
sed -i 's/^#\(fallback\)/\1/' $grub_file
cat >> $grub_file<<EOF
title RancherOS ${ROLLBACK_VERSION}-(rollback)
root (hd0)
kernel /boot/vmlinuz-${ROLLBACK_VERSION}-rancheros ${append_line} console=${CONSOLE}
kernel /boot/vmlinuz-${ROLLBACK_VERSION}-rancheros ${append_line} console=ttyS0 console=tty0
initrd /boot/initrd-${ROLLBACK_VERSION}-rancheros
EOF
fi
@@ -145,26 +145,23 @@ if [ -n ${ENV} ]; then
case ${ENV} in
"generic")
format_and_mount
install_extlinux
/scripts/seed-data ${BASE_DIR} ${CLOUD_CONFIG} ${FILES}
install_grub
/scripts/seed-data $BASE_DIR $CLOUD_CONFIG $FILES
;;
"amazon-ebs-pv"|"amazon-ebs-hvm")
CONSOLE=ttyS0
format_and_mount
if [ "${ENV}" == "amazon-ebs-hvm" ]; then
install_extlinux
install_grub
fi
# AWS Networking recommends disabling.
/scripts/seed-data ${BASE_DIR} ${CLOUD_CONFIG} ${FILES}
/scripts/seed-data $BASE_DIR $CLOUD_CONFIG $FILES
;;
"googlecompute")
CONSOLE=ttyS0
format_and_mount
install_extlinux
/scripts/seed-data ${BASE_DIR} ${CLOUD_CONFIG} ${FILES}
install_grub
/scripts/seed-data $BASE_DIR $CLOUD_CONFIG $FILES
;;
"bootstrap")
CONSOLE=ttyS0
mount_device true
create_boot_dirs
KERNEL_ARGS="${KERNEL_ARGS} rancher.cloud_init.datasources=[ec2,gce]"
@@ -180,6 +177,6 @@ if [ -n ${ENV} ]; then
esac
fi
extlinux_config "${KERNEL_ARGS}"
grub2_config "${KERNEL_ARGS}"
pvgrub_config "${KERNEL_ARGS}"
install_rancher

View File

@@ -39,6 +39,5 @@ p
1
a
w
EOF