Advertisement
Guest User

Pi-hole Gentoo support Patch

a guest
Jan 20th, 2018
404
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 9.83 KB | None | 0 0
  1. diff --git a/advanced/lighttpd.conf.gentoo b/advanced/lighttpd.conf.gentoo
  2. index e69de29..df382a9 100644
  3. --- a/advanced/lighttpd.conf.gentoo
  4. +++ b/advanced/lighttpd.conf.gentoo
  5. @@ -0,0 +1,104 @@
  6. +# Pi-hole: A black hole for Internet advertisements
  7. +# (c) 2017 Pi-hole, LLC (https://pi-hole.net)
  8. +# Network-wide ad blocking via your own hardware.
  9. +#
  10. +# lighttpd config for Pi-hole
  11. +#
  12. +# This file is copyright under the latest version of the EUPL.
  13. +# Please see LICENSE file for your rights under this license.
  14. +
  15. +
  16. +
  17. +###############################################################################
  18. +#     FILE AUTOMATICALLY OVERWRITTEN BY PI-HOLE INSTALL/UPDATE PROCEDURE.     #
  19. +# ANY CHANGES MADE TO THIS FILE AFTER INSTALL WILL BE LOST ON THE NEXT UPDATE #
  20. +#                                                                             #
  21. +#              CHANGES SHOULD BE MADE IN A SEPERATE CONFIG FILE:              #
  22. +#                         /etc/lighttpd/external.conf                         #
  23. +###############################################################################
  24. +
  25. +server.modules = (
  26. +   "mod_access",
  27. +   "mod_auth",
  28. +   "mod_fastcgi",
  29. +   "mod_accesslog",
  30. +   "mod_expire",
  31. +   "mod_compress",
  32. +   "mod_redirect",
  33. +   "mod_setenv",
  34. +   "mod_rewrite"
  35. +)
  36. +
  37. +server.document-root        = "/var/www/html"
  38. +server.error-handler-404    = "pihole/index.php"
  39. +server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
  40. +server.errorlog             = "/var/log/lighttpd/error.log"
  41. +server.pid-file             = "/var/run/lighttpd.pid"
  42. +server.username             = "lighttpd"
  43. +server.groupname            = "lighttpd"
  44. +server.port                 = 80
  45. +accesslog.filename          = "/var/log/lighttpd/access.log"
  46. +accesslog.format            = "%{%s}t|%V|%r|%s|%b"
  47. +
  48. +
  49. +index-file.names            = ( "index.php", "index.html", "index.lighttpd.html" )
  50. +url.access-deny             = ( "~", ".inc" )
  51. +static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
  52. +
  53. +compress.cache-dir          = "/var/cache/lighttpd/compress/"
  54. +compress.filetype           = ( "application/javascript", "text/css", "text/html", "text/plain" )
  55. +
  56. +mimetype.assign   = ( ".png"  => "image/png",
  57. +                      ".jpg"  => "image/jpeg",
  58. +                      ".jpeg" => "image/jpeg",
  59. +                      ".html" => "text/html",
  60. +                      ".css" => "text/css; charset=utf-8",
  61. +                      ".js" => "application/javascript",
  62. +                      ".json" => "application/json",
  63. +                      ".txt"  => "text/plain",
  64. +                      ".svg"  => "image/svg+xml" )
  65. +
  66. +# default listening port for IPv6 falls back to the IPv4 port
  67. +#include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
  68. +#include_shell "/usr/share/lighttpd/create-mime.assign.pl"
  69. +#include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
  70. +
  71. +fastcgi.server = ( ".php" =>
  72. +                   ( "localhost" =>
  73. +                    (
  74. +                     "socket" => "/run/lighttpd/php-fastcgi.socket",
  75. +                     "bin-path" => "/usr/bin/php-cgi",
  76. +                     "max-procs" => 1,
  77. +                     "bin-environment" => (
  78. +                         "PHP_FCGI_CHILDREN" => "16",
  79. +                         "PHP_FCGI_MAX_REQUESTS" => "10000"
  80. +                         ),
  81. +                     "broken-scriptfilename" => "enable"
  82. +                    )
  83. +                   )
  84. +                 )
  85. +
  86. +# If the URL starts with /admin, it is the Web interface
  87. +$HTTP["url"] =~ "^/admin/" {
  88. +   # Create a response header for debugging using curl -I
  89. +   setenv.add-response-header = ( "X-Pi-hole" => "The Pi-hole Web interface is working!" )
  90. +}
  91. +
  92. +# Rewite js requests, must be out of $HTTP block due to bug #2526
  93. +url.rewrite = ( "^(?!/admin/).*\.js$"  => "pihole/index.js"   )
  94. +
  95. +# If the URL does not start with /admin, then it is a query for an ad domain
  96. +$HTTP["url"] =~ "^(?!/admin)/.*" {
  97. +   # Create a response header for debugging using curl -I
  98. +   setenv.add-response-header = ( "X-Pi-hole" => "A black hole for Internet advertisements." )
  99. +}
  100. +
  101. +# Entering just "pi.hole" into a browser redirects to "pi.hole/admin/"
  102. +$HTTP["host"] == "pi.hole" {
  103. +    $HTTP["url"] == "/" {
  104. +        url.redirect = ( "" => "/admin/" )
  105. +    }
  106. +}
  107. +
  108. +# Add user chosen options held in external file
  109. +include_shell "cat external.conf 2>/dev/null"
  110. diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh
  111. index 832fd77..d6a3991 100755
  112. --- a/automated install/basic-install.sh   
  113. +++ b/automated install/basic-install.sh   
  114. @@ -218,7 +218,36 @@ elif command -v rpm &> /dev/null; then
  115.      LIGHTTPD_CFG="lighttpd.conf.fedora"
  116.      DNSMASQ_USER="nobody"
  117.  
  118. -# If neither apt-get or rmp/dnf are found
  119. +# If neither apt-get or rmp/dnf are found, check for emerge to see if it's gentoo family OS
  120. +elif command -v emerge -get &> /dev/null; then
  121. +  #Gentoo
  122. +  #############################################
  123. +  PKG_MANAGER="emerge"
  124. +  UPDATE_PKG_CACHE=":" # don't execute eix-sync
  125. +  PKG_INSTALL=(${PKG_MANAGER})
  126. +  PKG_COUNT="echo 0 || true" # Do not check for outdated packages in gentoo
  127. +  # #########################################
  128. +  # fixes for dependency differences
  129. +  # gentoo uses sys-apps/iproute2
  130. +  iproute_pkg="sys-apps/iproute2"
  131. +
  132. +  # USE for dev-lang/php: +sqlite +fpm +sockets
  133. +  phpVer="dev-lang/php"
  134. +
  135. +  # Select dhcp
  136. +  dhcp_pkg="net-misc/dhcp"
  137. +  # Select your cron implementation
  138. +  cron_pkg="virtual/cron"
  139. +  # #########################################
  140. +  INSTALLER_DEPS=(dev-util/dialog ${iproute_pkg} dev-vcs/git ${dhcp_pkg} sys-apps/net-tools dev-libs/newt sys-process/procps)
  141. +  PIHOLE_DEPS=(sys-devel/bc ${cron_pkg} net-misc/curl sys-apps/findutils net-dns/dnsmasq net-misc/iputils sys-process/lsof net-analyzer/netcat app-admin/sudo app-arch/unzip net-misc/wget net-dns/libidn2)
  142. +  PIHOLE_WEB_DEPS=(www-servers/lighttpd ${phpVer})
  143. +  LIGHTTPD_USER="lighttpd"
  144. +  LIGHTTPD_GROUP="lighttpd"
  145. +  # Reuse the fedora config file
  146. +  LIGHTTPD_CFG="lighttpd.conf.gentoo"
  147. +  DNSMASQ_USER="dnsmasq"
  148. +# If neither apt-get, emerge, or rmp/dnf are found
  149.  else
  150.    # it's not an OS we can support,
  151.    echo -e "  ${CROSS} OS distribution not supported"
  152. @@ -1115,8 +1144,10 @@ stop_service() {
  153.    echo -ne "  ${INFO} ${str}..."
  154.    if command -v systemctl &> /dev/null; then
  155.      systemctl stop "${1}" &> /dev/null || true
  156. -  else
  157. +  elif command -v service &> /dev/null; then
  158.      service "${1}" stop &> /dev/null || true
  159. +  elif command -v rc-service &> /dev/null; then
  160. +    rc-service "${1}" stop &> /dev/null || true
  161.    fi
  162.    echo -e "${OVER}  ${TICK} ${str}..."
  163.  }
  164. @@ -1131,10 +1162,16 @@ start_service() {
  165.    if command -v systemctl &> /dev/null; then
  166.      # use that to restart the service
  167.      systemctl restart "${1}" &> /dev/null
  168. -  # Otherwise,
  169. -  else
  170. -    # fall back to the service command
  171. +  # Otherwise, test if service command exists
  172. +  elif command -v service &> /dev/null; then
  173. +   # use it to restart the service
  174.      service "${1}" restart &> /dev/null
  175. +  # otherwise, test if rc-service exists
  176. +  elif command -v rc-service &> /dev/null; then
  177. +   # use it to restart the service
  178. +    rc-service "${1}" restart &> /dev/null || true
  179. +  else
  180. +     echo "Please manually restart ${1}."
  181.    fi
  182.    echo -e "${OVER}  ${TICK} ${str}"
  183.  }
  184. @@ -1149,6 +1186,10 @@ enable_service() {
  185.    if command -v systemctl &> /dev/null; then
  186.      # use that to enable the service
  187.      systemctl enable "${1}" &> /dev/null
  188. +  # If systemctrl is not existent, check if rc-update is available
  189. +  elif command -v rc-update &> /dev/null; then
  190. +   # use rc-update and add the service to the runlevel 'default'
  191. +   rc-update add "${1}" default
  192.    # Othwerwise,
  193.    else
  194.      # use update-rc.d to accomplish this
  195. @@ -1261,6 +1302,22 @@ install_dependent_packages() {
  196.        return 0
  197.    fi
  198.  
  199. +  if command -v eix &> /dev/null; then
  200. +    for i in "${argArray1[@]}"; do
  201. +      echo -n ":::    Checking for $i..."
  202. +      if eix "${i}" | grep \\[I\\] &> /dev/null; then
  203. +        echo " installed!"
  204. +      else
  205. +        echo " added to install list!"
  206. +        installArray+=("${i}")
  207. +      fi
  208. +    done
  209. +    if [[ ${#installArray[@]} -gt 0 ]]; then
  210. +      echo "Please install the following dependencies before continuing: " "${installArray[@]}"
  211. +      exit 1
  212. +    fi
  213. +   return 0
  214. +  fi
  215.    # Install Fedora/CentOS packages
  216.    for i in "${argArray1[@]}"; do
  217.      echo -ne "  ${INFO} Checking for $i..."
  218. @@ -2024,6 +2081,9 @@ main() {
  219.      if [[ -x "$(command -v systemctl)" ]]; then
  220.        # Value will either be 1, if true, or 0
  221.        LIGHTTPD_ENABLED=$(systemctl is-enabled lighttpd | grep -c 'enabled' || true)
  222. +    elif [[ -x "$(command -v rc-status)" ]]; then
  223. +      # Value will either be 1, if true, or 0
  224. +      LIGHTTPD_ENABLED=$(rc-status | grep lighttpd | grep -c 'started' || true)
  225.      else
  226.        # Value will either be 1, if true, or 0
  227.        LIGHTTPD_ENABLED=$(service lighttpd status | awk '/Loaded:/ {print $0}' | grep -c 'enabled' || true)
  228. @@ -2052,6 +2112,9 @@ main() {
  229.      if [[ -x "$(command -v systemctl)" ]]; then
  230.        # Value will either be 1, if true, or 0
  231.        LIGHTTPD_ENABLED=$(systemctl is-enabled lighttpd | grep -c 'enabled' || true)
  232. +    elif [[ -x "$(command -v rc-status)" ]]; then
  233. +      # Value will either be 1, if true, or 0
  234. +      LIGHTTPD_ENABLED=$(rc-status | grep lighttpd | grep -c 'started' || true)
  235.      else
  236.        # Value will either be 1, if true, or 0
  237.        LIGHTTPD_ENABLED=$(service lighttpd status | awk '/Loaded:/ {print $0}' | grep -c 'enabled' || true)
  238. diff --git a/pihole b/pihole
  239. index e4d6215..4fd5823 100755
  240. --- a/pihole
  241. +++ b/pihole
  242. @@ -343,7 +343,13 @@ restartDNS() {
  243.      else
  244.        svcOption="start"
  245.      fi
  246. -    svc="service dnsmasq ${svcOption}"
  247. +   # Test if service command is available
  248. +   if [[ -x "$(command -v service)" ]]; then
  249. +       svcCmd="service dnsmasq"
  250. +   else
  251. +       svcCmd="/etc/init.d/dnsmasq"
  252. +   fi
  253. +    svc="${svcCmd} ${svcOption}"
  254.    fi
  255.  
  256.    # Print output to Terminal, but not to Web Admin
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement