remove uses of ${SUDO} and root check from gravity. As this is handled by pihole command.

This commit is contained in:
Promofaux 2016-10-15 18:42:53 +01:00
parent 090fbd04af
commit 4c42f00a86

View file

@ -13,20 +13,6 @@
# Run this script as root or under sudo # Run this script as root or under sudo
echo ":::" echo ":::"
if [[ $EUID -eq 0 ]];then
echo "::: You are root."
else
echo "::: sudo will be used."
# Check if it is actually installed
# If it isn't, exit because the install cannot complete
if [ -x "$(command -v sudo)" ];then
export SUDO="sudo"
else
echo "::: Please install sudo or run this script as root."
exit 1
fi
fi
function helpFunc() function helpFunc()
{ {
echo "::: Pull in domains from adlists" echo "::: Pull in domains from adlists"
@ -105,13 +91,13 @@ function gravity_collapse() {
# Temporary hack to allow non-root access to pihole directory # Temporary hack to allow non-root access to pihole directory
# Will update later, needed for existing installs, new installs should # Will update later, needed for existing installs, new installs should
# create this directory as non-root # create this directory as non-root
${SUDO} chmod 777 ${piholeDir} chmod 777 ${piholeDir}
echo ":::" echo ":::"
echo "::: Existing pihole directory found" echo "::: Existing pihole directory found"
else else
echo "::: Creating pihole directory..." echo "::: Creating pihole directory..."
mkdir ${piholeDir} mkdir ${piholeDir}
${SUDO} chmod 777 ${piholeDir} chmod 777 ${piholeDir}
fi fi
} }
@ -305,7 +291,7 @@ function gravity_reload() {
#Clear no longer needed files... #Clear no longer needed files...
echo ":::" echo ":::"
echo -n "::: Cleaning up un-needed files..." echo -n "::: Cleaning up un-needed files..."
${SUDO} rm ${piholeDir}/pihole.*.txt rm ${piholeDir}/pihole.*.txt
echo " done!" echo " done!"
# Reload hosts file # Reload hosts file
@ -316,17 +302,17 @@ function gravity_reload() {
#First escape forward slashes in the path: #First escape forward slashes in the path:
adList=${adList//\//\\\/} adList=${adList//\//\\\/}
#Now replace the line in dnsmasq file #Now replace the line in dnsmasq file
${SUDO} sed -i "s/^addn-hosts.*/addn-hosts=$adList/" /etc/dnsmasq.d/01-pihole.conf sed -i "s/^addn-hosts.*/addn-hosts=$adList/" /etc/dnsmasq.d/01-pihole.conf
dnsmasqPid=$(pidof dnsmasq) dnsmasqPid=$(pidof dnsmasq)
find "$piholeDir" -type f -exec ${SUDO} chmod 666 {} \; find "$piholeDir" -type f -exec chmod 666 {} \;
if [[ ${dnsmasqPid} ]]; then if [[ ${dnsmasqPid} ]]; then
# service already running - reload config # service already running - reload config
${SUDO} killall -s HUP dnsmasq killall -s HUP dnsmasq
else else
# service not running, start it up # service not running, start it up
${SUDO} service dnsmasq start service dnsmasq start
fi fi
echo " done!" echo " done!"
} }
@ -342,12 +328,12 @@ done
if [[ ${forceGrav} == true ]]; then if [[ ${forceGrav} == true ]]; then
echo -n "::: Deleting exising list cache..." echo -n "::: Deleting exising list cache..."
${SUDO} rm /etc/pihole/list.* rm /etc/pihole/list.*
echo " done!" echo " done!"
fi fi
#Overwrite adlists.default from /etc/.pihole in case any changes have been made. Changes should be saved in /etc/adlists.list #Overwrite adlists.default from /etc/.pihole in case any changes have been made. Changes should be saved in /etc/adlists.list
${SUDO} cp /etc/.pihole/adlists.default /etc/pihole/adlists.default cp /etc/.pihole/adlists.default /etc/pihole/adlists.default
gravity_collapse gravity_collapse
gravity_spinup gravity_spinup
gravity_Schwarzchild gravity_Schwarzchild