-# $OpenBSD: install.sub,v 1.809 2015/01/12 16:33:31 deraadt Exp $
+# $OpenBSD: install.sub,v 1.810 2015/01/17 10:09:06 rpe Exp $
#
# Copyright (c) 1997-2009 Todd Miller, Theo de Raadt, Ken Westerback
# All rights reserved.
}
# Parse parameters
-auto=false
-respfile=
+AUTO=false
+RESPFILE=
while getopts "af:" opt; do
case $opt in
- a) auto=true;;
- f) respfile=$OPTARG;;
+ a) AUTO=true;;
+ f) RESPFILE=$OPTARG;;
*) usage;;
esac
done
# of that file
rm -f /tmp/update
-if ! $auto; then
+if ! $AUTO; then
# Start listener process looking for dmesg changes
(
while :; do
return $_redo
}
-# Search question in $respfile, return answer in $resp
+# Search question in $RESPFILE, return answer in $resp
#
# - split question and answer at leftmost =
# - strip leading/trailing blanks
_autorespond() {
typeset -l _q=$1 _key
local _def=$2 _l _val
- [[ -f $respfile ]] || return
+ [[ -f $RESPFILE ]] || return
# Find a suitable response in /ai.conf and remove it if found.
mv /ai.conf /ai.conf.tmp
while IFS=' ' read -r _l; do
# Ask for a password twice, saving the input in $_password
askpassword() {
local _q=$1
- if $auto; then
+ if $AUTO; then
echo -n "$_q "
_autorespond "$_q"
echo '<provided>'
userpass=$_password
userkey=
- $auto && ask "Public ssh key for user $user" none &&
+ $AUTO && ask "Public ssh key for user $user" none &&
[[ $resp != none ]] && userkey=$resp
if [[ $sshd == y ]]; then
ask "$1" "$2"
[[ -n $resp ]] && break
echo "A response is required."
- $auto && exit 1
+ $AUTO && exit 1
done
}
n|no) resp=n; return 1;;
esac
echo "'$resp' is not a valid choice."
- $auto && exit 1
+ $AUTO && exit 1
done
}
# entering something like 'a a'.
isin "$resp" $_dynlist done && break
echo "'$resp' is not a valid choice."
- $auto && [[ -n $respfile ]] && exit 1
+ $AUTO && [[ -n $RESPFILE ]] && exit 1
done
}
chmod 640 $_hn
: ${_first:=$_ifs}
fi
-
+
NIFS=$(ls -1 /tmp/hostname.* 2>/dev/null | grep -c ^)
_p=done
done
_prompt="IPv6 default router?"
- if $auto; then
+ if $AUTO; then
_autorespond "$_prompt" && _resp=$resp && echo "$_prompt $_resp"
else
local PS3="$_prompt (${_routers:+list #, }IPv6 address or 'none'): "
for _n in $THESETS; do echo $_n; done | showcols | sed 's/^/ /'
COLUMNS=$_col
- $auto && exit 1
+ $AUTO && exit 1
echo
return
fi
rm -f "$_tmpsrc/$_f"
if ! ask_yn "Fetching of $_f failed. Continue anyway?"; then
[[ -d $_tmpsrc ]] && rm -rf "$_tmpsrc"
- $auto && exit 1
+ $AUTO && exit 1
return
fi
continue
else
if ! ask_yn "Checksum test for $_f failed. Continue anyway?"; then
[[ -d $_tmpsrc ]] && rm -rf "$_tmpsrc"
- $auto && exit 1
+ $AUTO && exit 1
return
fi
fi
if [[ -n $_issue ]] &&
! ask_yn "$_issue. Continue without verification?"; then
[[ -d $_tmpsrc ]] && rm -rf "$_tmpsrc"
- $auto && exit 1
+ $AUTO && exit 1
return
fi
if (($?)); then
if ! ask_yn "Installation of $_f failed. Continue anyway?"; then
[[ -d $_tmpsrc ]] && rm -rf "$_tmpsrc"
- $auto && exit 1
+ $AUTO && exit 1
return
fi
else
# Accept a valid absolute path.
[[ -d /$resp ]] && { _dir=/$resp; break; }
echo "The directory '$resp' does not exist."
- $auto && exit 1
+ $AUTO && exit 1
done
install_files "file://$_dir" "$(ls $_dir/)"
[[ -n $_q ]] && return 1
# If sane_install has no argument, harass the user.
if ! ask_yn "Are you *SURE* your $MODE is complete without '$_s'?"; then
- $auto && exit 1 || return 1
+ $AUTO && exit 1 || return 1
fi
done
}
d*|D*) install_disk && METHOD=disk;;
h*|H*) isin http $_locs && install_http && METHOD=http;;
n*|N*) isin nfs $_locs && install_nfs && METHOD=nfs;;
- *) $auto && echo "'$resp' is not a valid choice." && exit 1;;
+ *) $AUTO && echo "'$resp' is not a valid choice." && exit 1;;
esac
[[ -n $METHOD ]] && _d=$METHOD
- sane_install quiet || $auto && _d=done
+ sane_install quiet || $AUTO && _d=done
done
}
md_congrats
[[ "$MODE" == upgrade ]] && \
echo "After rebooting, run sysmerge(8) to update your system configuration."
- $auto && >/ai.done
+ $AUTO && >/ai.done
}
# #######################################################################
}
# Interactive or automatic installation?
-if ! $auto; then
+if ! $AUTO; then
cat <<__EOT
At any prompt except password prompts you can escape to a shell by
typing '!'. Default answers are shown in []'s and are selected by
Control-C, but this can leave your system in an inconsistent state.
__EOT
-elif [[ -z $respfile ]]; then
+elif [[ -z $RESPFILE ]]; then
if ! get_responsefile; then
echo "No response file found; non-interactive mode aborted."
exit 1
exit 1
fi
else
- cp $respfile /ai.conf || exit
+ cp $RESPFILE /ai.conf || exit
fi
# Configure the terminal and keyboard.
done
rootkey=
- $auto && ask "Public ssh key for root account?" none &&
+ $AUTO && ask "Public ssh key for root account?" none &&
[[ $resp != none ]] && rootkey=$resp
questions