mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-28 17:13:17 +00:00
Rerunning with sudo is now part of piholeInclude functions.
Changed piholeLogFlush.sh to run as root, not pihole.
This commit is contained in:
parent
cc745d8b37
commit
f02666ef6e
8 changed files with 25 additions and 157 deletions
|
@ -23,28 +23,9 @@ if [[ $# = 0 ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if pihole user, and if not then rerun with sudo.
|
source /usr/local/include/pihole/piholeInclude
|
||||||
echo ":::"
|
|
||||||
runninguser=$(whoami)
|
rerun_pihole "$0" "$@"
|
||||||
if [[ "$runninguser" = "pihole" ]];then
|
|
||||||
echo "::: You are pihole user."
|
|
||||||
# Older versions of Pi-hole set $SUDO="sudo" and prefixed commands with it,
|
|
||||||
# rather than rerunning as sudo. Just in case it turns up by accident,
|
|
||||||
# explicitly set the $SUDO variable to an empty string.
|
|
||||||
SUDO=""
|
|
||||||
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 $0 $@"
|
|
||||||
sudo -u pihole "$0" "$@"
|
|
||||||
exit $?
|
|
||||||
else
|
|
||||||
echo "::: Please install sudo."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
#globals
|
#globals
|
||||||
blacklist=/etc/pihole/blacklist.txt
|
blacklist=/etc/pihole/blacklist.txt
|
||||||
|
|
|
@ -10,28 +10,9 @@
|
||||||
# the Free Software Foundation, either version 2 of the License, or
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
|
|
||||||
# Check if pihole user, and if not then rerun with sudo.
|
source /usr/local/include/pihole/piholeInclude
|
||||||
echo ":::"
|
|
||||||
runninguser=$(whoami)
|
rerun_pihole "$0" "$@"
|
||||||
if [[ "$runninguser" = "pihole" ]];then
|
|
||||||
echo "::: You are pihole user."
|
|
||||||
# Older versions of Pi-hole set $SUDO="sudo" and prefixed commands with it,
|
|
||||||
# rather than rerunning as sudo. Just in case it turns up by accident,
|
|
||||||
# explicitly set the $SUDO variable to an empty string.
|
|
||||||
SUDO=""
|
|
||||||
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 $0 $@"
|
|
||||||
sudo -u pihole "$0" "$@"
|
|
||||||
exit $?
|
|
||||||
else
|
|
||||||
echo "::: Please install sudo."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
#Functions##############################################################################################################
|
#Functions##############################################################################################################
|
||||||
piLog="/var/log/pihole.log"
|
piLog="/var/log/pihole.log"
|
||||||
|
|
|
@ -10,27 +10,8 @@
|
||||||
# the Free Software Foundation, either version 2 of the License, or
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
|
|
||||||
# Check if pihole user, and if not then rerun with sudo.
|
source /usr/local/include/pihole/piholeInclude
|
||||||
echo ":::"
|
|
||||||
runninguser=$(whoami)
|
rerun_root "$0" "$@"
|
||||||
if [[ "$runninguser" = "pihole" ]];then
|
|
||||||
echo "::: You are pihole user."
|
|
||||||
# Older versions of Pi-hole set $SUDO="sudo" and prefixed commands with it,
|
|
||||||
# rather than rerunning as sudo. Just in case it turns up by accident,
|
|
||||||
# explicitly set the $SUDO variable to an empty string.
|
|
||||||
SUDO=""
|
|
||||||
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 $0 $@"
|
|
||||||
sudo -u pihole "$0" "$@"
|
|
||||||
exit $?
|
|
||||||
else
|
|
||||||
echo "::: Please install sudo."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
truncate -s 0 /var/log/pihole.log
|
truncate -s 0 /var/log/pihole.log
|
||||||
|
|
|
@ -10,27 +10,9 @@
|
||||||
# the Free Software Foundation, either version 2 of the License, or
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
|
|
||||||
# Check if root, and if not then rerun with sudo.
|
source /usr/local/include/pihole/piholeInclude
|
||||||
echo ":::"
|
|
||||||
if [[ $EUID -eq 0 ]];then
|
rerun_root "$0" "$@"
|
||||||
echo "::: You are root."
|
|
||||||
# Older versions of Pi-hole set $SUDO="sudo" and prefixed commands with it,
|
|
||||||
# rather than rerunning as sudo. Just in case it turns up by accident,
|
|
||||||
# explicitly set the $SUDO variable to an empty string.
|
|
||||||
SUDO=""
|
|
||||||
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 $0 $@"
|
|
||||||
sudo "$0" "$@"
|
|
||||||
exit $?
|
|
||||||
else
|
|
||||||
echo "::: Please install sudo or run this script as root."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
spinner(){
|
spinner(){
|
||||||
|
|
|
@ -10,27 +10,9 @@
|
||||||
# the Free Software Foundation, either version 2 of the License, or
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
|
|
||||||
# Check if root, and if not then rerun with sudo.
|
source /usr/local/include/pihole/piholeInclude
|
||||||
echo ":::"
|
|
||||||
if [[ $EUID -eq 0 ]];then
|
rerun_root "$0" "$@"
|
||||||
echo "::: You are root."
|
|
||||||
# Older versions of Pi-hole set $SUDO="sudo" and prefixed commands with it,
|
|
||||||
# rather than rerunning as sudo. Just in case it turns up by accident,
|
|
||||||
# explicitly set the $SUDO variable to an empty string.
|
|
||||||
SUDO=""
|
|
||||||
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 $0 $@"
|
|
||||||
sudo "$0" "$@"
|
|
||||||
exit $?
|
|
||||||
else
|
|
||||||
echo "::: Please install sudo or run this script as root."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
chown --recursive root:pihole /etc/pihole
|
chown --recursive root:pihole /etc/pihole
|
||||||
chmod --recursive ug=rwX,o=rX /etc/pihole
|
chmod --recursive ug=rwX,o=rX /etc/pihole
|
||||||
|
|
|
@ -10,27 +10,9 @@
|
||||||
# the Free Software Foundation, either version 2 of the License, or
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
|
|
||||||
# Check if root, and if not then rerun with sudo.
|
source /usr/local/include/pihole/piholeInclude
|
||||||
echo ":::"
|
|
||||||
if [[ $EUID -eq 0 ]];then
|
rerun_root "$0" "$@"
|
||||||
echo "::: You are root."
|
|
||||||
# Older versions of Pi-hole set $SUDO="sudo" and prefixed commands with it,
|
|
||||||
# rather than rerunning as sudo. Just in case it turns up by accident,
|
|
||||||
# explicitly set the $SUDO variable to an empty string.
|
|
||||||
SUDO=""
|
|
||||||
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 $0 $@"
|
|
||||||
sudo "$0" "$@"
|
|
||||||
exit $?
|
|
||||||
else
|
|
||||||
echo "::: Please install sudo or run this script as root."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
############ FUNCTIONS ###########
|
############ FUNCTIONS ###########
|
||||||
# Run this script as root or under sudo
|
# Run this script as root or under sudo
|
||||||
|
|
|
@ -10,6 +10,10 @@
|
||||||
# the Free Software Foundation, either version 2 of the License, or
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
source /usr/local/include/pihole/piholeInclude
|
||||||
|
|
||||||
|
rerun_pihole "$0" "$@"
|
||||||
|
|
||||||
WEB_INTERFACE_GIT_URL="https://github.com/pi-hole/AdminLTE.git"
|
WEB_INTERFACE_GIT_URL="https://github.com/pi-hole/AdminLTE.git"
|
||||||
WEB_INTERFACE_DIR="/var/www/html/admin"
|
WEB_INTERFACE_DIR="/var/www/html/admin"
|
||||||
|
|
||||||
|
@ -23,12 +27,6 @@ main() {
|
||||||
|
|
||||||
prerequisites() {
|
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)
|
# web interface must already exist. this is a (lazy)
|
||||||
# check to make sure pihole is actually installed.
|
# check to make sure pihole is actually installed.
|
||||||
if [ ! -d "$WEB_INTERFACE_DIR" ]; then
|
if [ ! -d "$WEB_INTERFACE_DIR" ]; then
|
||||||
|
|
|
@ -23,28 +23,9 @@ if [[ $# = 0 ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if pihole user, and if not then rerun with sudo.
|
source /usr/local/include/pihole/piholeInclude
|
||||||
echo ":::"
|
|
||||||
runninguser=$(whoami)
|
rerun_pihole "$0" "$@"
|
||||||
if [[ "$runninguser" = "pihole" ]];then
|
|
||||||
echo "::: You are pihole user."
|
|
||||||
# Older versions of Pi-hole set $SUDO="sudo" and prefixed commands with it,
|
|
||||||
# rather than rerunning as sudo. Just in case it turns up by accident,
|
|
||||||
# explicitly set the $SUDO variable to an empty string.
|
|
||||||
SUDO=""
|
|
||||||
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 $0 $@"
|
|
||||||
sudo -u pihole "$0" "$@"
|
|
||||||
exit $?
|
|
||||||
else
|
|
||||||
echo "::: Please install sudo."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
#globals
|
#globals
|
||||||
whitelist=/etc/pihole/whitelist.txt
|
whitelist=/etc/pihole/whitelist.txt
|
||||||
|
|
Loading…
Reference in a new issue