Bring dev branch up to date with master bug fixes

This commit is contained in:
Promofaux 2016-02-09 20:44:49 +00:00
commit 255706e173
3 changed files with 45 additions and 34 deletions

View file

@ -303,35 +303,40 @@ setDNS(){
}
versionCheckDNSmasq(){
# Check if /etc/dnsmasq.conf is from pihole. If so replace with an original and install new in .d directory
dnsFile1="/etc/dnsmasq.conf"
dnsFile2="/etc/dnsmasq.conf.orig"
dnsSearch="addn-hosts=/etc/pihole/gravity.list"
# Check if /etc/dnsmasq.conf exists
if [ -d "/etc/dnsmasq.conf" ]; then
# If true, Check dnsmasq.conf for pihole magic
if grep -q $dnsSearch $dnsFile1; then
# If true, Check dnsmasq.conf.orig for pihole magic
if grep -q $dnsSearch $dnsFile2; then
# If true, use advanced/dnsmasq.conf.original
$SUDO mv -f /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
$SUDO cp /etc/.pihole/advanced/dnsmasq.conf.original /etc/dnsmasq.conf
else
# If false, mv original file back
$SUDO mv -f /etc/dnsmasq.conf.orig /etc/dnsmasq.conf
fi
# If false, This is a fresh install
fi
else
# If false, use advanced/dnsmasq.conf.original
$SUDO cp /etc/.pihole/advanced/dnsmasq.conf.original /etc/dnsmasq.conf
fi
$SUDO cp /etc/.pihole/advanced/01-pihole.conf /etc/dnsmasq.d/01-pihole.conf
$SUDO sed -i "s/@INT@/$piholeInterface/" /etc/dnsmasq.d/01-pihole.conf
$SUDO sed -i "s/@DNS1@/$piholeDNS1/" /etc/dnsmasq.d/01-pihole.conf
$SUDO sed -i "s/@DNS2@/$piholeDNS2/" /etc/dnsmasq.d/01-pihole.conf
# Check if /etc/dnsmasq.conf is from pihole. If so replace with an original and install new in .d directory
dnsFile1="/etc/dnsmasq.conf"
dnsFile2="/etc/dnsmasq.conf.orig"
dnsSearch="addn-hosts=/etc/pihole/gravity.list"
defaultFile="/etc/.pihole/advanced/dnsmasq.conf.original"
newFileToInstall="/etc/.pihole/advanced/01-pihole.conf"
newFileFinalLocation="/etc/dnsmasq.d/01-pihole.conf"
if [ -f $dnsFile1 ]; then
echo -n "::: Existing dnsmasq.conf found..."
if grep -q $dnsSearch $dnsFile1; then
echo " it is from a previous pi-hole install."
echo -n "::: Backing up dnsmasq.conf to dnsmasq.conf.orig..."
$SUDO mv -f $dnsFile1 $dnsFile2
echo " done."
echo -n "::: Restoring default dnsmasq.conf..."
$SUDO cp $defaultFile $dnsFile1
echo " done."
else
echo " it is not a pi-hole file, leaving alone!"
fi
else
echo -n "::: No dnsmasq.conf found.. restoring default dnsmasq.conf..."
$SUDO cp $defaultFile $dnsFile1
echo " done."
fi
echo -n "::: Copying 01-pihole.conf to /etc/dnsmasq.d/01-pihole.conf..."
$SUDO cp $newFileToInstall $newFileFinalLocation
echo " done."
$SUDO sed -i "s/@INT@/$piholeInterface/" $newFileFinalLocation
$SUDO sed -i "s/@DNS1@/$piholeDNS1/" $newFileFinalLocation
$SUDO sed -i "s/@DNS2@/$piholeDNS2/" $newFileFinalLocation
}
installScripts() {
@ -351,11 +356,10 @@ installScripts() {
installConfigs() {
# Install the configs from /etc/.pihole to their various locations
$SUDO echo ":::"
$SUDO echo -n "::: Installing configs..."
$SUDO echo "::: Installing configs..."
versionCheckDNSmasq
$SUDO mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig
$SUDO cp /etc/.pihole/advanced/lighttpd.conf /etc/lighttpd/lighttpd.conf
$SUDO echo " done."
}
stopServices() {
@ -389,7 +393,7 @@ checkForDependencies() {
fi
echo ":::"
echo -n "::: Checking apt-get for upgraded packages...."
updatesToInstall=$(sudo apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst)
updatesToInstall=$($SUDO apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst)
echo " done!"
echo ":::"
if [[ $updatesToInstall -eq "0" ]]; then