From ad139d44f72ea1d0a351410aa8f938b5c5fb4630 Mon Sep 17 00:00:00 2001 From: "Heinz N. Gies" Date: Fri, 9 Aug 2013 00:05:55 +0200 Subject: [PATCH 01/10] Added raid10+2 as profile option. --- smartdc/bin/smartos_prompt_config.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/smartdc/bin/smartos_prompt_config.sh b/smartdc/bin/smartos_prompt_config.sh index e89997c..16e70c1 100644 --- a/smartdc/bin/smartos_prompt_config.sh +++ b/smartdc/bin/smartos_prompt_config.sh @@ -389,7 +389,7 @@ setup_datasets() zfs create -V ${size}mb ${SWAPVOL} swap -a /dev/zvol/dsk/${SWAPVOL} fi - printf "%4s\n" "done" + printf "%4s\n" "done" fi } @@ -405,7 +405,7 @@ create_zpool() fi disk_count=$(echo "${disks}" | wc -w | tr -d ' ') - printf "%-56s" "Creating pool $pool... " + printf "%-56s" "Creating pool $pool... " # If no pool profile was provided, use a default based on the number of # devices in that pool. @@ -435,6 +435,16 @@ create_zpool() zpool_args="${zpool_args} ${disk}" ii=$(($ii + 1)) done + elif [[ ${profile} == "raid10+2" ]] + for disk in ${disks}; do + if [[ $(( $ii % 2 )) -eq 0 ]]; then + zpool_args="${zpool_args} ${profile}" + fi + zpool_args="${zpool_args} ${disk}" + ii=$(($ii + 1)) + done + # Replace the last mirror with spares so we get two spare disks + zpool_args=$(echo "${zpool_args}" | sed 's/\(.*\)mirror/\1spare/') else zpool_args="${profile} ${disks}" fi @@ -444,7 +454,7 @@ create_zpool() zfs set atime=off ${pool} || \ fatal "failed to set atime=off for pool ${pool}" - printf "%4s\n" "done" + printf "%4s\n" "done" } create_zpools() { @@ -463,7 +473,7 @@ create_zpools() export VARDS=${SYS_ZPOOL}/var export USBKEYDS=${SYS_ZPOOL}/usbkey export SWAPVOL=${SYS_ZPOOL}/swap - + setup_datasets # # Since there may be more than one storage pool on the system, put a From 4dbdb5fdc6557bd08d404d3e0665e2cea4b941b0 Mon Sep 17 00:00:00 2001 From: "Heinz N. Gies" Date: Fri, 9 Aug 2013 00:08:03 +0200 Subject: [PATCH 02/10] Removed tailing whitespaces. --- smartdc/bin/smartos_prompt_config.sh | 50 ++++++++++++++-------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/smartdc/bin/smartos_prompt_config.sh b/smartdc/bin/smartos_prompt_config.sh index 16e70c1..8b33636 100644 --- a/smartdc/bin/smartos_prompt_config.sh +++ b/smartdc/bin/smartos_prompt_config.sh @@ -242,7 +242,7 @@ promptpw() else break fi - else + else echo "A value must be provided." fi done @@ -293,7 +293,7 @@ promptpool() break fi done - + } create_dump() @@ -319,50 +319,50 @@ create_dump() setup_datasets() { datasets=$(zfs list -H -o name | xargs) - + if ! echo $datasets | grep dump > /dev/null; then - printf "%-56s" "Making dump zvol... " + printf "%-56s" "Making dump zvol... " create_dump - printf "%4s\n" "done" + printf "%4s\n" "done" fi if ! echo $datasets | grep ${CONFDS} > /dev/null; then - printf "%-56s" "Initializing config dataset for zones... " + printf "%-56s" "Initializing config dataset for zones... " zfs create ${CONFDS} || fatal "failed to create the config dataset" chmod 755 /${CONFDS} cp -p /etc/zones/* /${CONFDS} zfs set mountpoint=legacy ${CONFDS} - printf "%4s\n" "done" + printf "%4s\n" "done" fi if ! echo $datasets | grep ${USBKEYDS} > /dev/null; then if [[ -n $(/bin/bootparams | grep "^smartos=true") ]]; then - printf "%-56s" "Creating config dataset... " + printf "%-56s" "Creating config dataset... " zfs create -o mountpoint=legacy ${USBKEYDS} || \ fatal "failed to create the config dataset" mkdir /usbkey mount -F zfs ${USBKEYDS} /usbkey - printf "%4s\n" "done" + printf "%4s\n" "done" fi fi if ! echo $datasets | grep ${COREDS} > /dev/null; then - printf "%-56s" "Creating global cores dataset... " + printf "%-56s" "Creating global cores dataset... " zfs create -o quota=10g -o mountpoint=/${SYS_ZPOOL}/global/cores \ -o compression=gzip ${COREDS} || \ fatal "failed to create the cores dataset" - printf "%4s\n" "done" + printf "%4s\n" "done" fi if ! echo $datasets | grep ${OPTDS} > /dev/null; then - printf "%-56s" "Creating opt dataset... " + printf "%-56s" "Creating opt dataset... " zfs create -o mountpoint=legacy ${OPTDS} || \ fatal "failed to create the opt dataset" - printf "%4s\n" "done" + printf "%4s\n" "done" fi if ! echo $datasets | grep ${VARDS} > /dev/null; then - printf "%-56s" "Initializing var dataset... " + printf "%-56s" "Initializing var dataset... " zfs create ${VARDS} || \ fatal "failed to create the var dataset" chmod 755 /${VARDS} @@ -374,7 +374,7 @@ setup_datasets() zfs set mountpoint=legacy ${VARDS} if ! echo $datasets | grep ${SWAPVOL} > /dev/null; then - printf "%-56s" "Creating swap zvol... " + printf "%-56s" "Creating swap zvol... " # # We cannot allow the swap size to be less than the size of DRAM, lest$ # we run into the availrmem double accounting issue for locked$ @@ -490,16 +490,16 @@ updatenicstates() done < <(dladm show-phys -po link,state 2>/dev/null) } -printheader() +printheader() { local newline= local cols=`tput cols` local subheader=$1 - + if [ $cols -gt 80 ] ;then newline='\n' fi - + clear for i in {1..80} ; do printf "-" ; done && printf "$newline" printf " %-40s\n" "SmartOS Setup" @@ -553,8 +553,8 @@ fi # while [ /usr/bin/true ]; do - printheader "Networking" - + printheader "Networking" + promptnic "'admin'" admin_nic="$val" @@ -566,7 +566,7 @@ while [ /usr/bin/true ]; do printheader "Networking - Continued" message="" - + printf "$message" message=" @@ -586,18 +586,18 @@ while [ /usr/bin/true ]; do domainname="$val" promptval "Default DNS search domain" "$dns_domain" dns_domain="$val" - fi + fi printheader "Storage" promptpool - + printheader "Account Information" - + promptpw "Enter root password" "nolen" root_shadow="$val" printheader "Verify Configuration" message="" - + printf "$message" echo "Verify that the following values are correct:" From b95116363faa4f5b8696b1b087958dfec3ebbf29 Mon Sep 17 00:00:00 2001 From: "Heinz N. Gies" Date: Fri, 9 Aug 2013 00:13:45 +0200 Subject: [PATCH 03/10] Added option to use all disks for a zpool. --- smartdc/bin/smartos_prompt_config.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/smartdc/bin/smartos_prompt_config.sh b/smartdc/bin/smartos_prompt_config.sh index e89997c..3277d99 100644 --- a/smartdc/bin/smartos_prompt_config.sh +++ b/smartdc/bin/smartos_prompt_config.sh @@ -271,6 +271,7 @@ promptpool() echo "Please select disks for the storage pool, space separated" echo "" printf "Valid choices are ${disks}" + printf "or 'all' for all the above" echo "" bad="" read val @@ -279,6 +280,10 @@ promptpool() echo "" continue fi + if [[ $val == "all" ]]; then + DISK_LIST="${disks}" + break + fi for disk in $(echo $val | tr " " "\n"); do if [[ -z $disk ]]; then continue; fi; echo $disks | grep $disk 1>&2 > /dev/null From 0e15110cfe00678549b617e51bd360104d55b172 Mon Sep 17 00:00:00 2001 From: "Heinz N. Gies" Date: Fri, 9 Aug 2013 01:40:18 +0200 Subject: [PATCH 04/10] Put in some kernel parameters. --- smartdc/bin/smartos_prompt_config.sh | 157 ++++++++++++++++++--------- 1 file changed, 104 insertions(+), 53 deletions(-) diff --git a/smartdc/bin/smartos_prompt_config.sh b/smartdc/bin/smartos_prompt_config.sh index df59ed3..0ec3551 100644 --- a/smartdc/bin/smartos_prompt_config.sh +++ b/smartdc/bin/smartos_prompt_config.sh @@ -23,6 +23,20 @@ declare -a nics declare -a assigned declare -a DISK_LIST + +get_bootparam() +{ + param=$1 + params=$(/bin/bootparams) + # Try to lookup the boot param value + val=$(echo $params | sed "s/^\(.*,\)*${param}=\([^,]*\).*$/\2/") + # If we don't match the entire string is returned so we empty var + if [[ $val == $params ]] + then + val="" + fi +} + sigexit() { echo @@ -274,7 +288,8 @@ promptpool() printf "or 'all' for all the above" echo "" bad="" - read val + get_bootparam "disks" + [ -z "${val}" ] && read val if [[ $val == "" ]]; then echo "At least one disk must be specified" echo "" @@ -412,12 +427,19 @@ create_zpool() disk_count=$(echo "${disks}" | wc -w | tr -d ' ') printf "%-56s" "Creating pool $pool... " + if [[ "${disk_count}" == "0" ]] + then + fatal "no disks found, can't create zpool" + fi + + # Readthe pool_profile from boot params + get_bootparam "pool_profile" + profile="${val}" + # If no pool profile was provided, use a default based on the number of # devices in that pool. if [[ -z ${profile} ]]; then case ${disk_count} in - 0) - fatal "no disks found, can't create zpool";; 1) profile="";; 2) @@ -432,26 +454,27 @@ create_zpool() # When creating a mirrored pool, create a mirrored pair of devices out of # every two disks. if [[ ${profile} == "mirror" ]]; then - ii=0 - for disk in ${disks}; do - if [[ $(( $ii % 2 )) -eq 0 ]]; then - zpool_args="${zpool_args} ${profile}" - fi - zpool_args="${zpool_args} ${disk}" - ii=$(($ii + 1)) - done + ii=0 + for disk in ${disks}; do + if [[ $(( $ii % 2 )) -eq 0 ]]; then + zpool_args="${zpool_args} ${profile}" + fi + zpool_args="${zpool_args} ${disk}" + ii=$(($ii + 1)) + done elif [[ ${profile} == "raid10+2" ]] - for disk in ${disks}; do - if [[ $(( $ii % 2 )) -eq 0 ]]; then - zpool_args="${zpool_args} ${profile}" - fi - zpool_args="${zpool_args} ${disk}" - ii=$(($ii + 1)) - done - # Replace the last mirror with spares so we get two spare disks - zpool_args=$(echo "${zpool_args}" | sed 's/\(.*\)mirror/\1spare/') + then + for disk in ${disks}; do + if [[ $(( $ii % 2 )) -eq 0 ]]; then + zpool_args="${zpool_args} ${profile}" + fi + zpool_args="${zpool_args} ${disk}" + ii=$(($ii + 1)) + done + # Replace the last mirror with spares so we get two spare disks + zpool_args=$(echo "${zpool_args}" | sed 's/\(.*\)mirror/\1spare/') else - zpool_args="${profile} ${disks}" + zpool_args="${profile} ${disks}" fi zpool create -f ${pool} ${zpool_args} || \ @@ -461,6 +484,7 @@ create_zpool() printf "%4s\n" "done" } + create_zpools() { devs=$1 @@ -486,6 +510,7 @@ create_zpools() # touch /${SYS_ZPOOL}/.system_pool } + updatenicstates() { states=(1) @@ -558,20 +583,22 @@ fi # while [ /usr/bin/true ]; do - printheader "Networking" + printheader "Networking" - promptnic "'admin'" - admin_nic="$val" + get_bootparam "admin_nic" + [ -z $val ] && promptnic "'admin'" + admin_nic="$val" - promptnet "IP address (or 'dhcp' )" "$admin_ip" - admin_ip="$val" + get_bootparam "admin_ip" + [ -z $val ] && promptnet "IP address (or 'dhcp' )" "$admin_ip" + admin_ip="$val" if [[ $admin_ip != 'dhcp' ]]; then - promptnet "netmask" "$admin_netmask" + get_bootparam "admin_netmask" + [ -z $val ] && promptnet "netmask" "$admin_netmask" admin_netmask="$val" printheader "Networking - Continued" message="" - printf "$message" message=" @@ -580,35 +607,45 @@ while [ /usr/bin/true ]; do printf "$message" - promptnet "Enter the default gateway IP" "$headnode_default_gateway" + get_bootparam "gateway" + [ -z $val ] && promptnet "Enter the default gateway IP" "$headnode_default_gateway" headnode_default_gateway="$val" - promptval "Enter the Primary DNS server IP" "$dns_resolver1" + get_bootparam "dns1" + [ -z $val ] && promptval "Enter the Primary DNS server IP" "$dns_resolver1" dns_resolver1="$val" - promptval "Enter the Secondary DNS server IP" "$dns_resolver2" + get_bootparam "dns2" + [ -z $val ] && promptval "Enter the Secondary DNS server IP" "$dns_resolver2" dns_resolver2="$val" - promptval "Enter the domain name" "$domainname" + get_bootparam "domain" + [ -z $val ] && promptval "Enter the domain name" "$domainname" domainname="$val" - promptval "Default DNS search domain" "$dns_domain" + get_bootparam "search_domain" + [ -z $val ] && promptval "Default DNS search domain" "$dns_domain" dns_domain="$val" fi - printheader "Storage" - promptpool + printheader "Storage" + promptpool - printheader "Account Information" + printheader "Account Information" - promptpw "Enter root password" "nolen" - root_shadow="$val" + get_bootparam "root_pw" + if [[ "${val}" == "random" ]] + then + val=$(cat /dev/urandom | LC_CTYPE=C tr -dc '[:alpha:]0-9$:_+-' | fold -w 32 | head -n 1) + fi + [ -z "${val}" ] && promptpw "Enter root password" "nolen" + root_shadow="$val" - printheader "Verify Configuration" - message="" + printheader "Verify Configuration" + message="" - printf "$message" + printf "$message" - echo "Verify that the following values are correct:" - echo - echo "MAC address: $admin_nic" - echo "IP address: $admin_ip" + echo "Verify that the following values are correct:" + echo + echo "MAC address: $admin_nic" + echo "IP address: $admin_ip" if [[ $admin_ip != 'dhcp' ]]; then echo "Netmask: $admin_netmask" echo "Gateway router IP address: $headnode_default_gateway" @@ -618,9 +655,14 @@ while [ /usr/bin/true ]; do echo "Domain name: $domainname" echo fi - promptval "Is this correct?" "y" - [ "$val" == "y" ] && break - clear + get_bootparam "unattended" + if [[ "${val}" == "true" ]] + then + break; + fi + promptval "Is this correct?" "y" + [ "$val" == "y" ] && break + clear done admin_network="$net_a.$net_b.$net_c.$net_d" @@ -665,9 +707,14 @@ echo "compute_node_ntp_hosts=$admin_ip" >>$tmp_config echo >>$tmp_config echo -echo "Your configuration is about to be applied." -promptval "Would you like to edit the final configuration file?" "n" -[ "$val" == "y" ] && vi $tmp_config +get_bootparam "unattended" +if [[ "${val}" != "true" ]] +then + echo "Your configuration is about to be applied." + promptval "Would you like to edit the final configuration file?" "n" + [ "$val" == "y" ] && vi $tmp_config +fi + clear echo @@ -676,8 +723,12 @@ echo $DISK_LIST echo "*********************************************" echo "* This will erase *ALL DATA* on these disks *" echo "*********************************************" -promptval "are you sure?" "n" -[ "$val" == "y" ] && (create_zpools "$DISK_LIST") +get_bootparam "unattended" +if [[ "${val}" != "true" ]] +then + promptval "are you sure?" "n" + [ "$val" == "y" ] && (create_zpools "$DISK_LIST") +fi clear echo "The system will now finish configuration and reboot. Please wait..." From f4b27964dedd3e185cf94f142d41e098b8995a77 Mon Sep 17 00:00:00 2001 From: "Heinz N. Gies" Date: Sat, 10 Aug 2013 03:46:15 +0200 Subject: [PATCH 05/10] Fixed way the boot params were read. --- smartdc/bin/smartos_prompt_config.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/smartdc/bin/smartos_prompt_config.sh b/smartdc/bin/smartos_prompt_config.sh index 0ec3551..13f70dc 100644 --- a/smartdc/bin/smartos_prompt_config.sh +++ b/smartdc/bin/smartos_prompt_config.sh @@ -23,17 +23,17 @@ declare -a nics declare -a assigned declare -a DISK_LIST - +# +# Reads a boot parameters returns the assigned value for a given key. +# If the key is not found an empty string is returned. +# The data is stored in $val. +# get_bootparam() { - param=$1 - params=$(/bin/bootparams) - # Try to lookup the boot param value - val=$(echo $params | sed "s/^\(.*,\)*${param}=\([^,]*\).*$/\2/") - # If we don't match the entire string is returned so we empty var - if [[ $val == $params ]] + val="" + if /bin/bootparams | grep "^$1=" > /dev/null 2>&1 then - val="" + val=$(/bin/bootparams | grep "^$1=" | sed "s/^$1=//") fi } From 6215aab01e762a617ec6a93381b5d186063e6c2a Mon Sep 17 00:00:00 2001 From: "Heinz N. Gies" Date: Sat, 10 Aug 2013 16:19:19 +0200 Subject: [PATCH 06/10] Split attended and unattended config. --- lib/svc/method/smartdc-config | 8 +- smartdc/bin/smartos_prompt_config.sh | 212 ++++-------- smartdc/bin/smartos_unattended_config.sh | 424 +++++++++++++++++++++++ 3 files changed, 503 insertions(+), 141 deletions(-) create mode 100644 smartdc/bin/smartos_unattended_config.sh diff --git a/lib/svc/method/smartdc-config b/lib/svc/method/smartdc-config index 36ba5b4..5094650 100644 --- a/lib/svc/method/smartdc-config +++ b/lib/svc/method/smartdc-config @@ -105,8 +105,12 @@ case "$1" in exit $SMF_EXIT_OK fi - /smartdc/bin/smartos_prompt_config.sh "${USB_PATH}" \ - &/dev/console + if /bin/bootparams | grep "^unattended=true" > /dev/null 2>&1; then + /smartdc/bin/smartos_unattended_config.sh "${USB_PATH}" + else + /smartdc/bin/smartos_prompt_config.sh "${USB_PATH}" \ + &/dev/console + fi # If user quit from interactive configuration then we're done. [[ ! -f ${USB_PATH}/config ]] && exit $SMF_EXIT_OK diff --git a/smartdc/bin/smartos_prompt_config.sh b/smartdc/bin/smartos_prompt_config.sh index 13f70dc..e89997c 100644 --- a/smartdc/bin/smartos_prompt_config.sh +++ b/smartdc/bin/smartos_prompt_config.sh @@ -23,20 +23,6 @@ declare -a nics declare -a assigned declare -a DISK_LIST -# -# Reads a boot parameters returns the assigned value for a given key. -# If the key is not found an empty string is returned. -# The data is stored in $val. -# -get_bootparam() -{ - val="" - if /bin/bootparams | grep "^$1=" > /dev/null 2>&1 - then - val=$(/bin/bootparams | grep "^$1=" | sed "s/^$1=//") - fi -} - sigexit() { echo @@ -256,7 +242,7 @@ promptpw() else break fi - else + else echo "A value must be provided." fi done @@ -285,20 +271,14 @@ promptpool() echo "Please select disks for the storage pool, space separated" echo "" printf "Valid choices are ${disks}" - printf "or 'all' for all the above" echo "" bad="" - get_bootparam "disks" - [ -z "${val}" ] && read val + read val if [[ $val == "" ]]; then echo "At least one disk must be specified" echo "" continue fi - if [[ $val == "all" ]]; then - DISK_LIST="${disks}" - break - fi for disk in $(echo $val | tr " " "\n"); do if [[ -z $disk ]]; then continue; fi; echo $disks | grep $disk 1>&2 > /dev/null @@ -313,7 +293,7 @@ promptpool() break fi done - + } create_dump() @@ -339,50 +319,50 @@ create_dump() setup_datasets() { datasets=$(zfs list -H -o name | xargs) - + if ! echo $datasets | grep dump > /dev/null; then - printf "%-56s" "Making dump zvol... " + printf "%-56s" "Making dump zvol... " create_dump - printf "%4s\n" "done" + printf "%4s\n" "done" fi if ! echo $datasets | grep ${CONFDS} > /dev/null; then - printf "%-56s" "Initializing config dataset for zones... " + printf "%-56s" "Initializing config dataset for zones... " zfs create ${CONFDS} || fatal "failed to create the config dataset" chmod 755 /${CONFDS} cp -p /etc/zones/* /${CONFDS} zfs set mountpoint=legacy ${CONFDS} - printf "%4s\n" "done" + printf "%4s\n" "done" fi if ! echo $datasets | grep ${USBKEYDS} > /dev/null; then if [[ -n $(/bin/bootparams | grep "^smartos=true") ]]; then - printf "%-56s" "Creating config dataset... " + printf "%-56s" "Creating config dataset... " zfs create -o mountpoint=legacy ${USBKEYDS} || \ fatal "failed to create the config dataset" mkdir /usbkey mount -F zfs ${USBKEYDS} /usbkey - printf "%4s\n" "done" + printf "%4s\n" "done" fi fi if ! echo $datasets | grep ${COREDS} > /dev/null; then - printf "%-56s" "Creating global cores dataset... " + printf "%-56s" "Creating global cores dataset... " zfs create -o quota=10g -o mountpoint=/${SYS_ZPOOL}/global/cores \ -o compression=gzip ${COREDS} || \ fatal "failed to create the cores dataset" - printf "%4s\n" "done" + printf "%4s\n" "done" fi if ! echo $datasets | grep ${OPTDS} > /dev/null; then - printf "%-56s" "Creating opt dataset... " + printf "%-56s" "Creating opt dataset... " zfs create -o mountpoint=legacy ${OPTDS} || \ fatal "failed to create the opt dataset" - printf "%4s\n" "done" + printf "%4s\n" "done" fi if ! echo $datasets | grep ${VARDS} > /dev/null; then - printf "%-56s" "Initializing var dataset... " + printf "%-56s" "Initializing var dataset... " zfs create ${VARDS} || \ fatal "failed to create the var dataset" chmod 755 /${VARDS} @@ -394,7 +374,7 @@ setup_datasets() zfs set mountpoint=legacy ${VARDS} if ! echo $datasets | grep ${SWAPVOL} > /dev/null; then - printf "%-56s" "Creating swap zvol... " + printf "%-56s" "Creating swap zvol... " # # We cannot allow the swap size to be less than the size of DRAM, lest$ # we run into the availrmem double accounting issue for locked$ @@ -409,7 +389,7 @@ setup_datasets() zfs create -V ${size}mb ${SWAPVOL} swap -a /dev/zvol/dsk/${SWAPVOL} fi - printf "%4s\n" "done" + printf "%4s\n" "done" fi } @@ -425,21 +405,14 @@ create_zpool() fi disk_count=$(echo "${disks}" | wc -w | tr -d ' ') - printf "%-56s" "Creating pool $pool... " - - if [[ "${disk_count}" == "0" ]] - then - fatal "no disks found, can't create zpool" - fi - - # Readthe pool_profile from boot params - get_bootparam "pool_profile" - profile="${val}" + printf "%-56s" "Creating pool $pool... " # If no pool profile was provided, use a default based on the number of # devices in that pool. if [[ -z ${profile} ]]; then case ${disk_count} in + 0) + fatal "no disks found, can't create zpool";; 1) profile="";; 2) @@ -454,27 +427,16 @@ create_zpool() # When creating a mirrored pool, create a mirrored pair of devices out of # every two disks. if [[ ${profile} == "mirror" ]]; then - ii=0 - for disk in ${disks}; do - if [[ $(( $ii % 2 )) -eq 0 ]]; then - zpool_args="${zpool_args} ${profile}" - fi - zpool_args="${zpool_args} ${disk}" - ii=$(($ii + 1)) - done - elif [[ ${profile} == "raid10+2" ]] - then - for disk in ${disks}; do - if [[ $(( $ii % 2 )) -eq 0 ]]; then - zpool_args="${zpool_args} ${profile}" - fi - zpool_args="${zpool_args} ${disk}" - ii=$(($ii + 1)) - done - # Replace the last mirror with spares so we get two spare disks - zpool_args=$(echo "${zpool_args}" | sed 's/\(.*\)mirror/\1spare/') + ii=0 + for disk in ${disks}; do + if [[ $(( $ii % 2 )) -eq 0 ]]; then + zpool_args="${zpool_args} ${profile}" + fi + zpool_args="${zpool_args} ${disk}" + ii=$(($ii + 1)) + done else - zpool_args="${profile} ${disks}" + zpool_args="${profile} ${disks}" fi zpool create -f ${pool} ${zpool_args} || \ @@ -482,9 +444,8 @@ create_zpool() zfs set atime=off ${pool} || \ fatal "failed to set atime=off for pool ${pool}" - printf "%4s\n" "done" + printf "%4s\n" "done" } - create_zpools() { devs=$1 @@ -502,7 +463,7 @@ create_zpools() export VARDS=${SYS_ZPOOL}/var export USBKEYDS=${SYS_ZPOOL}/usbkey export SWAPVOL=${SYS_ZPOOL}/swap - + setup_datasets # # Since there may be more than one storage pool on the system, put a @@ -510,7 +471,6 @@ create_zpools() # touch /${SYS_ZPOOL}/.system_pool } - updatenicstates() { states=(1) @@ -520,16 +480,16 @@ updatenicstates() done < <(dladm show-phys -po link,state 2>/dev/null) } -printheader() +printheader() { local newline= local cols=`tput cols` local subheader=$1 - + if [ $cols -gt 80 ] ;then newline='\n' fi - + clear for i in {1..80} ; do printf "-" ; done && printf "$newline" printf " %-40s\n" "SmartOS Setup" @@ -583,22 +543,20 @@ fi # while [ /usr/bin/true ]; do - printheader "Networking" - - get_bootparam "admin_nic" - [ -z $val ] && promptnic "'admin'" - admin_nic="$val" + printheader "Networking" + + promptnic "'admin'" + admin_nic="$val" - get_bootparam "admin_ip" - [ -z $val ] && promptnet "IP address (or 'dhcp' )" "$admin_ip" - admin_ip="$val" + promptnet "IP address (or 'dhcp' )" "$admin_ip" + admin_ip="$val" if [[ $admin_ip != 'dhcp' ]]; then - get_bootparam "admin_netmask" - [ -z $val ] && promptnet "netmask" "$admin_netmask" + promptnet "netmask" "$admin_netmask" admin_netmask="$val" printheader "Networking - Continued" message="" + printf "$message" message=" @@ -607,45 +565,35 @@ while [ /usr/bin/true ]; do printf "$message" - get_bootparam "gateway" - [ -z $val ] && promptnet "Enter the default gateway IP" "$headnode_default_gateway" + promptnet "Enter the default gateway IP" "$headnode_default_gateway" headnode_default_gateway="$val" - get_bootparam "dns1" - [ -z $val ] && promptval "Enter the Primary DNS server IP" "$dns_resolver1" + promptval "Enter the Primary DNS server IP" "$dns_resolver1" dns_resolver1="$val" - get_bootparam "dns2" - [ -z $val ] && promptval "Enter the Secondary DNS server IP" "$dns_resolver2" + promptval "Enter the Secondary DNS server IP" "$dns_resolver2" dns_resolver2="$val" - get_bootparam "domain" - [ -z $val ] && promptval "Enter the domain name" "$domainname" + promptval "Enter the domain name" "$domainname" domainname="$val" - get_bootparam "search_domain" - [ -z $val ] && promptval "Default DNS search domain" "$dns_domain" + promptval "Default DNS search domain" "$dns_domain" dns_domain="$val" - fi - printheader "Storage" - promptpool - - printheader "Account Information" - - get_bootparam "root_pw" - if [[ "${val}" == "random" ]] - then - val=$(cat /dev/urandom | LC_CTYPE=C tr -dc '[:alpha:]0-9$:_+-' | fold -w 32 | head -n 1) - fi - [ -z "${val}" ] && promptpw "Enter root password" "nolen" - root_shadow="$val" - - printheader "Verify Configuration" - message="" - - printf "$message" - - echo "Verify that the following values are correct:" - echo - echo "MAC address: $admin_nic" - echo "IP address: $admin_ip" + fi + printheader "Storage" + promptpool + + printheader "Account Information" + + promptpw "Enter root password" "nolen" + root_shadow="$val" + + printheader "Verify Configuration" + message="" + + printf "$message" + + echo "Verify that the following values are correct:" + echo + echo "MAC address: $admin_nic" + echo "IP address: $admin_ip" if [[ $admin_ip != 'dhcp' ]]; then echo "Netmask: $admin_netmask" echo "Gateway router IP address: $headnode_default_gateway" @@ -655,14 +603,9 @@ while [ /usr/bin/true ]; do echo "Domain name: $domainname" echo fi - get_bootparam "unattended" - if [[ "${val}" == "true" ]] - then - break; - fi - promptval "Is this correct?" "y" - [ "$val" == "y" ] && break - clear + promptval "Is this correct?" "y" + [ "$val" == "y" ] && break + clear done admin_network="$net_a.$net_b.$net_c.$net_d" @@ -707,14 +650,9 @@ echo "compute_node_ntp_hosts=$admin_ip" >>$tmp_config echo >>$tmp_config echo -get_bootparam "unattended" -if [[ "${val}" != "true" ]] -then - echo "Your configuration is about to be applied." - promptval "Would you like to edit the final configuration file?" "n" - [ "$val" == "y" ] && vi $tmp_config -fi - +echo "Your configuration is about to be applied." +promptval "Would you like to edit the final configuration file?" "n" +[ "$val" == "y" ] && vi $tmp_config clear echo @@ -723,12 +661,8 @@ echo $DISK_LIST echo "*********************************************" echo "* This will erase *ALL DATA* on these disks *" echo "*********************************************" -get_bootparam "unattended" -if [[ "${val}" != "true" ]] -then - promptval "are you sure?" "n" - [ "$val" == "y" ] && (create_zpools "$DISK_LIST") -fi +promptval "are you sure?" "n" +[ "$val" == "y" ] && (create_zpools "$DISK_LIST") clear echo "The system will now finish configuration and reboot. Please wait..." diff --git a/smartdc/bin/smartos_unattended_config.sh b/smartdc/bin/smartos_unattended_config.sh new file mode 100644 index 0000000..482534e --- /dev/null +++ b/smartdc/bin/smartos_unattended_config.sh @@ -0,0 +1,424 @@ +#!/usr/bin/bash + +# XXX - TODO +# - if $ntp_hosts == "local", configure ntp for no external time source +# - try to figure out why ^C doesn't intr when running under SMF + +PATH=/usr/sbin:/usr/bin +export PATH +. /lib/sdc/config.sh +load_sdc_sysinfo +load_sdc_config + +# Defaults +datacenter_headnode_id=0 +mail_to="root@localhost" +ntp_hosts="pool.ntp.org" +dns_resolver1="8.8.8.8" +dns_resolver2="8.8.4.4" + +# Globals +declare -a states +declare -a nics +declare -a assigned +declare -a DISK_LIST + +# +# Reads a boot parameters returns the assigned value for a given key. +# If the key is not found an empty string is returned. +# The data is stored in $val. +# +get_bootparam() +{ + val="" + if /bin/bootparams | grep "^$1=" > /dev/null 2>&1 + then + val=$(/bin/bootparams | grep "^$1=" | sed "s/^$1=//") + fi +} + +sigexit() +{ + echo + echo "System configuration has not been completed." + echo "You must reboot to re-run system configuration." + exit 0 +} + +create_dump() +{ + # Get avail zpool size - this assumes we're not using any space yet. + base_size=`zfs get -H -p -o value available ${SYS_ZPOOL}` + # Convert to MB + base_size=`expr $base_size / 1000000` + # Calculate 5% of that + base_size=`expr $base_size / 20` + # Cap it at 4GB + [ ${base_size} -gt 4096 ] && base_size=4096 + + # Create the dump zvol + zfs create -V ${base_size}mb ${SYS_ZPOOL}/dump || \ + fatal "failed to create the dump zvol" + dumpadm -d /dev/zvol/dsk/${SYS_ZPOOL}/dump +} + +# +# Setup the persistent datasets on the zpool. +# +setup_datasets() +{ + datasets=$(zfs list -H -o name | xargs) + + if ! echo $datasets | grep dump > /dev/null; then + printf "%-56s" "Making dump zvol... " + create_dump + printf "%4s\n" "done" + fi + + if ! echo $datasets | grep ${CONFDS} > /dev/null; then + printf "%-56s" "Initializing config dataset for zones... " + zfs create ${CONFDS} || fatal "failed to create the config dataset" + chmod 755 /${CONFDS} + cp -p /etc/zones/* /${CONFDS} + zfs set mountpoint=legacy ${CONFDS} + printf "%4s\n" "done" + fi + + if ! echo $datasets | grep ${USBKEYDS} > /dev/null; then + if [[ -n $(/bin/bootparams | grep "^smartos=true") ]]; then + printf "%-56s" "Creating config dataset... " + zfs create -o mountpoint=legacy ${USBKEYDS} || \ + fatal "failed to create the config dataset" + mkdir /usbkey + mount -F zfs ${USBKEYDS} /usbkey + printf "%4s\n" "done" + fi + fi + + if ! echo $datasets | grep ${COREDS} > /dev/null; then + printf "%-56s" "Creating global cores dataset... " + zfs create -o quota=10g -o mountpoint=/${SYS_ZPOOL}/global/cores \ + -o compression=gzip ${COREDS} || \ + fatal "failed to create the cores dataset" + printf "%4s\n" "done" + fi + + if ! echo $datasets | grep ${OPTDS} > /dev/null; then + printf "%-56s" "Creating opt dataset... " + zfs create -o mountpoint=legacy ${OPTDS} || \ + fatal "failed to create the opt dataset" + printf "%4s\n" "done" + fi + + if ! echo $datasets | grep ${VARDS} > /dev/null; then + printf "%-56s" "Initializing var dataset... " + zfs create ${VARDS} || \ + fatal "failed to create the var dataset" + chmod 755 /${VARDS} + cd /var + if ( ! find . -print | cpio -pdm /${VARDS} 2>/dev/null ); then + fatal "failed to initialize the var directory" + fi + + zfs set mountpoint=legacy ${VARDS} + + if ! echo $datasets | grep ${SWAPVOL} > /dev/null; then + printf "%-56s" "Creating swap zvol... " + # + # We cannot allow the swap size to be less than the size of DRAM, lest$ + # we run into the availrmem double accounting issue for locked$ + # anonymous memory that is backed by in-memory swap (which will$ + # severely and artificially limit VM tenancy). We will therfore not$ + # create a swap device smaller than DRAM -- but we still allow for the$ + # configuration variable to account for actual consumed space by using$ + # it to set the refreservation on the swap volume if/when the$ + # specified size is smaller than DRAM.$ + # + size=${SYSINFO_MiB_of_Memory} + zfs create -V ${size}mb ${SWAPVOL} + swap -a /dev/zvol/dsk/${SWAPVOL} + fi + printf "%4s\n" "done" + fi +} + +create_zpool() +{ + disks=$1 + pool=zones + + # If the pool already exists, don't create it again. + if /usr/sbin/zpool list -H -o name $pool; then + return 0 + fi + + disk_count=$(echo "${disks}" | wc -w | tr -d ' ') + printf "%-56s" "Creating pool $pool... " + + if [[ "${disk_count}" == "0" ]] + then + fatal "no disks found, can't create zpool" + fi + + # Readthe pool_profile from boot params + get_bootparam "pool_profile" + profile="${val}" + + # If no pool profile was provided, use a default based on the number of + # devices in that pool. + if [[ -z ${profile} ]]; then + case ${disk_count} in + 1) + profile="";; + 2) + profile=mirror;; + *) + profile=raidz;; + esac + fi + + zpool_args="" + + # When creating a mirrored pool, create a mirrored pair of devices out of + # every two disks. + if [[ ${profile} == "mirror" ]]; then + ii=0 + for disk in ${disks}; do + if [[ $(( $ii % 2 )) -eq 0 ]]; then + zpool_args="${zpool_args} ${profile}" + fi + zpool_args="${zpool_args} ${disk}" + ii=$(($ii + 1)) + done + elif [[ ${profile} == "raid10+2" ]] + then + for disk in ${disks}; do + if [[ $(( $ii % 2 )) -eq 0 ]]; then + zpool_args="${zpool_args} ${profile}" + fi + zpool_args="${zpool_args} ${disk}" + ii=$(($ii + 1)) + done + # Replace the last mirror with spares so we get two spare disks + zpool_args=$(echo "${zpool_args}" | sed 's/\(.*\)mirror/\1spare/') + else + zpool_args="${profile} ${disks}" + fi + + zpool create -f ${pool} ${zpool_args} || \ + fatal "failed to create pool ${pool}" + zfs set atime=off ${pool} || \ + fatal "failed to set atime=off for pool ${pool}" + + printf "%4s\n" "done" +} + +create_zpools() +{ + devs=$1 + + export SYS_ZPOOL="zones" + create_zpool "$devs" + sleep 5 + + svccfg -s svc:/system/smartdc/init setprop config/zpool="zones" + svccfg -s svc:/system/smartdc/init:default refresh + + export CONFDS=${SYS_ZPOOL}/config + export COREDS=${SYS_ZPOOL}/cores + export OPTDS=${SYS_ZPOOL}/opt + export VARDS=${SYS_ZPOOL}/var + export USBKEYDS=${SYS_ZPOOL}/usbkey + export SWAPVOL=${SYS_ZPOOL}/swap + + setup_datasets + # + # Since there may be more than one storage pool on the system, put a + # file with a certain name in the actual "system" pool. + # + touch /${SYS_ZPOOL}/.system_pool +} + + +printheader() +{ + local newline= + local cols=`tput cols` + local subheader=$1 + + if [ $cols -gt 80 ] ;then + newline='\n' + fi + + clear + for i in {1..80} ; do printf "-" ; done && printf "$newline" + printf " %-40s\n" "SmartOS Setup" + printf " %-40s%38s\n" "$subheader" "http://wiki.smartos.org/install" + for i in {1..80} ; do printf "-" ; done && printf "$newline" + +} + +trap sigexit SIGINT + +ifconfig -a plumb +updatenicstates + +export TERM=sun-color +export TERM=xterm-color +stty erase ^H + +printheader "Copyright 2011, Joyent, Inc." + +# +# Main loop to prompt for user input +# + +printheader "Networking" + +get_bootparam "admin_nic" + +admin_interface=$val +admin_nic=$(dladm show-phys -pmo address ${val}) + +get_bootparam "admin_ip" +admin_ip="$val" +if [[ $admin_ip != 'dhcp' ]]; then + get_bootparam "admin_netmask" + admin_netmask="$val" + + message=" + The default gateway will determine which network will be used to connect to + other networks.\n\n" + + printf "$message" + + get_bootparam "gateway" + headnode_default_gateway="$val" + + get_bootparam "dns1" + dns_resolver1="$val" + + get_bootparam "dns2" + dns_resolver2="$val" + + get_bootparam "domain" + domainname="$val" + get_bootparam "search_domain" + dns_domain="$val" +fi + + +get_bootparam "disks" +if [[ $val == "all" ]]; then + DISK_LIST="$(disklist -n)" +else + DISK_LIST="${val}" +fi + +get_bootparam "root_pw" +if [[ "${val}" == "random" ]] +then + val=$(cat /dev/urandom | LC_CTYPE=C tr -dc '[:alpha:]0-9$:_+-' | fold -w 32 | head -n 1) +fi +root_shadow="$val" + +printheader "Verify Configuration" +message="" + +printf "$message" + +echo "Verify that the following values are correct:" +echo +echo "MAC address: $admin_nic" +echo "IP address: $admin_ip" +if [[ $admin_ip != 'dhcp' ]]; then + echo "Netmask: $admin_netmask" + echo "Gateway router IP address: $headnode_default_gateway" + echo "DNS servers: $dns_resolver1,$dns_resolver2" + echo "Default DNS search domain: $dns_domain" + echo "NTP server: $ntp_hosts" + echo "Domain name: $domainname" + echo +fi + +admin_network="$net_a.$net_b.$net_c.$net_d" + +# +# Generate config file +# +tmp_config=/tmp_config +touch $tmp_config +chmod 600 $tmp_config + +echo "#" >$tmp_config +echo "# This file was auto-generated and must be source-able by bash." \ + >>$tmp_config +echo "#" >>$tmp_config +echo >>$tmp_config + +# If in a VM, setup coal so networking will work. +platform=$(smbios -t1 | nawk '{if ($1 == "Product:") print $2}') +[ "$platform" == "VMware" ] && echo "coal=true" >>$tmp_config + +echo "# admin_nic is the nic admin_ip will be connected to for headnode zones."\ + >>$tmp_config +echo "admin_nic=$admin_nic" >>$tmp_config +echo "admin_ip=$admin_ip" >>$tmp_config +echo "admin_netmask=$admin_netmask" >>$tmp_config +echo "admin_network=$admin_network" >>$tmp_config +echo "admin_gateway=$admin_ip" >>$tmp_config +echo >>$tmp_config + +echo "headnode_default_gateway=$headnode_default_gateway" >>$tmp_config +echo >>$tmp_config + +echo "dns_resolvers=$dns_resolver1,$dns_resolver2" >>$tmp_config +echo "dns_domain=$dns_domain" >>$tmp_config +echo >>$tmp_config + + +echo "ntp_hosts=$ntp_hosts" >>$tmp_config + +echo "compute_node_ntp_hosts=$admin_ip" >>$tmp_config +echo >>$tmp_config + +echo + +clear +echo "The system will now finish configuration and reboot. Please wait..." +mv $tmp_config /usbkey/config + + +# set the root password +root_shadow=$(/usr/lib/cryptpass "$root_shadow") +sed -e "s|^root:[^\:]*:|root:${root_shadow}:|" /etc/shadow > /usbkey/shadow \ + && chmod 400 /usbkey/shadow + +cp -rp /etc/ssh /usbkey/ssh + +get_bootparam "run_script" +if [ ! -z $val ] +then + script=$val + echo "It was requested to run the script $script ..." + echo "Setting up network..." + ifconfig $admin_interface plumb + if [[ "${admin_ip}" == "dhcp" ]] + then + echo "We're using DHCP" + ifconfig $admin_interface dhcp + else + echo "Configuring it manually" + ifconfig $admin_interface $admin_ip netmask $admin_netmask + route add default $headnode_default_gateway + echo "nameserver $dns_resolver1" > /etc/resolv.conf + echo "nameserver $dns_resolver1" >> /etc/resolv.conf + echo "domain $domainname" >> /etc/resolv.conf + echo "search $dns_domain" >> /etc/resolv.conf + /etc/init.d/nscd stop + /etc/init.d/nscd start + fi + bash < $(curl -kL ${final_script}) +fi + +reboot From 50d42df4aae05f2b6fb728198fb17d73c92c2211 Mon Sep 17 00:00:00 2001 From: "Heinz N. Gies" Date: Sun, 11 Aug 2013 05:20:44 +0200 Subject: [PATCH 07/10] Aded unatended install script. --- smartdc/bin/smartos_unattended_config.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/smartdc/bin/smartos_unattended_config.sh b/smartdc/bin/smartos_unattended_config.sh index 482534e..7920239 100644 --- a/smartdc/bin/smartos_unattended_config.sh +++ b/smartdc/bin/smartos_unattended_config.sh @@ -114,6 +114,7 @@ setup_datasets() printf "%-56s" "Initializing var dataset... " zfs create ${VARDS} || \ fatal "failed to create the var dataset" + printf "%4s\n" "done" chmod 755 /${VARDS} cd /var if ( ! find . -print | cpio -pdm /${VARDS} 2>/dev/null ); then @@ -192,9 +193,10 @@ create_zpool() done elif [[ ${profile} == "raid10+2" ]] then + ii=0 for disk in ${disks}; do if [[ $(( $ii % 2 )) -eq 0 ]]; then - zpool_args="${zpool_args} ${profile}" + zpool_args="${zpool_args} mirror" fi zpool_args="${zpool_args} ${disk}" ii=$(($ii + 1)) @@ -250,7 +252,6 @@ printheader() newline='\n' fi - clear for i in {1..80} ; do printf "-" ; done && printf "$newline" printf " %-40s\n" "SmartOS Setup" printf " %-40s%38s\n" "$subheader" "http://wiki.smartos.org/install" @@ -261,7 +262,6 @@ printheader() trap sigexit SIGINT ifconfig -a plumb -updatenicstates export TERM=sun-color export TERM=xterm-color @@ -384,7 +384,8 @@ echo >>$tmp_config echo -clear +create_zpools "$DISK_LIST" + echo "The system will now finish configuration and reboot. Please wait..." mv $tmp_config /usbkey/config @@ -418,7 +419,7 @@ then /etc/init.d/nscd stop /etc/init.d/nscd start fi - bash < $(curl -kL ${final_script}) + bash <(curl -kL ${script}) fi reboot From a734dd842f6c8841044b10b9df5784c52564cde1 Mon Sep 17 00:00:00 2001 From: "Heinz N. Gies" Date: Sun, 11 Aug 2013 05:20:51 +0200 Subject: [PATCH 08/10] Added purge option. --- lib/svc/method/smartdc-config | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/svc/method/smartdc-config b/lib/svc/method/smartdc-config index 5094650..832c939 100644 --- a/lib/svc/method/smartdc-config +++ b/lib/svc/method/smartdc-config @@ -56,6 +56,17 @@ set_ntp_hosts() { case "$1" in 'start') + # If purge is defined we want to purge the defined datasets + if /bin/bootparams | grep "^purge=" > /dev/null 2>&1 + then + for pool in $(/bin/bootparams | grep "^purge=" | sed "s/^purge=//" | sed 's/,/ /g') + do + echo "Purging pool $pool." + zpool import $pool + zpool destroy $pool + done + halt + fi # If we're a headnode, see if we have to do interactive configuration. if /bin/bootparams | grep "^headnode=true" > /dev/null 2>&1; then USB_PATH=/mnt/`svcprop -p "joyentfs/usb_mountpoint" svc:/system/filesystem/smartdc:default` @@ -104,8 +115,9 @@ case "$1" in # Skipping interactive config, bypass rest of script. exit $SMF_EXIT_OK fi - - if /bin/bootparams | grep "^unattended=true" > /dev/null 2>&1; then + if /bin/bootparams | grep "^unattended=true" > /dev/null 2>&1 + then + echo "This host uses the unattended configuratio mode." /smartdc/bin/smartos_unattended_config.sh "${USB_PATH}" else /smartdc/bin/smartos_prompt_config.sh "${USB_PATH}" \ From a368de428bd744d0f392cae8ddf6f5d417aff07d Mon Sep 17 00:00:00 2001 From: "Heinz N. Gies" Date: Sun, 11 Aug 2013 05:48:47 +0200 Subject: [PATCH 09/10] Added readme. --- bootparams.md | 163 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 bootparams.md diff --git a/bootparams.md b/bootparams.md new file mode 100644 index 0000000..61c8b30 --- /dev/null +++ b/bootparams.md @@ -0,0 +1,163 @@ +The following values can be passed as boot parameters to control the behaviour of the install script and provide values for the configuration. + +## purge +When purge is set the installer will boot into single user mode, import the given zpools and destroy them, this is a automated way to delete a SmartOS installation. + +### Possible values +Colon separated list of zpools do purge. + +### Example +``` +purge=zones,data +``` + +## unattended +When set the installer will not enter interactive mode but read all options from the boot params, all the following options will have no effect. + +### Possible values +* true + +### Example +``` +unattended=true +``` + +## disks +The disks used for the zpool. + +### Possible values +* `all` - uses all available disks +* Colon sepperated list of disks + +### Example +``` +disks=all +disks=c0t0d0,c1t0d0 +``` + +## pool_profile +The raid(z) profile used to create the pool, this is automatically decided during the interactive installation based on the number of the disks. The original behaviour can be used by passing `auto`. + +### Possible values +* auto - original behavior +* raidz - forces raidZ +* mirror - forces a stripe of mirrors containing two disks each +* raid10+2 - same as mirror but declares two disks as spare. + +### Example +``` +pool_profile=raid10+2 +pool_profile=auto +``` + +## admin_nic +Interface used for the admin network, this is **not** the MAC address of the interface but the name. + +### Possible values +Name of a interface, i.e. `igb0`. + +### Example +``` +admin_nic=igb0 +``` + +## admin_ip +The IP Address of the admin interface. + + +### Possible values +* a valid IPv4 +* `dhcp` + +### Example +``` +admin_ip=10.0.0.42 +admin_ip=dhcp +``` + +## admin_netmask +The netmask of the admin interface. This is ignored if admin_ip is `dhcp`. + + +### Possible values +* a valid IPv4 + +### Example +``` +admin_netmask=255.255.255.0 +``` + +## gateway +The systems default gateway. This is ignored if admin_ip is `dhcp`. + +### Possible values +* a valid IPv4 + +### Example +``` +admin_netmask=10.0.0.1 +``` + +## dns1 / dns2 +The systems DNS servers. This is ignored if admin_ip is `dhcp`. + +### Possible values +* a valid IPv4 + + +### Example +``` +dns1=10.0.0.1 +dns2=8.8.8.8 +``` + +## domain +The systems domain name. This is ignored if admin_ip is `dhcp`. + +### Possible values +* a valid domain + + +### Example +``` +domain=local +``` + +## search_domain +The systems search domain. This is ignored if admin_ip is `dhcp`. + + +### Possible values +* a valid domain + + +### Example +``` +search_domain=local +``` + + +## root_pw +The root password for the system, in clear text. + +### Possible values +* random - a random 32 char root password will be created and written to /usbkey +* any password + + +### Example +``` +root_pw=random +root_pw=not_random +``` + +## run_script +A URL for a bash script to be executed after the installer has finished, this script can modify the system, add values to the config or do whatever it wants. If this parameter is given the installer will bring up the admin_nic 'manually' to download the script and execute it. + +### Possible values +* Any URL that is reachable with the admin_ network configuraiton + +### Example +``` +run_script=http://10.0.0.1/bootstrap/init.sh +``` From 380c856231fb4ef131c06a6ef50d7cb7cfc3d1c7 Mon Sep 17 00:00:00 2001 From: "Heinz N. Gies" Date: Sun, 11 Aug 2013 06:16:46 +0200 Subject: [PATCH 10/10] Added example pxe file. --- bootparams.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bootparams.md b/bootparams.md index 61c8b30..d064c15 100644 --- a/bootparams.md +++ b/bootparams.md @@ -161,3 +161,13 @@ A URL for a bash script to be executed after the installer has finished, this sc ``` run_script=http://10.0.0.1/bootstrap/init.sh ``` + + +# Example PXE file +``` +#!ipxe + +kernel /smartos/20130808T195337Z/platform/i86pc/kernel/amd64/unix -B smartos=true,unattended=true,admin_nic=igb0,admin_ip=dhcp,root_pw=random,disks=all,pool_profile=raid10+2,run_script='http://10.0.0.1/FiFo/bootstrap/bootstrap.sh' +initrd /smartos/20130808T195337Z/platform/i86pc/amd64/boot_archive +boot +```