Skip to content

Instantly share code, notes, and snippets.

@huphtur
Created November 7, 2017 23:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huphtur/0fa1034c7e4d11d983232f1c973ece9c to your computer and use it in GitHub Desktop.
Save huphtur/0fa1034c7e4d11d983232f1c973ece9c to your computer and use it in GitHub Desktop.
pi@raspberrypi:~ $ curl -sSL https://install.pi-hole.net | sudo bash -x
+ set -e
+ tmpLog=/tmp/pihole-install.log
+ instalLogLoc=/etc/pihole/install.log
+ setupVars=/etc/pihole/setupVars.conf
+ lighttpdConfig=/etc/lighttpd/lighttpd.conf
+ webInterfaceGitUrl=https://github.com/pi-hole/AdminLTE.git
+ webInterfaceDir=/var/www/html/admin
+ piholeGitUrl=https://github.com/pi-hole/pi-hole.git
+ PI_HOLE_LOCAL_REPO=/etc/.pihole
+ PI_HOLE_FILES=(chronometer list piholeDebug piholeLogFlush setupLCD update version gravity uninstall webpage)
+ PI_HOLE_INSTALL_DIR=/opt/pihole
+ useUpdateVars=false
+ IPV4_ADDRESS=
+ IPV6_ADDRESS=
+ QUERY_LOGGING=true
+ INSTALL_WEB=true
++ stty size
++ echo 24 80
+ screen_size='24 80'
++ echo '24 80'
++ awk '{print $1}'
+ rows=24
++ awk '{print $2}'
++ echo '24 80'
+ columns=80
+ r=12
+ c=40
+ r=20
+ c=70
+ skipSpaceCheck=false
+ reconfigure=false
+ runUnattended=false
+ [[ '' != true ]]
+ main
+ show_ascii_berry
+ echo '
.;;,.
.ccccc:,.
:cccclll:. ..,,
:ccccclll. ;ooodc
'\''ccll:;ll .oooodc
.;cll.;;looo:.
.. '\'','\''.
.'\'',,,,,,'\''.
.'\'',,,,,,,,,,.
.'\'',,,,,,,,,,,,....
....'\'''\'''\'',,,,,,,'\''.......
......... .... .........
.......... ..........
.......... ..........
......... .... .........
........,,,,,,,'\''......
....'\'',,,,,,,,,,,,.
.'\'',,,,,,,,,'\''.
.'\'',,,,,,'\''.
..'\'''\'''\''.
'
.;;,.
.ccccc:,.
:cccclll:. ..,,
:ccccclll. ;ooodc
'ccll:;ll .oooodc
.;cll.;;looo:.
.. ','.
.',,,,,,'.
.',,,,,,,,,,.
.',,,,,,,,,,,,....
....''',,,,,,,'.......
......... .... .........
.......... ..........
.......... ..........
......... .... .........
........,,,,,,,'......
....',,,,,,,,,,,,.
.',,,,,,,,,'.
.',,,,,,'.
..'''.
+ echo :::
:::
+ [[ 0 -eq 0 ]]
+ echo '::: You are root.'
::: You are root.
+ distro_check
+ command -v apt-get
+ PKG_MANAGER=apt-get
+ UPDATE_PKG_CACHE='apt-get update'
+ PKG_INSTALL=(${PKG_MANAGER} --yes --no-install-recommends install)
+ PKG_COUNT='apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst || true'
+ apt-get install --dry-run iproute2
+ iproute_pkg=iproute2
+ apt-get install --dry-run php
+ phpVer=php
+ INSTALLER_DEPS=(apt-utils dialog debconf dhcpcd5 git ${iproute_pkg} whiptail)
+ PIHOLE_DEPS=(bc cron curl dnsmasq dnsutils iputils-ping lsof netcat sudo unzip wget)
+ PIHOLE_WEB_DEPS=(lighttpd ${phpVer}-common ${phpVer}-cgi)
+ LIGHTTPD_USER=www-data
+ LIGHTTPD_GROUP=www-data
+ LIGHTTPD_CFG=lighttpd.conf.debian
+ DNSMASQ_USER=dnsmasq
+ [[ -f /etc/pihole/setupVars.conf ]]
+ [[ false == true ]]
+ verifyFreeDiskSpace
+ echo '::: Verifying free disk space...'
::: Verifying free disk space...
+ local required_free_kilobytes=51200
++ grep -m1 '\/$'
++ awk '{print $4}'
++ df -Pk
+ local existing_free_kilobytes=23340816
+ [[ 23340816 =~ ^([0-9])+$ ]]
+ [[ 23340816 -lt 51200 ]]
+ update_package_cache
+ echo :::
:::
+ echo -n '::: Updating local cache of available packages...'
::: Updating local cache of available packages...+ eval 'apt-get update'
+ echo ' done!'
done!
+ notify_package_updates_available
+ echo :::
:::
+ echo -n '::: Checking apt-get for upgraded packages....'
::: Checking apt-get for upgraded packages....++ eval 'apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst || true'
+++ apt-get -s -o Debug::NoLocking=true upgrade
+++ grep -c '^Inst'
+++ true
+ updatesToInstall=0
+ echo ' done!'
done!
+ echo :::
:::
++ uname -r
+ [[ -d /lib/modules/4.9.59-v7+ ]]
+ [[ 0 -eq 0 ]]
+ echo '::: Your system is up to date! Continuing with Pi-hole installation...'
::: Your system is up to date! Continuing with Pi-hole installation...
+ install_dependent_packages 'INSTALLER_DEPS[@]'
+ argArray1=("${!1}")
+ declare -a argArray1
+ declare -a installArray
+ command -v debconf-apt-progress
+ for i in "${argArray1[@]}"
+ echo -n '::: Checking for apt-utils...'
::: Checking for apt-utils...+ dpkg-query -W '-f=${Status}' apt-utils
+ grep 'ok installed'
+ echo ' installed!'
installed!
+ for i in "${argArray1[@]}"
+ echo -n '::: Checking for dialog...'
::: Checking for dialog...+ dpkg-query -W '-f=${Status}' dialog
+ grep 'ok installed'
+ echo ' added to install list!'
added to install list!
+ installArray+=("${i}")
+ for i in "${argArray1[@]}"
+ echo -n '::: Checking for debconf...'
::: Checking for debconf...+ dpkg-query -W '-f=${Status}' debconf
+ grep 'ok installed'
+ echo ' installed!'
installed!
+ for i in "${argArray1[@]}"
+ echo -n '::: Checking for dhcpcd5...'
::: Checking for dhcpcd5...+ dpkg-query -W '-f=${Status}' dhcpcd5
+ grep 'ok installed'
+ echo ' installed!'
installed!
+ for i in "${argArray1[@]}"
+ echo -n '::: Checking for git...'
::: Checking for git...+ dpkg-query -W '-f=${Status}' git
+ grep 'ok installed'
+ echo ' installed!'
installed!
+ for i in "${argArray1[@]}"
+ echo -n '::: Checking for iproute2...'
::: Checking for iproute2...+ dpkg-query -W '-f=${Status}' iproute2
+ grep 'ok installed'
+ echo ' installed!'
installed!
+ for i in "${argArray1[@]}"
+ echo -n '::: Checking for whiptail...'
::: Checking for whiptail...+ dpkg-query -W '-f=${Status}' whiptail
+ grep 'ok installed'
+ echo ' installed!'
installed!
+ [[ 1 -gt 0 ]]
+ test_dpkg_lock
+ i=0
+ fuser /var/lib/dpkg/lock
+ return 0
+ debconf-apt-progress -- apt-get --yes --no-install-recommends install dialog
+ return
+ checkSelinux
+ command -v getenforce
+ [[ false == false ]]
+ welcomeDialogs
+ whiptail --msgbox --backtitle Welcome --title 'Pi-hole automated installer' '\n\nThis installer will transform your device into a network-wide ad blocker!' 20 70
+ whiptail --msgbox --backtitle Plea --title 'Free and open source' '\n\nThe Pi-hole is free, but powered by your donations: http://pi-hole.net/donate' 20 70
+ whiptail --msgbox --backtitle 'Initiating network interface' --title 'Static IP Needed' '\n\nThe Pi-hole is a SERVER so it needs a STATIC IP ADDRESS to function properly.
In the next section, you can choose to use your current network settings (DHCP) or to manually edit them.' 20 70
+ mkdir -p /etc/pihole/
+ stop_service dnsmasq
+ echo :::
:::
+ echo -n '::: Stopping dnsmasq service...'
::: Stopping dnsmasq service...+ command -v systemctl
+ systemctl stop dnsmasq
+ true
+ echo ' done.'
done.
+ [[ true == true ]]
+ stop_service lighttpd
+ echo :::
:::
+ echo -n '::: Stopping lighttpd service...'
::: Stopping lighttpd service...+ command -v systemctl
+ systemctl stop lighttpd
+ true
+ echo ' done.'
done.
+ get_available_interfaces
++ ip --oneline link show up
++ grep -v lo
++ cut -d: -f1
++ cut -d@ -f1
++ awk '{print $2}'
+ availableInterfaces='eth0
wlan0'
+ chooseInterface
+ interfacesArray=()
+ local interfacesArray
+ local interfaceCount
+ local chooseInterfaceCmd
+ local chooseInterfaceOptions
+ local firstLoop=1
++ echo 'eth0
wlan0'
++ wc -l
+ interfaceCount=2
+ [[ 2 -eq 1 ]]
+ read -r line
+ mode=OFF
+ [[ 1 -eq 1 ]]
+ firstLoop=0
+ mode=ON
+ interfacesArray+=("${line}" "available" "${mode}")
+ read -r line
+ mode=OFF
+ [[ 0 -eq 1 ]]
+ interfacesArray+=("${line}" "available" "${mode}")
+ read -r line
+ chooseInterfaceCmd=(whiptail --separate-output --radiolist "Choose An Interface (press space to select)" ${r} ${c} ${interfaceCount})
++ whiptail --separate-output --radiolist 'Choose An Interface (press space to select)' 20 70 2 eth0 available ON wlan0 available OFF
+ chooseInterfaceOptions=wlan0
+ for desiredInterface in ${chooseInterfaceOptions}
+ PIHOLE_INTERFACE=wlan0
+ echo '::: Using interface: wlan0'
::: Using interface: wlan0
+ setDNS
+ local DNSSettingsCorrect
+ DNSChooseOptions=(Google "" OpenDNS "" Level3 "" Norton "" Comodo "" DNSWatch "" Custom "")
++ whiptail --separate-output --menu 'Select Upstream DNS Provider. To use your own, select Custom.' 20 70 6 Google '' OpenDNS '' Level3 '' Norton '' Comodo '' DNSWatch '' Custom ''
+ DNSchoices=Google
+ case ${DNSchoices} in
+ echo '::: Using Google DNS servers.'
::: Using Google DNS servers.
+ PIHOLE_DNS_1=8.8.8.8
+ PIHOLE_DNS_2=8.8.4.4
+ use4andor6
+ local useIPv4
+ local useIPv6
+ cmd=(whiptail --separate-output --checklist "Select Protocols (press space to select)" ${r} ${c} 2)
+ options=(IPv4 "Block ads over IPv4" on IPv6 "Block ads over IPv6" on)
++ whiptail --separate-output --checklist 'Select Protocols (press space to select)' 20 70 2 IPv4 'Block ads over IPv4' on IPv6 'Block ads over IPv6' on
+ choices='IPv4
IPv6'
+ for choice in ${choices}
+ case ${choice} in
+ useIPv4=true
+ for choice in ${choices}
+ case ${choice} in
+ useIPv6=true
+ [[ -n true ]]
+ find_IPv4_information
+ local route
++ ip route get 8.8.8.8
+ route='8.8.8.8 via 192.168.1.1 dev eth0 src 192.168.1.22
cache '
++ awk '{for (i=1; i<=NF; i++) if ($i~/dev/) print $(i+1)}'
+ IPv4dev=eth0
++ awk '{print $7}'
+ IPv4bare=192.168.1.22
++ ip -o -f inet addr show
++ grep 192.168.1.22
++ awk '{print $4}'
++ awk 'END {print}'
+ IPV4_ADDRESS=192.168.1.22/24
++ awk '{print $3}'
+ IPv4gw=192.168.1.1
+ getStaticIPv4Settings
+ local ipSettingsCorrect
+ whiptail --backtitle 'Calibrating network interface' --title 'Static IP Address' --yesno 'Do you want to use your current network settings as a static address?
IP address: 192.168.1.22/24
Gateway: 192.168.1.1' 20 70
+ whiptail --msgbox --backtitle 'IP information' --title 'FYI: IP Conflict' 'It is possible your router could still try to assign this IP to a device, which would cause a conflict. But in most cases the router is smart enough to not do that.
If you are worried, either manually set the address, or modify the DHCP reservation pool so it does not include the IP you want.
It is also possible to use a DHCP reservation, but if you are going to do that, you might as well set a static address.' 20 70
+ setStaticIPv4
+ local IFCFG_FILE
+ local IPADDR
+ local CIDR
+ [[ -f /etc/dhcpcd.conf ]]
+ grep -q 192.168.1.22/24 /etc/dhcpcd.conf
+ setDHCPCD
+ tee -a /etc/dhcpcd.conf
+ echo 'interface wlan0
static ip_address=192.168.1.22/24
static routers=192.168.1.1
static domain_name_servers=127.0.0.1'
+ ip addr replace dev wlan0 192.168.1.22/24
+ echo :::
:::
+ echo '::: Setting IP to 192.168.1.22/24. You may need to restart after the install is complete.'
::: Setting IP to 192.168.1.22/24. You may need to restart after the install is complete.
+ echo :::
:::
+ [[ -n true ]]
+ useIPv6dialog
+ IPV6_ADDRESSES=($(ip -6 address | grep 'scope global' | awk '{print $2}'))
++ ip -6 address
++ awk '{print $2}'
++ grep 'scope global'
+ [[ ! -z '' ]]
+ [[ ! -z '' ]]
+ echo '::: Found neither IPv6 ULA nor GUA address, blocking IPv6 ads will not be enabled'
::: Found neither IPv6 ULA nor GUA address, blocking IPv6 ads will not be enabled
+ IPV6_ADDRESS=
+ [[ ! -z '' ]]
+ echo '::: IPv4 address: 192.168.1.22/24'
::: IPv4 address: 192.168.1.22/24
+ echo '::: IPv6 address: '
::: IPv6 address:
+ '[' '!' true ']'
+ setAdminFlag
+ local WebToggleCommand
+ local WebChooseOptions
+ local WebChoices
+ WebToggleCommand=(whiptail --separate-output --radiolist "Do you wish to install the web admin interface?" ${r} ${c} 6)
+ WebChooseOptions=("On (Recommended)" "" on Off "" off)
++ whiptail --separate-output --radiolist 'Do you wish to install the web admin interface?' 20 70 6 'On (Recommended)' '' on Off '' off
+ WebChoices='On (Recommended)'
+ case ${WebChoices} in
+ echo '::: Web Interface On.'
::: Web Interface On.
+ INSTALL_WEB=true
+ setLogging
+ local LogToggleCommand
+ local LogChooseOptions
+ local LogChoices
+ LogToggleCommand=(whiptail --separate-output --radiolist "Do you want to log queries?\n (Disabling will render graphs on the Admin page useless):" ${r} ${c} 6)
+ LogChooseOptions=("On (Recommended)" "" on Off "" off)
++ whiptail --separate-output --radiolist 'Do you want to log queries?\n (Disabling will render graphs on the Admin page useless):' 20 70 6 'On (Recommended)' '' on Off '' off
+ LogChoices='On (Recommended)'
+ case ${LogChoices} in
+ echo '::: Logging On.'
::: Logging On.
+ QUERY_LOGGING=true
+ clone_or_update_repos
+ [[ false == true ]]
+ getGitFiles /etc/.pihole https://github.com/pi-hole/pi-hole.git
+ local directory=/etc/.pihole
+ local remoteRepo=https://github.com/pi-hole/pi-hole.git
+ echo :::
:::
+ echo '::: Checking for existing repository...'
::: Checking for existing repository...
+ is_repo /etc/.pihole
+ local directory=/etc/.pihole
+ local curdir
+ local rc
+ curdir=/home/pi
+ [[ -d /etc/.pihole ]]
+ rc=1
+ cd /home/pi
+ return 1
+ make_repo /etc/.pihole https://github.com/pi-hole/pi-hole.git
+ local directory=/etc/.pihole
+ local remoteRepo=https://github.com/pi-hole/pi-hole.git
+ echo -n '::: Cloning https://github.com/pi-hole/pi-hole.git into /etc/.pihole...'
::: Cloning https://github.com/pi-hole/pi-hole.git into /etc/.pihole...+ [[ -d /etc/.pihole ]]
+ git clone -q --depth 1 https://github.com/pi-hole/pi-hole.git /etc/.pihole
+ return 128
+ echo 'Unable to clone repository, please contact support'
Unable to clone repository, please contact support
+ exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment