Merge branch 'development' into new/UninstallCleanup

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

# Conflicts:
#	automated install/uninstall.sh
pull/1663/head
Adam Warner 7 years ago
commit 774c6e8ac0
No known key found for this signature in database
GPG Key ID: 03843F6C65554B22

@ -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"

@ -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 &
}
@ -230,7 +234,7 @@ RestartDNS() {
output=$( { service dnsmasq restart; } 2>&1 )
fi
if [[ -z "${output}" ]]; then
if [[ -z "${output}" ]]; then
[[ -t 1 ]] && echo -e "${OVER} ${TICK} ${str}"
else
[[ ! -t 1 ]] && OVER=""
@ -480,6 +484,7 @@ main() {
"setdns" ) SetDNSServers;;
"setexcludedomains" ) SetExcludeDomains;;
"setexcludeclients" ) SetExcludeClients;;
"poweroff" ) Poweroff;;
"reboot" ) Reboot;;
"restartdns" ) RestartDNS;;
"setquerylog" ) SetQueryLogOptions;;

@ -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,
@ -172,22 +177,22 @@ if command -v apt-get &> /dev/null; then
# The DNS server user
DNSMASQ_USER="dnsmasq"
# A function to check...
test_dpkg_lock() {
# An iterator used for counting loop iterations
i=0
# fuser is a program to show which processes use the named files, sockets, or filesystems
# So while the command is true
while fuser /var/lib/dpkg/lock >/dev/null 2>&1 ; do
# Wait half a second
sleep 0.5
# and increase the iterator
((i=i+1))
done
# Always return success, since we only return if there is no
# lock (anymore)
return 0
}
# A function to check...
test_dpkg_lock() {
# An iterator used for counting loop iterations
i=0
# fuser is a program to show which processes use the named files, sockets, or filesystems
# So while the command is true
while fuser /var/lib/dpkg/lock >/dev/null 2>&1 ; do
# Wait half a second
sleep 0.5
# and increase the iterator
((i=i+1))
done
# Always return success, since we only return if there is no
# lock (anymore)
return 0
}
# If apt-get is not found, check for rpm to see if it's a Red Hat family OS
elif command -v rpm &> /dev/null; then
@ -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

@ -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

@ -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
@ -217,7 +218,7 @@ gravity_Schwarzchild() {
# Find all active domains and compile them into one file and remove CRs
local str="Aggregating list of domains"
echo -ne " ${INFO} ${str}..."
truncate -s 0 ${piholeDir}/${matterAndLight}
for i in "${activeDomains[@]}"; do
# Only assimilate list if it is available (download might have failed permanently)
@ -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() {
@ -468,7 +474,7 @@ if [[ ! "${blackListOnly}" == true ]]; then
echo -ne " ${INFO} ${str}..."
rm ${piholeDir}/pihole.*.txt 2> /dev/null
echo -e "${OVER} ${TICK} ${str}"
fi

Loading…
Cancel
Save