Merge branch 'development' into new/RemoveDefaultBlocklists

This commit is contained in:
Adam Warner 2018-04-29 13:39:17 +01:00
commit 3216d65353
No known key found for this signature in database
GPG key ID: F5410858022DA5EB
7 changed files with 154 additions and 100 deletions

View file

@ -56,7 +56,7 @@ IPV4_ADDRESS=""
IPV6_ADDRESS=""
# By default, query logging is enabled and the dashboard is set to be installed
QUERY_LOGGING=true
INSTALL_WEB=true
INSTALL_WEB_INTERFACE=true
# Find the rows and columns will default to 80x24 if it can not be detected
@ -77,6 +77,16 @@ c=$(( c < 70 ? 70 : c ))
skipSpaceCheck=false
reconfigure=false
runUnattended=false
INSTALL_WEB_SERVER=true
# Check arguments for the undocumented flags
for var in "$@"; do
case "$var" in
"--reconfigure" ) reconfigure=true;;
"--i_do_not_follow_recommendations" ) skipSpaceCheck=true;;
"--unattended" ) runUnattended=true;;
"--disable-install-webserver" ) INSTALL_WEB_SERVER=false;;
esac
done
# If the color table file exists,
if [[ -f "${coltable}" ]]; then
@ -164,7 +174,7 @@ if command -v apt-get &> /dev/null; then
# These programs are stored in an array so they can be looped through later
INSTALLER_DEPS=(apt-utils dialog debconf dhcpcd5 git ${iproute_pkg} whiptail)
# Pi-hole itself has several dependencies that also need to be installed
PIHOLE_DEPS=(bc cron curl dnsutils iputils-ping lsof netcat sudo unzip wget idn2 sqlite3 libcap2-bin dns-root-data resolvconf)
PIHOLE_DEPS=(bc cron curl dnsutils iputils-ping lsof netcat psmisc sudo unzip wget idn2 sqlite3 libcap2-bin dns-root-data resolvconf)
# The Web dashboard has some that also need to be installed
# It's useful to separate the two since our repos are also setup as "Core" code and "Web" code
PIHOLE_WEB_DEPS=(lighttpd ${phpVer}-common ${phpVer}-cgi ${phpVer}-${phpSqlite})
@ -946,14 +956,36 @@ setAdminFlag() {
"On (Recommended)")
echo -e " ${INFO} Web Interface On"
# Set it to true
INSTALL_WEB=true
INSTALL_WEB_INTERFACE=true
;;
Off)
echo -e " ${INFO} Web Interface Off"
# or false
INSTALL_WEB=false
INSTALL_WEB_INTERFACE=false
;;
esac
# Request user to install web server, if --disable-install-webserver has not been used (INSTALL_WEB_SERVER=true is default).
if [[ "${INSTALL_WEB_SERVER}" == true ]]; then
WebToggleCommand=(whiptail --separate-output --radiolist "Do you wish to install the web server (lighttpd)?\\n\\nNB: If you disable this, and, do not have an existing webserver installed, the web interface will not function." "${r}" "${c}" 6)
# with the default being enabled
WebChooseOptions=("On (Recommended)" "" on
Off "" off)
WebChoices=$("${WebToggleCommand[@]}" "${WebChooseOptions[@]}" 2>&1 >/dev/tty) || (echo -e " ${COL_LIGHT_RED}Cancel was selected, exiting installer${COL_NC}" && exit 1)
# Depending on their choice
case ${WebChoices} in
"On (Recommended)")
echo -e " ${INFO} Web Server On"
# set it to true, as clearly seen below.
INSTALL_WEB_SERVER=true
;;
Off)
echo -e " ${INFO} Web Server Off"
# or false
INSTALL_WEB_SERVER=false
;;
esac
fi
}
# A function to display a list of example blocklists for users to select
@ -1129,7 +1161,7 @@ installConfigs() {
version_check_dnsmasq
# If the user chose to install the dashboard,
if [[ "${INSTALL_WEB}" == true ]]; then
if [[ "${INSTALL_WEB_SERVER}" == true ]]; then
# and if the Web server conf directory does not exist,
if [[ ! -d "/etc/lighttpd" ]]; then
# make it
@ -1497,7 +1529,7 @@ configureFirewall() {
#
finalExports() {
# If the Web interface is not set to be installed,
if [[ "${INSTALL_WEB}" == false ]]; then
if [[ "${INSTALL_WEB_INTERFACE}" == false ]]; then
# and if there is not an IPv4 address,
if [[ "${IPV4_ADDRESS}" ]]; then
# there is no block page, so set IPv4 to 0.0.0.0 (all IP addresses)
@ -1512,7 +1544,7 @@ finalExports() {
# If the setup variable file exists,
if [[ -e "${setupVars}" ]]; then
# update the variables in the file
sed -i.update.bak '/PIHOLE_INTERFACE/d;/IPV4_ADDRESS/d;/IPV6_ADDRESS/d;/PIHOLE_DNS_1/d;/PIHOLE_DNS_2/d;/QUERY_LOGGING/d;/INSTALL_WEB/d;/LIGHTTPD_ENABLED/d;' "${setupVars}"
sed -i.update.bak '/PIHOLE_INTERFACE/d;/IPV4_ADDRESS/d;/IPV6_ADDRESS/d;/PIHOLE_DNS_1/d;/PIHOLE_DNS_2/d;/QUERY_LOGGING/d;/INSTALL_WEB_SERVER/d;/INSTALL_WEB_INTERFACE/d;/LIGHTTPD_ENABLED/d;' "${setupVars}"
fi
# echo the information to the user
{
@ -1522,7 +1554,8 @@ finalExports() {
echo "PIHOLE_DNS_1=${PIHOLE_DNS_1}"
echo "PIHOLE_DNS_2=${PIHOLE_DNS_2}"
echo "QUERY_LOGGING=${QUERY_LOGGING}"
echo "INSTALL_WEB=${INSTALL_WEB}"
echo "INSTALL_WEB_SERVER=${INSTALL_WEB_SERVER}"
echo "INSTALL_WEB_INTERFACE=${INSTALL_WEB_INTERFACE}"
echo "LIGHTTPD_ENABLED=${LIGHTTPD_ENABLED}"
}>> "${setupVars}"
@ -1566,32 +1599,35 @@ installPihole() {
create_pihole_user
# If the user wants to install the Web interface,
if [[ "${INSTALL_WEB}" == true ]]; then
if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then
if [[ ! -d "/var/www/html" ]]; then
# make the Web directory if necessary
mkdir -p /var/www/html
fi
# Set the owner and permissions
chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /var/www/html
chmod 775 /var/www/html
# Give pihole access to the Web server group
usermod -a -G ${LIGHTTPD_GROUP} pihole
# If the lighttpd command is executable,
if [[ -x "$(command -v lighty-enable-mod)" ]]; then
# enable fastcgi and fastcgi-php
lighty-enable-mod fastcgi fastcgi-php > /dev/null || true
else
# Othweise, show info about installing them
echo -e " ${INFO} Warning: 'lighty-enable-mod' utility not found
Please ensure fastcgi is enabled if you experience issues\\n"
fi
if [[ "${INSTALL_WEB_SERVER}" == true ]]; then
# Set the owner and permissions
chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /var/www/html
chmod 775 /var/www/html
# Give pihole access to the Web server group
usermod -a -G ${LIGHTTPD_GROUP} pihole
# If the lighttpd command is executable,
if [[ -x "$(command -v lighty-enable-mod)" ]]; then
# enable fastcgi and fastcgi-php
lighty-enable-mod fastcgi fastcgi-php > /dev/null || true
else
# Othweise, show info about installing them
echo -e " ${INFO} Warning: 'lighty-enable-mod' utility not found
Please ensure fastcgi is enabled if you experience issues\\n"
fi
fi
fi
# Install scripts,
installScripts
# configs,
installConfigs
# If the user wants to install the dashboard,
if [[ "${INSTALL_WEB}" == true ]]; then
if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then
# do so
installPiholeWeb
fi
@ -1618,6 +1654,15 @@ accountForRefactor() {
sed -i 's/piholeIPv6/IPV6_ADDRESS/g' ${setupVars}
sed -i 's/piholeDNS1/PIHOLE_DNS_1/g' ${setupVars}
sed -i 's/piholeDNS2/PIHOLE_DNS_2/g' ${setupVars}
sed -i 's/^INSTALL_WEB=/INSTALL_WEB_INTERFACE=/' ${setupVars}
# Add 'INSTALL_WEB_SERVER', if its not been applied already: https://github.com/pi-hole/pi-hole/pull/2115
if ! grep -q '^INSTALL_WEB_SERVER=' ${setupVars}; then
local webserver_installed=false
if grep -q '^INSTALL_WEB_INTERFACE=true' ${setupVars}; then
webserver_installed=true
fi
echo -e "INSTALL_WEB_SERVER=$webserver_installed" >> ${setupVars}
fi
}
updatePihole() {
@ -1625,9 +1670,9 @@ updatePihole() {
# Install base files and web interface
installScripts
# Install config files
installConfigs
installConfigs
# If the user wants to install the dasboard,
if [[ "${INSTALL_WEB}" == true ]]; then
if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then
# do so
installPiholeWeb
fi
@ -1677,7 +1722,7 @@ displayFinalMessage() {
pwstring="NOT SET"
fi
# If the user wants to install the dashboard,
if [[ "${INSTALL_WEB}" == true ]]; then
if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then
# Store a message in a variable and display it
additional="View the web interface at http://pi.hole/admin or http://${IPV4_ADDRESS%/*}/admin
@ -1745,7 +1790,7 @@ clone_or_update_repos() {
exit 1; \
}
# If the Web interface was installed,
if [[ "${INSTALL_WEB}" == true ]]; then
if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then
# reset it's repo
resetRepo ${webInterfaceDir} || \
{ echo -e " ${COL_LIGHT_RED}Unable to reset ${webInterfaceDir}, exiting installer${COL_NC}"; \
@ -1760,7 +1805,7 @@ clone_or_update_repos() {
exit 1; \
}
# If the Web interface was installed,
if [[ "${INSTALL_WEB}" == true ]]; then
if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then
# get the Web git files
getGitFiles ${webInterfaceDir} ${webInterfaceGitUrl} || \
{ echo -e " ${COL_LIGHT_RED}Unable to clone ${webInterfaceGitUrl} into ${webInterfaceDir}, exiting installer${COL_NC}"; \
@ -2065,15 +2110,6 @@ main() {
# Check for supported distribution
distro_check
# Check arguments for the undocumented flags
for var in "$@"; do
case "$var" in
"--reconfigure" ) reconfigure=true;;
"--i_do_not_follow_recommendations" ) skipSpaceCheck=true;;
"--unattended" ) runUnattended=true;;
esac
done
# If the setup variable file exists,
if [[ -f "${setupVars}" ]]; then
# if it's running unattended,
@ -2127,7 +2163,7 @@ main() {
fi
fi
if [[ "${INSTALL_WEB}" == true ]]; then
if [[ "${INSTALL_WEB_SERVER}" == true ]]; then
stop_service lighttpd
fi
# Determine available interfaces
@ -2147,21 +2183,19 @@ main() {
# Clone/Update the repos
clone_or_update_repos
# Install packages used by the Pi-hole
if [[ "${INSTALL_WEB}" == true ]]; then
# Install the Core dependencies
local dep_install_list=("${PIHOLE_DEPS[@]}")
if [[ "${INSTALL_WEB_SERVER}" == true ]]; then
# Install the Web dependencies
DEPS=("${PIHOLE_DEPS[@]}" "${PIHOLE_WEB_DEPS[@]}")
# Otherwise,
else
# just install the Core dependencies
DEPS=("${PIHOLE_DEPS[@]}")
dep_install_list+=("${PIHOLE_WEB_DEPS[@]}")
fi
install_dependent_packages DEPS[@]
install_dependent_packages dep_install_list[@]
unset dep_install_list
# On some systems, lighttpd is not enabled on first install. We need to enable it here if the user
# has chosen to install the web interface, else the `LIGHTTPD_ENABLED` check will fail
if [[ "${INSTALL_WEB}" == true ]]; then
if [[ "${INSTALL_WEB_SERVER}" == true ]]; then
enable_service lighttpd
fi
@ -2182,16 +2216,15 @@ main() {
# Clone/Update the repos
clone_or_update_repos
# Install packages used by the Pi-hole
if [[ "${INSTALL_WEB}" == true ]]; then
# Install the Core dependencies
local dep_install_list=("${PIHOLE_DEPS[@]}")
if [[ "${INSTALL_WEB_SERVER}" == true ]]; then
# Install the Web dependencies
DEPS=("${PIHOLE_DEPS[@]}" "${PIHOLE_WEB_DEPS[@]}")
# Otherwise,
else
# just install the Core dependencies
DEPS=("${PIHOLE_DEPS[@]}")
dep_install_list+=("${PIHOLE_WEB_DEPS[@]}")
fi
install_dependent_packages DEPS[@]
install_dependent_packages dep_install_list[@]
unset dep_install_list
if [[ -x "$(command -v systemctl)" ]]; then
# Value will either be 1, if true, or 0
@ -2206,7 +2239,7 @@ main() {
# Copy the temp log file into final log location for storage
copy_to_install_log
if [[ "${INSTALL_WEB}" == true ]]; then
if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then
# Add password to web UI if there is none
pw=""
# If no password is set,
@ -2228,7 +2261,7 @@ main() {
fi
# If the Web server was installed,
if [[ "${INSTALL_WEB}" == true ]]; then
if [[ "${INSTALL_WEB_SERVER}" == true ]]; then
if [[ "${LIGHTTPD_ENABLED}" == "1" ]]; then
start_service lighttpd
@ -2255,7 +2288,7 @@ main() {
fi
# If the Web interface was installed,
if [[ "${INSTALL_WEB}" == true ]]; then
if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then
# If there is a password,
if (( ${#pw} > 0 )) ; then
# display the password
@ -2267,7 +2300,7 @@ main() {
#
if [[ "${useUpdateVars}" == false ]]; then
# If the Web interface was installed,
if [[ "${INSTALL_WEB}" == true ]]; then
if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then
echo -e " View the web interface at http://pi.hole/admin or http://${IPV4_ADDRESS%/*}/admin"
echo ""
fi