diff --git a/advanced/nginx-pi-hole.conf b/advanced/nginx-pi-hole.conf index 416e3b12..3aa2eab8 100644 --- a/advanced/nginx-pi-hole.conf +++ b/advanced/nginx-pi-hole.conf @@ -2,11 +2,11 @@ server { listen 80; listen [::]:80; root /var/www/html; + index index.php index.html index.nginx-debian.html; error_page 404 /pihole/index.html; location ~ ^/admin/ { - index index.php; add_header X-Pi-hole "The Pi-hole Web interface is working!"; location ~ .php$ { @@ -18,6 +18,6 @@ server { } location / { - add_header X-Pi-hole "A black hole for Internet advertisements."; + add_header X-Pi-hole "A black hole for Internet advertisements." always; } } diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index a93ef9f2..e940fdc7 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -317,6 +317,38 @@ installConfigs(){ $SUDO echo " done." } +installNginx(){ + currentNginxIsUpToDate=$(dpkg --compare-versions $(dpkg -l | grep nginx | grep 'ii' | head -n 1 | awk '{print $3}') ge-nl 1.7.5 2> /dev/null && echo '0' || echo '1') + minimumNginxVersionAvailable=$(dpkg --compare-versions $(apt-cache madison nginx | awk '{print $3}' | sort -V | tail -n 1) ge-nl 1.7.5 && echo '0' || echo '1') + installNginxFromTesting=1 + + echo -n "::: Checking for nginx..." + if [ $(dpkg-query -W -f='${Status}' nginx 2>/dev/null | grep -c "ok installed") -eq 0 ]; then + echo -n " Not found! Installing...." + if [ $minimumNginxVersionAvailable -eq 0 ]; then + $SUDO apt-get -y -qq install nginx > /dev/null & spinner $! + echo " done!" + else + installNginxFromTesting=0 + fi + else + echo -n " already installed" + if [ $currentNginxIsUpToDate -eq 0 ]; then + echo "!" + else + echo -n " (but version is too old)! Installing..." + installNginxFromTesting=0 + fi + fi + + if [ $installNginxFromTesting -eq 0 ]; then + $SUDO cat /etc/apt/sources.list | grep deb | grep main | grep -vE '^\s*#' | sed -E 's@(stretch|wheezy|jessie)(-staging)?@testing@g' >> /etc/apt/sources.list + $SUDO apt-get -y -qq update & spinner $! + $SUDO apt-get -y -qq -t testing install nginx > /dev/null & spinner $! + echo " done!" + fi +} + stopServices(){ $SUDO echo ":::" $SUDO echo -n "::: Stopping services..." @@ -393,14 +425,18 @@ checkForDependencies(){ for i in "${dependencies[@]}" do - : - echo -n "::: Checking for $i..." - if [ $(dpkg-query -W -f='${Status}' $i 2>/dev/null | grep -c "ok installed") -eq 0 ]; then - echo -n " Not found! Installing...." - $SUDO apt-get -y -qq install $i > /dev/null & spinner $! - echo " done!" + # nginx has a little more sophisticated installation script, so it needs a special treatment. + if [ $i == 'nginx' ]; then + installNginx else - echo " already installed!" + echo -n "::: Checking for $i..." + if [ $(dpkg-query -W -f='${Status}' $i 2>/dev/null | grep -c "ok installed") -eq 0 ]; then + echo -n " Not found! Installing...." + $SUDO apt-get -y -qq install $i > /dev/null & spinner $! + echo " done!" + else + echo " already installed!" + fi fi done } @@ -478,10 +514,10 @@ installPiholeWeb(){ else $SUDO mkdir /var/www/html/pihole if [ $piholeWebserver == 'lighttpd' ]; then - $SUDO mv /var/www/html/index.lighttpd.html /var/www/html/index.lighttpd.orig + $SUDO cp /var/www/html/index.lighttpd.html /var/www/html/index.lighttpd.orig fi if [ $piholeWebserver == 'nginx' ]; then - $SUDO mv /var/www/html/index.nginx-debian.html /var/www/html/index.nginx-debian.orig + $SUDO cp /var/www/html/index.nginx-debian.html /var/www/html/index.nginx-debian.orig fi $SUDO cp /etc/.pihole/advanced/index.html /var/www/html/pihole/index.html $SUDO echo " done!" diff --git a/block hulu ads/nginx-pi-hole.conf b/block hulu ads/nginx-pi-hole.conf index 95b64e02..8b7cf0f8 100644 --- a/block hulu ads/nginx-pi-hole.conf +++ b/block hulu ads/nginx-pi-hole.conf @@ -2,11 +2,11 @@ server { listen 80; listen [::]:80; root /var/www/html; + index index.php index.html index.nginx-debian.html; error_page 404 /pihole/index.html; location ~ ^/admin/ { - index index.php; add_header X-Pi-hole "The Pi-hole Web interface is working!"; location ~ .php$ { @@ -18,7 +18,7 @@ server { } location / { - add_header X-Pi-hole "A black hole for Internet advertisements."; + add_header X-Pi-hole "A black hole for Internet advertisements." always; } }