Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

39 lines
1.1KB

  1. #!/bin/bash
  2. echo ""
  3. echo "Adding DNS entries to PI-HOLE"
  4. CONF_FILE=custom_dnsmasq.conf
  5. IP_LOOKUP="$(ip route get 8.8.8.8 | awk '{ print $NF; exit }')" # May not work for VPN / tun0
  6. # read variables, for domain and host names
  7. source .env
  8. # global domain
  9. echo server=/${LDAP_DOMAIN}/${IP_LOOKUP} > /tmp/${CONF_FILE}
  10. # mail
  11. echo address=/${MAIL_HOSTNAME}.${LDAP_DOMAIN}/${IP_LOOKUP} > /tmp/${CONF_FILE}
  12. # Nextcloud
  13. echo address=/${NEXTCLOUD_SERVER_NAME}.${LDAP_DOMAIN}/${IP_LOOKUP} >> /tmp/${CONF_FILE}
  14. # gogs
  15. echo address=/gogs.${LDAP_DOMAIN}/${IP_LOOKUP} >> /tmp/${CONF_FILE}
  16. # ##### Add entries to PiHole ###### #
  17. container=$(docker ps | grep pihole | cut -f1 -d" ")
  18. #echo Container=$container
  19. if [ -z $container ]; then
  20. echo "Qué me estás container?!";
  21. exit 1;
  22. fi
  23. echo Copying user files to Container $container
  24. docker cp /tmp/${CONF_FILE} $container:/etc/dnsmasq.d/99-local-addresses.conf
  25. # restart dns
  26. docker exec ${container} pihole restartdns
  27. echo Removing copied user files
  28. docker exec ${container} sh -c 'rm -Rf /tmp/${CONF_FILE}'
  29. rm -Rf /tmp/${CONF_FILE}