install_bind9.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/bash
  2. function error {
  3. echo -e "\\e[91m$1\\e[39m"
  4. exit 1
  5. }
  6. function check_internet() {
  7. printf "Checking if you are online..."
  8. wget -q --spider http://github.com
  9. if [ $? -eq 0 ]; then
  10. echo "Online. Continuing."
  11. else
  12. error "Offline. Go connect to the internet then run the script again."
  13. fi
  14. }
  15. check_internet
  16. echo "Creating directories..."
  17. sudo mkdir -p /portainer/Files/AppData/Config/bind9/ || error "Failed to create config directory!"
  18. sudo mkdir -p /portainer/Files/AppData/Config/bind9/cache/ || error "Failed to create data directory for Cache!"
  19. sudo mkdir -p /portainer/Files/AppData/Config/bind9/bind/ || error "Failed to create data directory for Bind"
  20. echo "Downloading Prometheus config files if they don't exist"
  21. if [ -d /portainer/Files/AppData/Config/bind9/named.conf ];
  22. then
  23. echo "/portainer/Files/AppData/Config/bind9/named.conf is a directory removing"
  24. rm -rf '/portainer/Files/AppData/Config/bind9/named.conf'
  25. fi
  26. if [ ! -f /portainer/Files/AppData/Config/bind9/named.conf ];
  27. then
  28. sudo wget -O /portainer/Files/AppData/Config/bind9/named.conf https://raw.githubusercontent.com/pi-hosted/pi-hosted/master/configs/bind9/named.conf || error "Failed to download named.conf file!"
  29. fi
  30. echo "Done You are ready to goto next step in the install document"