install.sh 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #!/bin/sh
  2. dotnetDir="/opt/dotnet"
  3. if [ -d "/etc/dns/config" ]
  4. then
  5. dnsDir="/etc/dns"
  6. else
  7. dnsDir="/opt/technitium/dns"
  8. fi
  9. dnsTar="$dnsDir/DnsServerPortable.tar.gz"
  10. dnsUrl="https://download.technitium.com/dns/DnsServerPortable.tar.gz"
  11. mkdir -p $dnsDir
  12. installLog="$dnsDir/install.log"
  13. echo "" > $installLog
  14. echo ""
  15. echo "==============================="
  16. echo "Technitium DNS Server Installer"
  17. echo "==============================="
  18. if dotnet --list-runtimes 2> /dev/null | grep -q "Microsoft.AspNetCore.App 7.0.";
  19. then
  20. dotnetFound="yes"
  21. else
  22. dotnetFound="no"
  23. fi
  24. if [ ! -d $dotnetDir ] && [ "$dotnetFound" = "yes" ]
  25. then
  26. echo ""
  27. echo "ASP.NET Core Runtime is already installed."
  28. else
  29. echo ""
  30. if [ -d $dotnetDir ] && [ "$dotnetFound" = "yes" ]
  31. then
  32. dotnetUpdate="yes"
  33. echo "Updating ASP.NET Core Runtime..."
  34. else
  35. dotnetUpdate="no"
  36. echo "Installing ASP.NET Core Runtime..."
  37. fi
  38. curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin -c 7.0 --runtime aspnetcore --no-path --install-dir $dotnetDir --verbose >> $installLog 2>&1
  39. if [ ! -f "/usr/bin/dotnet" ]
  40. then
  41. ln -s $dotnetDir/dotnet /usr/bin >> $installLog 2>&1
  42. fi
  43. if dotnet --list-runtimes 2> /dev/null | grep -q "Microsoft.AspNetCore.App 7.0.";
  44. then
  45. if [ "$dotnetUpdate" = "yes" ]
  46. then
  47. echo "ASP.NET Core Runtime was updated successfully!"
  48. else
  49. echo "ASP.NET Core Runtime was installed successfully!"
  50. fi
  51. else
  52. echo "Failed to install ASP.NET Core Runtime. Please try again."
  53. exit 1
  54. fi
  55. fi
  56. echo ""
  57. echo "Downloading Technitium DNS Server..."
  58. if curl -o $dnsTar --fail $dnsUrl >> $installLog 2>&1
  59. then
  60. if [ -d $dnsDir ]
  61. then
  62. echo "Updating Technitium DNS Server..."
  63. else
  64. echo "Installing Technitium DNS Server..."
  65. fi
  66. tar -zxf $dnsTar -C $dnsDir >> $installLog 2>&1
  67. if [ "$(ps --no-headers -o comm 1 | tr -d '\n')" = "systemd" ]
  68. then
  69. if [ -f "/etc/systemd/system/dns.service" ]
  70. then
  71. echo "Restarting systemd service..."
  72. systemctl restart dns.service >> $installLog 2>&1
  73. else
  74. echo "Configuring systemd service..."
  75. cp $dnsDir/systemd.service /etc/systemd/system/dns.service
  76. systemctl enable dns.service >> $installLog 2>&1
  77. systemctl stop systemd-resolved >> $installLog 2>&1
  78. systemctl disable systemd-resolved >> $installLog 2>&1
  79. systemctl start dns.service >> $installLog 2>&1
  80. rm /etc/resolv.conf >> $installLog 2>&1
  81. echo "nameserver 127.0.0.1" > /etc/resolv.conf 2>> $installLog
  82. if [ -f "/etc/NetworkManager/NetworkManager.conf" ]
  83. then
  84. echo "[main]" >> /etc/NetworkManager/NetworkManager.conf
  85. echo "dns=default" >> /etc/NetworkManager/NetworkManager.conf
  86. fi
  87. fi
  88. echo ""
  89. echo "Technitium DNS Server was installed successfully!"
  90. echo "Open http://$(hostname):5380/ to access the web console."
  91. echo ""
  92. echo "Donate! Make a contribution by becoming a Patron: https://www.patreon.com/technitium"
  93. echo ""
  94. else
  95. echo ""
  96. echo "Failed to install Technitium DNS Server: systemd was not detected."
  97. exit 1
  98. fi
  99. else
  100. echo ""
  101. echo "Failed to download Technitium DNS Server from: $dnsUrl"
  102. exit 1
  103. fi