Merge branch 'development' into new/UninstallCleanup

Signed-off-by: Adam Warner <adamw@rner.email>

# Conflicts:
#	automated install/uninstall.sh
This commit is contained in:
Adam Warner 2017-09-09 18:56:17 +01:00
commit 774c6e8ac0
No known key found for this signature in database
GPG key ID: 03843F6C65554B22
5 changed files with 82 additions and 46 deletions

View file

@ -1,28 +1,49 @@
# Determine if terminal is capable of showing colours
if [[ -t 1 ]] && [[ $(tput colors) -ge 8 ]]; then
# Bold and underline may not show up on all clients
# If something MUST be emphasised, use both
COL_BOLD=''
COL_ULINE=''
COL_NC=''
COL_WHITE=''
COL_BLACK=''
COL_BLUE=''
COL_LIGHT_BLUE=''
COL_GREEN=''
COL_LIGHT_GREEN=''
COL_CYAN=''
COL_LIGHT_CYAN=''
COL_RED=''
COL_LIGHT_RED=''
COL_URG_RED=''
COL_PURPLE=''
COL_LIGHT_PURPLE=''
COL_BROWN=''
COL_YELLOW=''
COL_GRAY=''
COL_LIGHT_GRAY=''
COL_DARK_GRAY=''
COL_GRAY=''
COL_RED=''
COL_GREEN=''
COL_YELLOW=''
COL_BLUE=''
COL_PURPLE=''
COL_CYAN=''
else
# Provide empty variables for `set -u`
COL_BOLD=""
COL_ULINE=""
COL_NC=""
COL_GRAY=""
COL_RED=""
COL_GREEN=""
COL_YELLOW=""
COL_BLUE=""
COL_PURPLE=""
COL_CYAN=""
fi
TICK="[${COL_LIGHT_GREEN}✓${COL_NC}]"
CROSS="[${COL_LIGHT_RED}✗${COL_NC}]"
# Deprecated variables
COL_WHITE="${COL_BOLD}"
COL_BLACK="${COL_NC}"
COL_LIGHT_BLUE="${COL_BLUE}"
COL_LIGHT_GREEN="${COL_GREEN}"
COL_LIGHT_CYAN="${COL_CYAN}"
COL_LIGHT_RED="${COL_RED}"
COL_URG_RED="${COL_RED}${COL_BOLD}${COL_ULINE}"
COL_LIGHT_PURPLE="${COL_PURPLE}"
COL_BROWN="${COL_YELLOW}"
COL_LIGHT_GRAY="${COL_GRAY}"
COL_DARK_GRAY="${COL_GRAY}"
TICK="[${COL_GREEN}✓${COL_NC}]"
CROSS="[${COL_RED}✗${COL_NC}]"
INFO="[i]"
QST="[?]"
DONE="${COL_LIGHT_GREEN} done!${COL_NC}"
OVER="\r\033[K"
DONE="${COL_GREEN} done!${COL_NC}"
OVER="\\r"

View file

@ -217,6 +217,10 @@ SetExcludeClients() {
change_setting "API_EXCLUDE_CLIENTS" "${args[2]}"
}
Poweroff(){
nohup bash -c "sleep 5; poweroff" &> /dev/null </dev/null &
}
Reboot() {
nohup bash -c "sleep 5; reboot" &> /dev/null </dev/null &
}
@ -480,6 +484,7 @@ main() {
"setdns" ) SetDNSServers;;
"setexcludedomains" ) SetExcludeDomains;;
"setexcludeclients" ) SetExcludeClients;;
"poweroff" ) Poweroff;;
"reboot" ) Reboot;;
"restartdns" ) RestartDNS;;
"setquerylog" ) SetQueryLogOptions;;

View file

@ -154,7 +154,12 @@ if command -v apt-get &> /dev/null; then
# fall back on the php5 packages
phpVer="php5"
fi
# We also need the correct version for `php-sqlite` (which differs across distros)
if ${PKG_MANAGER} install --dry-run ${phpVer}-sqlite3 > /dev/null 2>&1; then
phpSqlite="sqlite3"
else
phpSqlite="sqlite"
fi
# Since our install script is so large, we need several other programs to successfuly get a machine provisioned
# 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)
@ -162,7 +167,7 @@ if command -v apt-get &> /dev/null; then
PIHOLE_DEPS=(bc cron curl dnsmasq dnsutils iputils-ping lsof netcat sudo unzip wget)
# 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)
PIHOLE_WEB_DEPS=(lighttpd ${phpVer}-common ${phpVer}-cgi ${phpVer}-${phpSqlite})
# The Web server user,
LIGHTTPD_USER="www-data"
# group,
@ -204,7 +209,7 @@ elif command -v rpm &> /dev/null; then
PKG_COUNT="${PKG_MANAGER} check-update | egrep '(.i686|.x86|.noarch|.arm|.src)' | wc -l"
INSTALLER_DEPS=(dialog git iproute net-tools newt procps-ng)
PIHOLE_DEPS=(bc bind-utils cronie curl dnsmasq findutils nmap-ncat sudo unzip wget)
PIHOLE_WEB_DEPS=(lighttpd lighttpd-fastcgi php php-common php-cli)
PIHOLE_WEB_DEPS=(lighttpd lighttpd-fastcgi php php-common php-cli php-pdo)
if ! grep -q 'Fedora' /etc/redhat-release; then
INSTALLER_DEPS=("${INSTALLER_DEPS[@]}" "epel-release");
fi

View file

@ -180,7 +180,6 @@ removeNoPurge() {
${SUDO} rm -f /etc/init.d/pihole-FTL
${SUDO} rm -f /usr/bin/pihole-FTL
echo -e "${OVER} ${TICK} Removed pihole-FTL"
fi

View file

@ -53,6 +53,7 @@ piholeDir=/etc/${basename}
adList=${piholeDir}/gravity.list
blackList=${piholeDir}/black.list
localList=${piholeDir}/local.list
VPNList=/etc/openvpn/ipp.txt
justDomainsExtension=domains
matterAndLight=${basename}.0.matterandlight.txt
supernova=${basename}.1.supernova.txt
@ -296,7 +297,7 @@ gravity_unique() {
local str="Removing duplicate domains"
echo -ne " ${INFO} ${str}..."
sort -u ${piholeDir}/${supernova} > ${piholeDir}/${preEventHorizon}
sort -u -f ${piholeDir}/${supernova} > ${piholeDir}/${preEventHorizon}
echo -e "${OVER} ${TICK} ${str}"
numberOf=$(wc -l < ${piholeDir}/${preEventHorizon})
@ -337,6 +338,11 @@ gravity_hostFormatLocal() {
rm "${localList}"
gravity_doHostFormat "${localList}.tmp" "${localList}"
rm "${localList}.tmp"
# Generate local HOSTS list with information obtained from OpenVPN (if available)
if [[ -f ${VPNList} ]]; then
awk -F, '{printf $2"\t"$1"\n"}' "${VPNList}" >> "${localList}"
fi
}
gravity_hostFormatGravity() {