mirror of
https://github.com/pi-hole/pi-hole.git
synced 2025-02-17 17:04:07 +00:00
Forgot to commit the include script.
This commit is contained in:
parent
d0bc596adb
commit
5ecde852a0
1 changed files with 60 additions and 0 deletions
60
advanced/Scripts/piholeInclude
Normal file
60
advanced/Scripts/piholeInclude
Normal file
|
@ -0,0 +1,60 @@
|
|||
#!/usr/bin/env bash
|
||||
# Pi-hole: A black hole for Internet advertisements
|
||||
# (c) 2015, 2016 by Jacob Salmela
|
||||
# Network-wide ad blocking via your Raspberry Pi
|
||||
# http://pi-hole.net
|
||||
# Include for other pihole scripts.
|
||||
#
|
||||
# Pi-hole is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# Older versions of Pi-hole set $SUDO="sudo" and prefixed commands with it,
|
||||
# rather than rerunning with sudo. Just in case it turns up by accident,
|
||||
# explicitly set the $SUDO variable to an empty string.
|
||||
SUDO=""
|
||||
|
||||
function rerun_root() {
|
||||
# Check if root, and if not then rerun with sudo.
|
||||
# The parent script should pass its $0 and $@ to this function's $1 and $2
|
||||
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 [[ $(dpkg-query -s sudo) ]];then
|
||||
echo "::: Running sudo $1 $2"
|
||||
sudo "$1" "$2"
|
||||
exit $?
|
||||
else
|
||||
echo "::: Please install sudo."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function rerun_pihole() {
|
||||
# Check if pihole user, and if not then rerun with sudo.
|
||||
# The parent script should pass its $0 and $@ to this function's $1 and $2
|
||||
echo ":::"
|
||||
runninguser=$(whoami)
|
||||
if [[ "$runninguser" = "pihole" ]];then
|
||||
echo "::: You are pihole user."
|
||||
else
|
||||
echo "::: sudo will be used."
|
||||
# Check if it is actually installed
|
||||
# If it isn't, exit because the install cannot complete
|
||||
if [[ $(dpkg-query -s sudo) ]];then
|
||||
echo "::: Running sudo -u pihole $1 $2"
|
||||
sudo -u pihole "$1" "$2"
|
||||
exit $?
|
||||
else
|
||||
echo "::: Please install sudo."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
Loading…
Add table
Reference in a new issue