Merge branch 'master' into whitelist

# Conflicts:
#	gravity.sh
This commit is contained in:
jacobsalmela 2016-01-14 18:12:45 -06:00
parent c88982d0d5
commit ca5e34a9a9
5 changed files with 186 additions and 65 deletions

View file

@ -20,12 +20,9 @@
tmpLog=/tmp/pihole-install.log
instalLogLoc=/etc/pihole/install.log
# Get the screen size in case we need a full-screen message and so we can display a dialog that is sized nicely
screenSize=$(stty -a | tr \; \\012 | egrep 'rows|columns' | cut '-d ' -f3)
# Find the rows and columns
rows=$(stty -a | tr \; \\012 | egrep 'rows' | cut -d' ' -f3)
columns=$(stty -a | tr \; \\012 | egrep 'columns' | cut -d' ' -f3)
rows=$(tput lines)
columns=$(tput cols)
# Divide by two so the dialogs take up half of the screen, which looks nice.
r=$(( rows / 2 ))
@ -36,10 +33,6 @@ IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1
IPv4addr=$(ip -o -f inet addr show dev $IPv4dev | awk '{print $4}' | awk 'END {print}')
IPv4gw=$(ip route get 8.8.8.8 | awk '{print $3}')
# IPv6 support to be added later
#IPv6eui64=$(ip addr show | awk '/scope\ global/ && /ff:fe/ {print $2}' | cut -d'/' -f1)
#IPv6linkLocal=$(ip addr show | awk '/inet/ && /scope\ link/ && /fe80/ {print $2}' | cut -d'/' -f1)
availableInterfaces=$(ip -o link | awk '{print $2}' | grep -v "lo" | cut -d':' -f1)
dhcpcdFile=/etc/dhcpcd.conf
@ -65,6 +58,9 @@ welcomeDialogs()
# Display the welcome dialog
whiptail --msgbox --backtitle "Welcome" --title "Pi-hole automated installer" "This installer will transform your Raspberry Pi into a network-wide ad blocker!" $r $c
# Support for a part-time dev
whiptail --msgbox --backtitle "Plea" --title "Free and open source" "The Pi-hole is free, but powered by your donations: http://pi-hole.net/donate" $r $c
# Explain the need for a static address
whiptail --msgbox --backtitle "Initating network interface" --title "Static IP Needed" "The Pi-hole is a SERVER so it needs a STATIC IP ADDRESS to function properly.
@ -75,9 +71,16 @@ chooseInterface()
{
# Turn the available interfaces into an array so it can be used with a whiptail dialog
interfacesArray=()
firstloop=1
while read -r line
do
interfacesArray+=("$line" "available" "ON")
mode="OFF"
if [[ $firstloop -eq 1 ]]; then
firstloop=0
mode="ON"
fi
interfacesArray+=("$line" "available" "$mode")
done <<< "$availableInterfaces"
# Find out how many interfaces are available to choose from
@ -97,7 +100,7 @@ use4andor6()
# Let use select IPv4 and/or IPv6
cmd=(whiptail --separate-output --checklist "Select Protocols" $r $c 2)
options=(IPv4 "Block ads over IPv4" on
IPv6 "Block ads over IPv4" off)
IPv6 "Block ads over IPv6" off)
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
for choice in $choices
do
@ -116,7 +119,10 @@ done
useIPv6dialog()
{
whiptail --msgbox --backtitle "Coming soon..." --title "IPv6 not yet supported" "I need your help for IPv6. Consider donating at: http://pi-hole.net/donate" $r $c
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
whiptail --msgbox --backtitle "IPv6..." --title "IPv6 Supported" "$piholeIPv6 will be used to block ads." $r $c
sudo mkdir -p /etc/pihole/
sudo touch /etc/pihole/.useIPv6
}
getStaticIPv4Settings()
@ -231,6 +237,9 @@ sudo wget https://github.com/jacobsalmela/AdminLTE/archive/master.zip -O /var/ww
sudo unzip -oq /var/www/master.zip -d /var/www/html/
sudo mv /var/www/html/AdminLTE-master /var/www/html/admin
sudo rm /var/www/master.zip 2>/dev/null
sudo touch /var/log/pihole.log
sudo chmod 644 /var/log/pihole.log
sudo chown dnsmasq:root /var/log/pihole.log
}
installPiholeWeb(){
@ -260,6 +269,17 @@ installCron
sudo /usr/local/bin/gravity.sh
}
displayFinalMessage(){
whiptail --msgbox --backtitle "Make it so." --title "Installation Complete!" "Configure your devices to use the Pi-hole as their DNS server using:
$IPv4addr
$piholeIPv6
If you set a new IP address, you should restart the Pi.
The install log is in /etc/pihole." $r $c
}
######## SCRIPT ############
# Start the installer
welcomeDialogs
@ -285,16 +305,12 @@ fi
# Decide is IPv6 will be used
if [[ "$useIPv6" = true ]];then
# If only IPv6 is selected, exit because it is not supported yet
if [[ "$useIPv6" = true ]] && [[ "$useIPv4" = false ]];then
useIPv6dialog
exit
else
useIPv6dialog
fi
useIPv6dialog
echo "Using IPv6."
echo "Your IPv6 address is: $piholeIPv6"
else
useIPv6=false
echo "IPv6 will NOT be used. Consider a donation at pi-hole.net/donate"
echo "IPv6 will NOT be used."
fi
# Install and log everything to a file
@ -303,11 +319,7 @@ installPihole | tee $tmpLog
# Move the log file into /etc/pihole for storage
sudo mv $tmpLog $instalLogLoc
whiptail --msgbox --backtitle "Make it so." --title "Installation Complete!" "Configure your devices to use the Pi-hole as their DNS server using this IP: $IPv4addr.
If you set a new IP address, it should work fine, but you may want to reboot the Pi at some point.
The install log is in /etc/pihole." $r $c
displayFinalMessage
sudo service dnsmasq start
sudo service lighttpd start

