Skip to content

Support remote installation/recovery #627

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions overlay/generic/smartdc/lib/smartos_prompt_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,14 @@ create_zpools()
touch /${SYS_ZPOOL}/.system_pool
}

update_root_password()
{
[[ -z "$1" ]] && return 0
(umask 066; sed -e "s|^root:[^\:]*:|root:$1:|" /etc/shadow \
> /etc/shadow.tmp) && \
mv /etc/shadow.tmp "$2"
}

trap "" SIGINT

while getopts "f:" opt
Expand Down Expand Up @@ -964,10 +972,15 @@ if [[ $nic_cnt -lt 1 ]]; then
exit 0
fi

run_sshd=$(/bin/bootparams | grep "^run_sshd=" | sed "s,^[^=]*=,,")

# Don't do an 'ifconfig -a' - this causes some nics (bnx) to not
# work when combined with the later dladm commands
for iface in $(dladm show-phys -pmo link); do
ifconfig $iface plumb 2>/dev/null
if [[ "$run_sshd" = "true" ]]; then
ifconfig $iface dhcp
fi
done
updatenicstates

Expand All @@ -978,6 +991,18 @@ trap sig_doshell SIGINT

printheader "Copyright 2013, Joyent, Inc."

if [[ "$run_sshd" = "true" ]] && \
[[ -z $(/usr/bin/ps -e -o comm | /usr/bin/grep sshd) ]]; then
/usr/bin/ssh-keygen -A
/usr/bin/ssh-keygen -l -f /var/ssh/ssh_host_dsa_key
/usr/bin/ssh-keygen -l -f /var/ssh/ssh_host_rsa_key
/usr/bin/ssh-keygen -l -f /var/ssh/ssh_host_ecdsa_key
/usr/bin/ssh-keygen -l -f /var/ssh/ssh_host_ed25519_key

update_root_password "$(/bin/bootparams | grep "^root_shadow=" | sed "s,^[^=]*=,,")" /etc/shadow
/usr/lib/ssh/sshd
fi

message="
You must answer the following questions to configure your SmartOS node.
You will have a chance to review and correct your answers, as well as a
Expand Down Expand Up @@ -1246,9 +1271,7 @@ create_zpools "$DISK_LAYOUT"
mv $tmp_config /usbkey/config || fatal "failed to persist configuration"

# 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
update_root_password "$(/usr/lib/cryptpass "$root_shadow")" /usbkey/shadow
[[ $? -eq 0 ]] || fatal "failed to preserve root pasword"

cp -rp /etc/ssh /usbkey/ssh || fatal "failed to set up preserve host keys"
Expand Down