Lines Matching +full:additional +full:- +full:devs
3 # Copyright (c) 2012-2013 Devin Teske
91 # Returns zero if the given argument (a fully-qualified hostname) is compliant
92 # with standards set-forth in RFC's 952 and 1123 of the Network Working Group:
94 # RFC 952 - DoD Internet host table specification
97 # RFC 1123 - Requirements for Internet Hosts - Application and Support
124 [ ${#fqhn} -gt 255 ] && return 255
129 [ ${#label} -gt 63 ] && return 63
135 case "$label" in -*|*-) return 2; esac
138 case "$label" in *[!0-9a-zA-Z-]*) return 1; esac
146 # Convert an IPv4 address or mask from dotted-quad notation (e.g., `127.0.0.1'
147 # or `255.255.255.0') to a 32-bit unsigned integer for the purpose of network
154 # if [ $(( $ip1num & $masknum )) -eq \
160 # See f_validate_ipaddr() below for an additional example usage, on calculating
164 # standard output for capturing in a sub-shell (which is less-recommended
172 set -- $__addr
215 [ $octet -ge 0 ] || return 1
218 [ $octet -gt 255 ] && return 3
224 [ $noctets -eq 4 ] || return 4
237 bcastnum=$(( ($ipnum & $masknum)+$max_addr-$masknum ))
240 [ $ipnum -eq $netnum -o $ipnum -eq $bcastnum ]
256 # Segments must contain only combinations of the characters 0-9,
257 # A-F, or a-f.
260 # allowed at the beginning or end (unless a double-null segment;
263 # (separated by colons) exceeds the length of 4 hex-digits.
268 # * When there is an error with the dotted-quad IPv4 address at the
270 # bit-shifted (<< 4) return of f_validate_ipaddr.
274 local ip="${1%\%*}" # removing the interface specification if-present
277 set -- $ip:
281 [ $# -gt 9 -o $# -lt 3 ] && return 4
283 local h="[0-9A-Fa-f]"
286 while [ $# -gt 0 ]; do
292 # Return error if this segment makes one null too-many. A
299 if [ $nulls -eq 3 ]; then
302 elif [ $nulls -eq 2 ]; then
317 : valid segment of 1-4 hexadecimal digits
319 *[!0-9A-Fa-f]*)
323 [ $# -eq 0 ] || return 1
327 *[!0-9.]*)
334 if [ $nulls -eq 0 ]; then
335 [ $nsegments -eq 7 ] || return 4
351 if [ $nulls -eq 1 ]; then
359 # A legacy IPv4 address can span the last two 16-bit segments,
360 # reducing the amount of maximum allowable segments by-one.
369 0) [ $nsegments -eq $maxsegments ] || return 4 ;;
371 1) [ $nsegments -le $maxsegments ] || return 4 ;;
373 2) [ $nsegments -le $(( $maxsegments + 1 )) ] || return 4 ;;
389 # the maximum of 255 (a full 8-bit register).
411 [ $field -gt 255 ] && return 3
422 [ $nfields -eq 4 ] || return 4
444 [ $(( $ipnum & $masknum )) -eq \
471 elif [ "$gateway" -a "$gateway" != "NO" ] &&
485 # in a sub-shell (which is less-recommended because of performance degredation;
488 # This function is a two-parter. Below is the awk(1) portion of the function,
519 # in a sub-shell (which is less-recommended because of performance degredation;
522 # This function is a two-parter. Below is the awk(1) portion of the function,
553 # sub-shell (which is less-recommended because of performance degredation; for
591 # capturing in a sub-shell (which is less-recommended because of performance
594 # This function is a two-parter. Below is the awk(1) portion of the function,
612 __ip=$( route -n get default 2> /dev/null |
616 route -n get default 2> /dev/null |
625 # in a sub-shell (which is less-recommended because of performance degredation;
628 # This function is a two-parter. Below is the awk(1) portion of the function,
683 */*) f_quietly mkdir -p "${RESOLV_CONF%/*}" ;;
702 if [ ! -e "$ETC_HOSTS" ]; then
704 */*) f_quietly mkdir -p "${ETC_HOSTS%/*}" ;;
711 awk -v dn="$dp" -v ip4="$cp" -v ip6="$c6p" -v hn="$hp" '
715 h = ( match(hn, /\./) ? substr(hn, 0, RSTART-1) : "" )
779 # struct (see struct.subr for additional details) named `struct_name'. See
788 if [ ! -e "$leasefile" ]; then
796 eval "$( awk -v struct="$struct_name" '
801 fixed-address \
803 server-name \
813 host-name \
814 subnet-mask \
816 domain-name-servers \
817 domain-name \
818 broadcast-address \
819 dhcp-lease-time \
820 dhcp-message-type \
821 dhcp-server-identifier \
822 dhcp-renewal-time \
823 dhcp-rebinding-time \
892 # were unable to parse the lease database), fall-back to resolv.conf(5) for
900 # If it fails, do it the old-fashioned way
924 if [ -r "$RESOLV_CONF" ] && ! {
936 # Returns the rtsol-provided IPv6 address associated with $interface. The
966 # standard output for capturing in a sub-shell (which is less-recommended
983 # This function is a two-parter. Below is the awk(1) portion of the function,
1007 if __cp=$( awk -v name="$__host" \
1014 awk -v name="$__host" \
1021 # Fall back to host(1) -- which is further governed by nsswitch.conf(5)
1044 [ "$__wait" ] && __wait="-W $(( $__wait / $__host_runs ))"
1049 host -t SRV $__wait -- "$__type.$__host" \
1060 if ! __output=$( host -t AAAA $__wait -- "$__host" 2>&1 ); then
1061 # An error occurred, display in-full and return error
1066 # Add the IPv6 addresses and fall-through to collect IPv4 too
1071 if ! __output=$( host -t A $__wait -- "$__host" 2>&1 ); then
1072 # An error occurred, display it in-full and return error
1088 # This is it - how to get TCP setup values. Prompt the user to edit/confirm the
1089 # interface, gateway, nameserver, and hostname settings -- all required for
1127 # allows you to have a mostly non-interactive script that still
1186 i=$( sysctl -n net.inet6.ip6.dad_count )
1189 f_quietly mkdir -p /var/run
1192 i=$( sysctl -n net.inet6.ip6.dad_count )
1214 f_quietly mkdir -p /var/db
1215 f_quietly mkdir -p /var/run
1216 f_quietly mkdir -p /tmp
1219 trap - SIGINT
1220 ( # Execute in sub-shell to allow/catch Ctrl-C
1232 if [ $retval -eq $SUCCESS ]; then
1283 *.*) : do nothing ;; # Already fully-qualified
1291 # Re-check variables for initial inheritance before heading into dialog
1292 [ "$_hostname" ] || _hostname="${HOSTNAME:-$( hostname )}"
1299 # If non-interactive, jump over dialog section and into config section
1322 local n=$(( $width/2 - (${#devlabel} + 4)/2 - 2 ))
1326 --title "$title" \
1327 --backtitle "$DIALOG_BACKTITLE" \
1328 --hline "$hline" \
1329 --item-help \
1330 --ok-label "$msg_ok" \
1331 --cancel-label "$msg_cancel" \
1332 --help-button \
1333 --help-label "$msg_help" \
1334 --mixedform "$prompt" 16 $width 9 \
1344 "- $devlabel -" 5 $n "" 0 0 0 0 3 "" \
1356 # --mixed-form always returns 0, we have to
1364 [ $n -eq 1 ] && case "$cp" in HELP*)
1371 # Turn mixed-form results into env variables
1407 # Xdialog(1) does not support --mixed-form
1415 --title "$DIALOG_TITLE" \
1416 --backtitle "$DIALOG_BACKTITLE" \
1417 --hline "$hline" \
1418 --item-help \
1419 --ok-label "$msg_ok" \
1420 --cancel-label "$msg_cancel" \
1421 --help "" \
1422 --menu "$prompt" 21 60 8 \
1444 if [ $retval -eq $DIALOG_HELP ]; then
1447 elif [ $retval -ne $DIALOG_OK ]; then
1514 if [ "$use_dhcp" -o "$_ipaddr" ]; then
1534 # is printed to stderr like other dialog(1)-based functions (stdout is reserved
1541 for __iface in $( ifconfig -l ); do
1583 # Either a comma-separated list of network interfaces to try when
1584 # setting up network access (e.g., "fxp0,em0") or "ANY" (case-
1593 local devs dev cnt if network_dev
1618 f_device_find -1 "$if" $DEVICE_TYPE_NETWORK dev
1620 if [ $? -eq $DIALOG_OK ]; then
1631 f_device_find "" $DEVICE_TYPE_NETWORK devs
1632 f_count cnt $devs
1633 dev="${devs%%[$IFS]*}"
1638 ! [ "${NETWORK_CONFIGURED+set}" -a "$NETWORK_CONFIGURED" = "NO" ]
1649 if [ ${cnt:=0} -eq 0 ]; then
1652 elif [ $cnt -eq 1 ]; then
1655 [ $retval -eq $DIALOG_OK ] && setvar $VAR_NETWORK_DEVICE $if
1669 if [ $retval -eq $DIALOG_OK ]; then