View file

@ -0,0 +1,70 @@
#!/usr/bin/env bash
#
# this script will update the pihole web interface files.
#
# if this is the first time running this script after an
# existing installation, the existing web interface files
# will be removed and replaced with the latest master
# branch from github. subsequent executions of this script
# will pull the latest version of the web interface.
#
# @TODO: add git as requirement to basic-install.sh
#
WEB_INTERFACE_GIT_URL="https://github.com/jacobsalmela/AdminLTE.git"
WEB_INTERFACE_DIR="/var/www/html/admin"
main() {
prerequisites
if ! is_repo; then
make_repo
fi
update_repo
}
prerequisites() {
# must be root to update
if [[ $EUID -ne 0 ]]; then
sudo bash "$0" "$@"
exit $?
fi
# web interface must already exist. this is a (lazy)
# check to make sure pihole is actually installed.
if [ ! -d "$WEB_INTERFACE_DIR" ]; then
echo "$WEB_INTERFACE_DIR not found. Exiting."
exit 1
fi
if ! type "git" > /dev/null; then
apt-get -y install git
fi
}
is_repo() {
# if the web interface directory does not have a .git folder
# it means its using the master.zip archive from the install
# script.
if [ ! -d "$WEB_INTERFACE_DIR/.git" ]; then
return 1
fi
return 0
}
# removes the web interface installed from the master.zip archive and
# replaces it with the current master branch from github
make_repo() {
# remove the non-repod interface and clone the interface
rm -rf $WEB_INTERFACE_DIR
git clone "$WEB_INTERFACE_GIT_URL" "$WEB_INTERFACE_DIR"
}
# pulls the latest master branch from github
update_repo() {
# pull the latest commits
cd "$WEB_INTERFACE_DIR"
git pull
}
main