summaryrefslogtreecommitdiff
path: root/distrib/miniroot/install.sub
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2003-05-12 19:01:59 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2003-05-12 19:01:59 +0000
commit133a9e1f61a57c0b8c2b055ffc29e15820eaeead (patch)
tree3a3050b51e54e29b5a7277f84249e94d84c994fa /distrib/miniroot/install.sub
parent3466355dad79d9e5119cb618e457ee864ddadd81 (diff)
More cleanup and fixes in url installs.
1) Filter appropriate lines (ftp or http) from ftplist once when it is downloaded rather than everytime the lines are needed. 2) Don't display the 'ftp://' or 'http://' part of the listed url's as all displayed url's are of the same type. Partially compensates for the last increase in the width of the 'cat -n' line number field. 3) Store filtered lines in /tmp/serverlist instead of /tmp/ftplist, since it can be a list of http servers too. Makes it more obvious that it is not a copy of ftplist. 4) Avoid 'ftplist: No such file' message, but add more informative 'Getting...done.' or 'Getting...FAILED.' message. Display the actual ftp error that caused the FAILED status. 5) Add 'done' to the list of available options when asking for a server location, allowing the user to return to set location selection without having to enter a server. 6) Mention the '?' option in the prompt. It re-displays the list of servers. 7) Eliminate unneeded variables 'host' and 'maxlines'. Make global tline a local (_line). Change _ftp_get_list global to more generic _get_server_list. 8) General logic cleanup.
Diffstat (limited to 'distrib/miniroot/install.sub')
-rw-r--r--distrib/miniroot/install.sub83
1 files changed, 41 insertions, 42 deletions
diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub
index 157c842314c..9a22d368332 100644
--- a/distrib/miniroot/install.sub
+++ b/distrib/miniroot/install.sub
@@ -1,4 +1,4 @@
-# $OpenBSD: install.sub,v 1.302 2003/05/12 18:16:15 krw Exp $
+# $OpenBSD: install.sub,v 1.303 2003/05/12 19:01:58 krw Exp $
# $NetBSD: install.sub,v 1.5.2.8 1996/09/02 23:25:02 pk Exp $
#
# Copyright (c) 1997-2003 Todd Miller, Theo de Raadt, Ken Westerback
@@ -225,7 +225,7 @@ ask() {
# Save the user input (or the default) in $resp.
ask_until () {
resp=
- while [ -z "$resp" ] ; do
+ while [[ -z $resp ]] ; do
ask "$1" "$2"
done
}
@@ -926,7 +926,7 @@ ftp_error () {
# Note: _ftp_server_ip, _ftp_server_dir, _ftp_server_login,
# _ftp_server_password, and _ftp_active must be global.
install_url() {
- local _file_list _url_type=$1 _url_base _oifs
+ local _url_type=$1 _file_list _url_base _oifs _prompt _line
donetconfig
@@ -935,59 +935,58 @@ install_url() {
unset ftp_proxy http_proxy
[[ $resp == none ]] || export ftp_proxy=$resp http_proxy=$resp
- ask "Display the list of known $_url_type servers?" "${_ftp_getlist:-y}"
+ rm -f $SERVERLIST
+ ask "Display the list of known $_url_type servers?" "${_get_server_list:-y}"
case $resp in
- n*|N*) _ftp_getlist=n
+ n*|N*) _get_server_list=n
;;
*)
- _ftp_getlist=y
+ _get_server_list=y
# ftp.openbsd.org == 129.128.5.191 and will remain at
# that address for the forseeable future.
- ftp ${_ftp_active} -V -a -o /tmp/ftplist ftp://129.128.5.191/$FTPDIR/ftplist > /dev/null
- grep "^${_url_type}:" /tmp/ftplist | cat -n | less -XE
+ echo -n "Getting the list from 129.128.5.191 (ftp.openbsd.org)..."
+ ftp $_ftp_active -V -a -o - \
+ ftp://129.128.5.191/$FTPDIR/ftplist 2>/tmp/ftplisterr \
+ | sed -ne "/^${_url_type}:\/\//s///p" >$SERVERLIST
+ if [[ -s $SERVERLIST ]]; then
+ echo "done."
+ _prompt="Server? (IP address, hostname, list#, 'done' or '?')"
+ cat -n $SERVERLIST | less -XE
+ else
+ echo "FAILED."
+ cat /tmp/ftplisterr
+ fi
;;
esac
# Get server IP address or hostname
- resp=
- while [[ -z $resp ]] ; do
- if [ ! -f /tmp/ftplist ]; then
- eval ask \"Server IP address, or hostname?\" \"\$_${_url_type}_server_ip\"
- continue;
- fi
-
- eval ask \"Server IP address, hostname, or list#?\" \"\$_${_url_type}_server_ip\"
-
+ : ${_prompt:="Server? (IP address, hostname or 'done')"}
+ while : ; do
+ eval resp=\$_${_url_type}_server_ip
+ ask_until "$_prompt" "$resp"
case $resp in
- "?")
- grep "^${_url_type}:" /tmp/ftplist | cat -n | less -XE
- resp=
+ done) return ;;
+ "?") [[ -s $SERVERLIST ]] || continue
+ cat -n $SERVERLIST | less -XE
;;
+([0-9]))
- maxlines=`grep "^${_url_type}:" /tmp/ftplist | sed -ne '$='`
-
- if [ $maxlines -lt $resp -o $resp -lt 1 ]; then
- echo "There is no ${resp}th line in the list."
- else
- tline=`grep "^${_url_type}:" /tmp/ftplist | sed -ne "${resp}p"`
- echo "Using $tline"
- url=`echo $tline | sed -e "s/^${_url_type}:\/\///" |
- cutword -t' ' 1 | cutword -t' ' 1`
- host=`echo $url | cutword -t/ 1`
- eval _${_url_type}_server_ip=$host
- eval _${_url_type}_server_dir=$(echo $url | sed -e "s/^${host}\///")/$SETDIR
- fi
-
- # Always do it again, just to double check
- resp=
- ;;
- *)
+ # A numeric hostname is ignored. A number is only used
+ # as a line number in $SERVERLIST.
+ [[ -s $SERVERLIST ]] || continue
+ _line=$(sed -ne "${resp}p" $SERVERLIST)
+ [[ -n $_line ]] || { echo "There is no line $resp." ; continue ; }
+ echo "Using $_line"
+ _line=$(echo $_line | cutword -t' ' 1)
+ eval _${_url_type}_server_ip=${_line%%/*}
+ eval _${_url_type}_server_dir=${_line#*/}/$SETDIR
+ # Repeat loop to get user to confirm server address.
+ ;;
+ *) eval _${_url_type}_server_ip=$resp
+ break
;;
esac
done
- eval _${_url_type}_server_ip=$resp
-
# Some older servers lie about their support for passive mode ftp, so
# ask the user if it worth trying passive mode to the chosen server.
# Irrelevant if using a proxy.
@@ -1056,11 +1055,10 @@ install_mounted_fs() {
local _mp=$1 _dir=$2
while : ; do
- ask "Pathname to the sets? (or 'done')" "$_dir"
+ ask_until "Pathname to the sets? (or 'done')" "$_dir"
case $resp in
done) return
;;
- "") ;;
*)
# Accept a valid $_mp relative path.
[[ -d $_mp/$resp ]] && { _dir=$_mp/$resp ; break ; }
@@ -1756,6 +1754,7 @@ VNAME="$(( $VERSION / 10 )).$(( $VERSION % 10 ))"
SETDIR="$VNAME/$ARCH"
FTPDIR="pub/OpenBSD/$VNAME"
OBSD="OpenBSD/$ARCH $VNAME"
+SERVERLIST=/tmp/serverlist
# Extract and save one boot's worth of dmesg
dmesg | sed -ne '/^OpenBSD /h;/^OpenBSD /!H;${g;p;}' > /var/run/dmesg.boot