mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 10:43:55 +00:00
Merge branch 'development' of github.com:pi-hole/pi-hole into fix/firewall_redux
This commit is contained in:
commit
de6ce276d0
1 changed files with 67 additions and 56 deletions
|
@ -36,8 +36,8 @@ QUERY_LOGGING=true
|
||||||
|
|
||||||
# Find the rows and columns will default to 80x24 is it can not be detected
|
# Find the rows and columns will default to 80x24 is it can not be detected
|
||||||
screen_size=$(stty size 2>/dev/null || echo 24 80)
|
screen_size=$(stty size 2>/dev/null || echo 24 80)
|
||||||
rows=$(echo $screen_size | awk '{print $1}')
|
rows=$(echo "${screen_size}" | awk '{print $1}')
|
||||||
columns=$(echo $screen_size | awk '{print $2}')
|
columns=$(echo "${screen_size}" | awk '{print $2}')
|
||||||
|
|
||||||
# Divide by two so the dialogs take up half of the screen, which looks nice.
|
# Divide by two so the dialogs take up half of the screen, which looks nice.
|
||||||
r=$(( rows / 2 ))
|
r=$(( rows / 2 ))
|
||||||
|
@ -51,28 +51,6 @@ skipSpaceCheck=false
|
||||||
reconfigure=false
|
reconfigure=false
|
||||||
runUnattended=false
|
runUnattended=false
|
||||||
|
|
||||||
######## FIRST CHECK ########
|
|
||||||
# Must be root to install
|
|
||||||
echo ":::"
|
|
||||||
if [[ ${EUID} -eq 0 ]]; then
|
|
||||||
echo "::: You are root."
|
|
||||||
else
|
|
||||||
echo "::: Script called with non-root privileges. The Pi-hole installs server packages and configures"
|
|
||||||
echo "::: system networking, it requires elevated rights. Please check the contents of the script for"
|
|
||||||
echo "::: any concerns with this requirement. Please be sure to download this script from a trusted source."
|
|
||||||
echo ":::"
|
|
||||||
echo "::: Detecting the presence of the sudo utility for continuation of this install..."
|
|
||||||
|
|
||||||
if command -v sudo &> /dev/null; then
|
|
||||||
echo "::: Utility sudo located."
|
|
||||||
exec curl -sSL https://install.pi-hole.net | sudo bash "$@"
|
|
||||||
exit $?
|
|
||||||
else
|
|
||||||
echo "::: sudo is needed for the Web interface to run pihole commands. Please run this script as root and it will be automatically installed."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Compatibility
|
# Compatibility
|
||||||
|
|
||||||
if command -v apt-get &> /dev/null; then
|
if command -v apt-get &> /dev/null; then
|
||||||
|
@ -127,36 +105,51 @@ fi
|
||||||
|
|
||||||
####### FUNCTIONS ##########
|
####### FUNCTIONS ##########
|
||||||
is_repo() {
|
is_repo() {
|
||||||
# Use git to check if directory is currently under VCS, return the value
|
# Use git to check if directory is currently under VCS, return the value 128
|
||||||
|
# if directory is not a repo. Return 1 if directory does not exist.
|
||||||
local directory="${1}"
|
local directory="${1}"
|
||||||
if [ -d $directory ]; then
|
local curdir
|
||||||
|
local rc
|
||||||
|
|
||||||
|
curdir="${PWD}"
|
||||||
|
if [[ -d "${directory}" ]]; then
|
||||||
# git -C is not used here to support git versions older than 1.8.4
|
# git -C is not used here to support git versions older than 1.8.4
|
||||||
curdir=$PWD; cd $directory; git status --short &> /dev/null; rc=$?; cd $curdir
|
cd "${directory}"
|
||||||
return $rc
|
git status --short &> /dev/null || rc=$?
|
||||||
else
|
else
|
||||||
# non-zero return code if directory does not exist OR is not a valid git repository
|
# non-zero return code if directory does not exist
|
||||||
return 1
|
rc=1
|
||||||
fi
|
fi
|
||||||
|
cd "${curdir}"
|
||||||
|
return "${rc:-0}"
|
||||||
}
|
}
|
||||||
|
|
||||||
make_repo() {
|
make_repo() {
|
||||||
local directory="${1}"
|
local directory="${1}"
|
||||||
local remoteRepo="${2}"
|
local remoteRepo="${2}"
|
||||||
# Remove the non-repod interface and clone the interface
|
|
||||||
echo -n "::: Cloning $remoteRepo into $directory..."
|
echo -n "::: Cloning ${remoteRepo} into ${directory}..."
|
||||||
rm -rf "${directory}"
|
# Clean out the directory if it exists for git to clone into
|
||||||
git clone -q --depth 1 "${remoteRepo}" "${directory}" &> /dev/null
|
if [[ -d "${directory}" ]]; then
|
||||||
|
rm -rf "${directory}"
|
||||||
|
fi
|
||||||
|
git clone -q --depth 1 "${remoteRepo}" "${directory}" &> /dev/null || return $?
|
||||||
echo " done!"
|
echo " done!"
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
update_repo() {
|
update_repo() {
|
||||||
local directory="${1}"
|
local directory="${1}"
|
||||||
|
|
||||||
# Pull the latest commits
|
# Pull the latest commits
|
||||||
echo -n "::: Updating repo in $1..."
|
echo -n "::: Updating repo in ${1}..."
|
||||||
cd "${directory}" || exit 1
|
if [[ -d "${directory}" ]]; then
|
||||||
git stash -q &> /dev/null
|
cd "${directory}"
|
||||||
git pull -q &> /dev/null
|
git stash -q &> /dev/null || true # Okay for stash failure
|
||||||
echo " done!"
|
git pull -q &> /dev/null || return $?
|
||||||
|
echo " done!"
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
getGitFiles() {
|
getGitFiles() {
|
||||||
|
@ -167,10 +160,11 @@ getGitFiles() {
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: Checking for existing repository..."
|
echo "::: Checking for existing repository..."
|
||||||
if is_repo "${directory}"; then
|
if is_repo "${directory}"; then
|
||||||
update_repo "${directory}"
|
update_repo "${directory}" || return 1
|
||||||
else
|
else
|
||||||
make_repo "${directory}" "${remoteRepo}"
|
make_repo "${directory}" "${remoteRepo}" || return 1
|
||||||
fi
|
fi
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
find_IPv4_information() {
|
find_IPv4_information() {
|
||||||
|
@ -1001,29 +995,18 @@ checkSelinux() {
|
||||||
}
|
}
|
||||||
|
|
||||||
displayFinalMessage() {
|
displayFinalMessage() {
|
||||||
if (( ${#1} > 0 )) ; then
|
|
||||||
# Final completion message to user
|
# Final completion message to user
|
||||||
whiptail --msgbox --backtitle "Make it so." --title "Installation Complete!" "Configure your devices to use the Pi-hole as their DNS server using:
|
whiptail --msgbox --backtitle "Make it so." --title "Installation Complete!" "Configure your devices to use the Pi-hole as their DNS server using:
|
||||||
|
|
||||||
IPv4: ${IPV4_ADDRESS%/*}
|
IPv4: ${IPV4_ADDRESS%/*}
|
||||||
IPv6: ${IPV6_ADDRESS}
|
IPv6: ${IPV6_ADDRESS:-"Not Configured"}
|
||||||
|
|
||||||
If you set a new IP address, you should restart the Pi.
|
If you set a new IP address, you should restart the Pi.
|
||||||
|
|
||||||
The install log is in /etc/pihole.
|
The install log is in /etc/pihole.
|
||||||
View the web interface at http://pi.hole/admin or http://${IPV4_ADDRESS%/*}/admin
|
View the web interface at http://pi.hole/admin or http://${IPV4_ADDRESS%/*}/admin
|
||||||
The currently set password is ${1}" ${r} ${c}
|
|
||||||
else
|
|
||||||
whiptail --msgbox --backtitle "Make it so." --title "Installation Complete!" "Configure your devices to use the Pi-hole as their DNS server using:
|
|
||||||
|
|
||||||
IPv4: ${IPV4_ADDRESS%/*}
|
Your Admin Webpage login password is ${1:-"NOT SET"}" ${r} ${c}
|
||||||
IPv6: ${IPV6_ADDRESS}
|
|
||||||
|
|
||||||
If you set a new IP address, you should restart the Pi.
|
|
||||||
|
|
||||||
The install log is in /etc/pihole.
|
|
||||||
View the web interface at http://pi.hole/admin or http://${IPV4_ADDRESS%/*}/admin" ${r} ${c}
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
update_dialogs() {
|
update_dialogs() {
|
||||||
|
@ -1063,6 +1046,28 @@ update_dialogs() {
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
|
||||||
|
######## FIRST CHECK ########
|
||||||
|
# Must be root to install
|
||||||
|
echo ":::"
|
||||||
|
if [[ ${EUID} -eq 0 ]]; then
|
||||||
|
echo "::: You are root."
|
||||||
|
else
|
||||||
|
echo "::: Script called with non-root privileges. The Pi-hole installs server packages and configures"
|
||||||
|
echo "::: system networking, it requires elevated rights. Please check the contents of the script for"
|
||||||
|
echo "::: any concerns with this requirement. Please be sure to download this script from a trusted source."
|
||||||
|
echo ":::"
|
||||||
|
echo "::: Detecting the presence of the sudo utility for continuation of this install..."
|
||||||
|
|
||||||
|
if command -v sudo &> /dev/null; then
|
||||||
|
echo "::: Utility sudo located."
|
||||||
|
exec curl -sSL https://install.pi-hole.net | sudo bash "$@"
|
||||||
|
exit $?
|
||||||
|
else
|
||||||
|
echo "::: sudo is needed for the Web interface to run pihole commands. Please run this script as root and it will be automatically installed."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Check arguments for the undocumented flags
|
# Check arguments for the undocumented flags
|
||||||
for var in "$@"; do
|
for var in "$@"; do
|
||||||
case "$var" in
|
case "$var" in
|
||||||
|
@ -1105,8 +1110,14 @@ main() {
|
||||||
echo "::: --reconfigure passed to install script. Not downloading/updating local repos"
|
echo "::: --reconfigure passed to install script. Not downloading/updating local repos"
|
||||||
else
|
else
|
||||||
# Get Git files for Core and Admin
|
# Get Git files for Core and Admin
|
||||||
getGitFiles ${PI_HOLE_LOCAL_REPO} ${piholeGitUrl}
|
getGitFiles ${PI_HOLE_LOCAL_REPO} ${piholeGitUrl} || \
|
||||||
getGitFiles ${webInterfaceDir} ${webInterfaceGitUrl}
|
{ echo "!!! Unable to clone ${piholeGitUrl} into ${PI_HOLE_LOCAL_REPO}, unable to continue."; \
|
||||||
|
exit 1; \
|
||||||
|
}
|
||||||
|
getGitFiles ${webInterfaceDir} ${webInterfaceGitUrl} || \
|
||||||
|
{ echo "!!! Unable to clone ${webInterfaceGitUrl} into ${webInterfaceDir}, unable to continue."; \
|
||||||
|
exit 1; \
|
||||||
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ${useUpdateVars} == false ]]; then
|
if [[ ${useUpdateVars} == false ]]; then
|
||||||
|
|
Loading…
Reference in a new issue