From 1fdd884913f7ed6bd8ff5a08d4e719a413b8d315 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Mon, 21 Jul 2014 01:05:22 -0400 Subject: installers/pc: New installer for PC platforms --- (limited to 'installers/data') diff --git a/installers/data/pc.sh b/installers/data/pc.sh new file mode 100644 index 0000000..4cd8d09 --- /dev/null +++ b/installers/data/pc.sh @@ -0,0 +1,96 @@ +set -u + +_read() +{ + # The miniprokit call in the installer redirects this script to stdin, + # so we need to reconnect stdin to the tty. We can't do this for the + # whole script with exec, because the shell reads the script in parts. + read "${@}" 0<&1 +} + +_select() +{ + # Field width of the prompt numbers. + select_width=$(expr ${#} : '.*') + + select_i= + + while :; do + case "${select_i}" in + '') + select_i=0 + for select_word in "${@}"; do + select_i=$(expr ${select_i} + 1) + printf "%${select_width}d) %s\\n" \ + ${select_i} "${select_word}" + done + ;; + *[!0-9]*) + printf 'Please enter a number in range.\n' >&2 + ;; + *) + if [ ${select_i} -gt 0 ] && \ + [ ${select_i} -le ${#} ]; then + shift $(expr $select_i - 1) + select_result="${1}" + break + fi + printf 'Please enter a number in range.\n' >&2 + ;; + esac + + # Prompt and read input. + printf '%s' "${PS3-#? }" >&2 + _read -r select_i || exit + done +} + +printf '\nConfigure the network' +printf '\n=====================\n\n' +printf 'Network configuration method:\n' +_select 'Static' 'DHCP' +if [ "x${select_result}" = 'xStatic' ]; then + printf 'Network interface (e.g. "eth0"): ' + _read -r netiface + printf 'Network address (e.g. "192.168.1.2"): ' + _read -r netaddr + printf 'Network mask (e.g. "255.255.255.0"): ' + _read -r netmask + printf 'Network gateway (e.g. "192.168.1.1"): ' + _read -r netgw + cat >/etc/network/interfaces <