Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c93c4cc5e6 | ||
|
|
06cba7defd | ||
|
|
8b76bbe51d | ||
|
|
aa1d3a4c2e |
@@ -303,35 +303,40 @@ setDNS(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
versionCheckDNSmasq(){
|
versionCheckDNSmasq(){
|
||||||
# Check if /etc/dnsmasq.conf is from pihole. If so replace with an original and install new in .d directory
|
# Check if /etc/dnsmasq.conf is from pihole. If so replace with an original and install new in .d directory
|
||||||
dnsFile1="/etc/dnsmasq.conf"
|
dnsFile1="/etc/dnsmasq.conf"
|
||||||
dnsFile2="/etc/dnsmasq.conf.orig"
|
dnsFile2="/etc/dnsmasq.conf.orig"
|
||||||
dnsSearch="addn-hosts=/etc/pihole/gravity.list"
|
dnsSearch="addn-hosts=/etc/pihole/gravity.list"
|
||||||
|
|
||||||
# Check if /etc/dnsmasq.conf exists
|
defaultFile="/etc/.pihole/advanced/dnsmasq.conf.original"
|
||||||
if [ -d "/etc/dnsmasq.conf" ]; then
|
newFileToInstall="/etc/.pihole/advanced/01-pihole.conf"
|
||||||
# If true, Check dnsmasq.conf for pihole magic
|
newFileFinalLocation="/etc/dnsmasq.d/01-pihole.conf"
|
||||||
if grep -q $dnsSearch $dnsFile1; then
|
|
||||||
# If true, Check dnsmasq.conf.orig for pihole magic
|
if [ -f $dnsFile1 ]; then
|
||||||
if grep -q $dnsSearch $dnsFile2; then
|
echo -n "::: Existing dnsmasq.conf found..."
|
||||||
# If true, use advanced/dnsmasq.conf.original
|
if grep -q $dnsSearch $dnsFile1; then
|
||||||
$SUDO mv -f /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
|
echo " it is from a previous pi-hole install."
|
||||||
$SUDO cp /etc/.pihole/advanced/dnsmasq.conf.original /etc/dnsmasq.conf
|
echo -n "::: Backing up dnsmasq.conf to dnsmasq.conf.orig..."
|
||||||
else
|
$SUDO mv -f $dnsFile1 $dnsFile2
|
||||||
# If false, mv original file back
|
echo " done."
|
||||||
$SUDO mv -f /etc/dnsmasq.conf.orig /etc/dnsmasq.conf
|
echo -n "::: Restoring default dnsmasq.conf..."
|
||||||
fi
|
$SUDO cp $defaultFile $dnsFile1
|
||||||
# If false, This is a fresh install
|
echo " done."
|
||||||
fi
|
else
|
||||||
else
|
echo " it is not a pi-hole file, leaving alone!"
|
||||||
# If false, use advanced/dnsmasq.conf.original
|
fi
|
||||||
$SUDO cp /etc/.pihole/advanced/dnsmasq.conf.original /etc/dnsmasq.conf
|
else
|
||||||
fi
|
echo -n "::: No dnsmasq.conf found.. restoring default dnsmasq.conf..."
|
||||||
|
$SUDO cp $defaultFile $dnsFile1
|
||||||
$SUDO cp /etc/.pihole/advanced/01-pihole.conf /etc/dnsmasq.d/01-pihole.conf
|
echo " done."
|
||||||
$SUDO sed -i "s/@INT@/$piholeInterface/" /etc/dnsmasq.d/01-pihole.conf
|
fi
|
||||||
$SUDO sed -i "s/@DNS1@/$piholeDNS1/" /etc/dnsmasq.d/01-pihole.conf
|
|
||||||
$SUDO sed -i "s/@DNS2@/$piholeDNS2/" /etc/dnsmasq.d/01-pihole.conf
|
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() {
|
installScripts() {
|
||||||
@@ -351,11 +356,10 @@ installScripts() {
|
|||||||
installConfigs() {
|
installConfigs() {
|
||||||
# Install the configs from /etc/.pihole to their various locations
|
# Install the configs from /etc/.pihole to their various locations
|
||||||
$SUDO echo ":::"
|
$SUDO echo ":::"
|
||||||
$SUDO echo -n "::: Installing configs..."
|
$SUDO echo "::: Installing configs..."
|
||||||
versionCheckDNSmasq
|
versionCheckDNSmasq
|
||||||
$SUDO mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig
|
$SUDO mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig
|
||||||
$SUDO cp /etc/.pihole/advanced/lighttpd.conf /etc/lighttpd/lighttpd.conf
|
$SUDO cp /etc/.pihole/advanced/lighttpd.conf /etc/lighttpd/lighttpd.conf
|
||||||
$SUDO echo " done."
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stopServices() {
|
stopServices() {
|
||||||
|
|||||||
Reference in New Issue
Block a user