diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 5537bd4b..435237cc 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -83,6 +83,7 @@ if [ -x "$(command -v apt-get)" ];then LIGHTTPD_USER="www-data" LIGHTTPD_GROUP="www-data" LIGHTTPD_CFG="lighttpd.conf.debian" + DNSMASQ_USER="dnsmasq" package_check_install() { dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed" || ${PKG_INSTALL} "$1" } @@ -103,6 +104,7 @@ elif [ -x "$(command -v rpm)" ];then LIGHTTPD_USER="lighttpd" LIGHTTPD_GROUP="lighttpd" LIGHTTPD_CFG="lighttpd.conf.fedora" + DNSMASQ_USER="nobody" package_check_install() { rpm -qa | grep ^"$1"- > /dev/null || ${PKG_INSTALL} "$1" } @@ -399,14 +401,14 @@ function valid_ip() } setDNS(){ - DNSChoseCmd=(whiptail --separate-output --radiolist "Select Upstream DNS Provider. To use your own, select Custom." ${r} ${c} 6) + DNSChooseCmd=(whiptail --separate-output --radiolist "Select Upstream DNS Provider. To use your own, select Custom." ${r} ${c} 6) DNSChooseOptions=(Google "" on OpenDNS "" off Level3 "" off Norton "" off Comodo "" off Custom "" off) - DNSchoices=$("${DNSChoseCmd[@]}" "${DNSChooseOptions[@]}" 2>&1 >/dev/tty) + DNSchoices=$("${DNSChooseCmd[@]}" "${DNSChooseOptions[@]}" 2>&1 >/dev/tty) if [[ $? = 0 ]];then case ${DNSchoices} in Google) @@ -706,7 +708,7 @@ CreateLogFile() { if [ ! -f /var/log/pihole.log ]; then touch /var/log/pihole.log chmod 644 /var/log/pihole.log - chown dnsmasq:root /var/log/pihole.log + chown "${DNSMASQ_USER}":root /var/log/pihole.log echo " done!" else echo " already exists!" @@ -766,14 +768,8 @@ create_pihole_user(){ configureFirewall() { # Allow HTTP and DNS traffic if [ -x "$(command -v firewall-cmd)" ]; then - firewall-cmd --state > /dev/null - if [[ $? -eq 0 ]]; then - echo "::: Configuring firewalld for httpd and dnsmasq.." - firewall-cmd --permanent --add-port=80/tcp - firewall-cmd --permanent --add-port=53/tcp - firewall-cmd --permanent --add-port=53/udp - firewall-cmd --reload - fi + firewall-cmd --state &> /dev/null && ( echo "::: Configuring firewalld for httpd and dnsmasq.." && firewall-cmd --permanent --add-port=80/tcp && firewall-cmd --permanent --add-port=53/tcp \ + && firewall-cmd --permanent --add-port=53/udp && firewall-cmd --reload) || echo "::: FirewallD not enabled" elif [ -x "$(command -v iptables)" ]; then echo "::: Configuring iptables for httpd and dnsmasq.." iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT @@ -843,21 +839,13 @@ configureSelinux() { package_check_install "selinux-policy-devel" > /dev/null echo " installed!" printf "::: Enabling httpd server side includes (SSI).. " - setsebool -P httpd_ssi_exec on - if [ $? -eq 0 ]; then - echo -n "Success" - fi + setsebool -P httpd_ssi_exec on &> /dev/null && echo "Success" || echo "SELinux not enabled" printf "\n:::\tCompiling Pi-Hole SELinux policy..\n" checkmodule -M -m -o /etc/pihole/pihole.mod /etc/.pihole/advanced/selinux/pihole.te semodule_package -o /etc/pihole/pihole.pp -m /etc/pihole/pihole.mod semodule -i /etc/pihole/pihole.pp rm -f /etc/pihole/pihole.mod - semodule -l | grep pihole > /dev/null - if [ $? -eq 0 ]; then - printf "::: Successfully installed Pi-Hole SELinux policy\n" - else - printf "::: Warning: Pi-Hole SELinux policy did not install correctly!\n" - fi + semodule -l | grep pihole &> /dev/null && echo "::: Installed Pi-Hole SELinux policy" || echo "::: Warning: Pi-Hole SELinux policy did not install." fi } @@ -876,7 +864,7 @@ View the web interface at http://pi.hole/admin or http://${IPv4_address%/*}/admi update_dialogs(){ - UpdateCmd=$(whiptail --title "Existing Install Detected!" --menu "\n\nWe have detected an existing install.\n\nPlease chose from the following options:" ${r} ${c} 2 \ + UpdateCmd=$(whiptail --title "Existing Install Detected!" --menu "\n\nWe have detected an existing install.\n\nPlease choose from the following options:" ${r} ${c} 2 \ "Update" "Update install will retain existing settings." \ "Install" "Install will allow you to enter new settings." 3>&2 2>&1 1>&3) diff --git a/gravity.sh b/gravity.sh index 636c6c06..f25b28ee 100755 --- a/gravity.sh +++ b/gravity.sh @@ -257,7 +257,7 @@ function gravity_hostFormat() { echo "::: Error: Unable to determine fully qualified domain name of host" fi # If there is a value in the $piholeIPv6, then IPv6 will be used, so the awk command modified to create a line for both protocols - if [[ -n ${IPv6_address} ]];then + if [[ -n "${IPv6_address}" ]];then # Add hostname and dummy domain to the top of gravity.list to make ping result return a friendlier looking domain! Also allows for an easy way to access the Pi-hole admin console (pi.hole/admin) echo -e "$IPv4addr $hostname\n$IPv6_address $hostname\n$IPv4addr pi.hole\n$IPv6_address pi.hole" > ${piholeDir}/${accretionDisc} cat ${piholeDir}/${eventHorizon} | awk -v ipv4addr="$IPv4addr" -v ipv6addr="$IPv6_address" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> ${piholeDir}/${accretionDisc}