From bee6675b36fce42a471cabd70de3e4785bbbf527 Mon Sep 17 00:00:00 2001 From: Bill Maxwell Date: Thu, 12 Mar 2015 14:10:25 -0700 Subject: [PATCH] Set defaults based off of RanchOS info If running on RancherOS gather sane defaults for users. --- .../dockerimages/scripts/rancheros-install | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/scripts/dockerimages/scripts/rancheros-install b/scripts/dockerimages/scripts/rancheros-install index 36c1b36e..624987c7 100755 --- a/scripts/dockerimages/scripts/rancheros-install +++ b/scripts/dockerimages/scripts/rancheros-install @@ -13,7 +13,7 @@ Options: -d device -f [ DANGEROUS! Data loss can happen ] partition/format without prompting -t install-type: - generic: Creates 1 ext4 partition and installs RancherOS + generic: (Default) Creates 1 ext4 partition and installs RancherOS amazon-ebs: Installs RancherOS and sets up PV-GRUB -v os-installer version. -h print this @@ -21,17 +21,24 @@ EOF } PARTITION_FLAG="false" -INSTALLER_VERSION="latest" -EXTRA_ARGS= INSTALL_CONTAINER_IMAGE="rancher/os" +if [ -x /usr/bin/rancherctl ]; then + INSTALL_CONTAINER_IMAGE="$(rancherctl config get upgrade.image)" +fi + +if [ -n "$(grep RancherOS /etc/lsb-release)" ]; then + INSTALLER_VERSION=$(grep DISTRIB_RELEASE /etc/lsb-release|cut -d'=' -f2) +fi + +EXTRA_ARGS= + while getopts "c:d:ft:v:h" OPTION do case $OPTION in c) CLOUD_CONFIG="$OPTARG" ;; d) DEVICE="$OPTARG" ;; f) FORCE_INSTALL="true" ;; - # p) PARTITION_FLAG="true" ;; t) INSTALL_TYPE="${OPTARG}" ;; v) INSTALLER_VERSION="$OPTARG" ;; h) usage; exit ;; @@ -45,8 +52,8 @@ if [ "$(whoami)" != "root" ]; then fi if [[ -z "${INSTALL_TYPE}" ]]; then - echo "$0: No install type specified, -t required to install" 1>&2 - exit 1 + echo "No install type specified...defaulting to generic" + INSTALL_TYPE="generic" fi if [ -z "${CLOUD_CONFIG}" ] && [ "${INSTALL_TYPE}" != "amazon-ebs" ]; then @@ -54,6 +61,11 @@ if [ -z "${CLOUD_CONFIG}" ] && [ "${INSTALL_TYPE}" != "amazon-ebs" ]; then exit 1 fi +if [[ -z "${DEVICE}" ]]; then + echo "$0: No device defined. Can not proceed without -d specified" 1>&2 + exit 1 +fi + if [ "${INSTALL_TYPE}" == "generic" ]; then PARTITION_FLAG="true" fi