Combine multiple calls to interface length code.

&& ||

Signed-off-by: Dan Schaper <dan.schaper@pi-hole.net>
This commit is contained in:
Dan Schaper 2017-01-14 18:23:52 -08:00
parent 9b6427144f
commit 2689b37c35
No known key found for this signature in database
GPG Key ID: 572E999E385B7BFC
1 changed files with 31 additions and 24 deletions

View File

@ -65,12 +65,20 @@ if command -v apt-get &> /dev/null; then
# ######################################### # #########################################
# fixes for dependancy differences # fixes for dependancy differences
# Debian 7 doesn't have iproute2 use iproute # Debian 7 doesn't have iproute2 use iproute
${PKG_MANAGER} install --dry-run iproute2 > /dev/null 2>&1 && IPROUTE_PKG="iproute2" || IPROUTE_PKG="iproute" if ${PKG_MANAGER} install --dry-run iproute2 > /dev/null 2>&1; then
iproute_pkg="iproute2"
else
iproute_pkg="iproute"
fi
# Prefer the php metapackage if it's there, fall back on the php5 pacakges # Prefer the php metapackage if it's there, fall back on the php5 pacakges
${PKG_MANAGER} install --dry-run php > /dev/null 2>&1 && phpVer="php" || phpVer="php5" if ${PKG_MANAGER} install --dry-run php > /dev/null 2>&1; then
phpVer="php"
else
phpVer="php5"
fi
# ######################################### # #########################################
INSTALLER_DEPS=(apt-utils debconf dhcpcd5 git whiptail) INSTALLER_DEPS=(apt-utils debconf dhcpcd5 git whiptail)
PIHOLE_DEPS=(bc cron curl dnsmasq dnsutils ${IPROUTE_PKG} iputils-ping lighttpd lsof netcat ${phpVer}-common ${phpVer}-cgi sudo unzip wget) PIHOLE_DEPS=(bc cron curl dnsmasq dnsutils ${iproute_pkg} iputils-ping lighttpd lsof netcat ${phpVer}-common ${phpVer}-cgi sudo unzip wget)
LIGHTTPD_USER="www-data" LIGHTTPD_USER="www-data"
LIGHTTPD_GROUP="www-data" LIGHTTPD_GROUP="www-data"
LIGHTTPD_CFG="lighttpd.conf.debian" LIGHTTPD_CFG="lighttpd.conf.debian"
@ -239,11 +247,12 @@ chooseInterface() {
# Loop sentinel variable # Loop sentinel variable
local firstLoop=1 local firstLoop=1
if [[ "${#availableInterfaces[@]}" -eq 1 ]]; then # Find out how many interfaces are available to choose from
PIHOLE_INTERFACE="${availableInterfaces}" interfaceCount=$(echo "${availableInterfaces}" | wc -l)
return
fi
if [[ ${interfaceCount} -eq 1 ]]; then
PIHOLE_INTERFACE="${availableInterfaces}"
else
while read -r line; do while read -r line; do
mode="OFF" mode="OFF"
if [[ ${firstLoop} -eq 1 ]]; then if [[ ${firstLoop} -eq 1 ]]; then
@ -253,8 +262,6 @@ chooseInterface() {
interfacesArray+=("${line}" "available" "${mode}") interfacesArray+=("${line}" "available" "${mode}")
done <<< "${availableInterfaces}" done <<< "${availableInterfaces}"
# Find out how many interfaces are available to choose from
interfaceCount=$(echo "${availableInterfaces}" | wc -l)
chooseInterfaceCmd=(whiptail --separate-output --radiolist "Choose An Interface (press space to select)" ${r} ${c} ${interfaceCount}) chooseInterfaceCmd=(whiptail --separate-output --radiolist "Choose An Interface (press space to select)" ${r} ${c} ${interfaceCount})
chooseInterfaceOptions=$("${chooseInterfaceCmd[@]}" "${interfacesArray[@]}" 2>&1 >/dev/tty) || \ chooseInterfaceOptions=$("${chooseInterfaceCmd[@]}" "${interfacesArray[@]}" 2>&1 >/dev/tty) || \
{ echo "::: Cancel selected. Exiting"; exit 1; } { echo "::: Cancel selected. Exiting"; exit 1; }
@ -262,7 +269,7 @@ chooseInterface() {
PIHOLE_INTERFACE=${desiredInterface} PIHOLE_INTERFACE=${desiredInterface}
echo "::: Using interface: $PIHOLE_INTERFACE" echo "::: Using interface: $PIHOLE_INTERFACE"
done done
fi
} }
useIPv6dialog() { useIPv6dialog() {