added new generic installer and uninstaller bash scripts.

This commit is contained in:
Shreyas Zare
2020-07-18 17:01:52 +05:30
parent 3e258e7964
commit e20e19e407
2 changed files with 132 additions and 0 deletions

View File

@@ -0,0 +1,92 @@
#!/bin/sh
dotnetDir="/opt/dotnet"
dnsDir="/etc/dns"
dnsTar="/etc/dns/DnsServerPortable.tar.gz"
dnsUrl="https://download.technitium.com/dns/DnsServerPortable.tar.gz"
mkdir -p $dnsDir
installLog="$dnsDir/install.log"
echo "" > $installLog
echo ""
echo "==============================="
echo "Technitium DNS Server Installer"
echo "==============================="
echo ""
echo "Installing .NET Core Runtime..."
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin -c Current --runtime dotnet --no-path --install-dir $dotnetDir --verbose >> $installLog 2>&1
if [ ! -f "/usr/bin/dotnet" ]
then
ln -s $dotnetDir/dotnet /usr/bin >> $installLog 2>&1
fi
echo ""
echo "Downloading Technitium DNS Server..."
if curl -o $dnsTar --fail $dnsUrl >> $installLog 2>&1
then
if [ -d "/etc/dns/" ]
then
echo "Updating Technitium DNS Server..."
else
echo "Installing Technitium DNS Server..."
fi
tar -zxf $dnsTar -C $dnsDir >> $installLog 2>&1
if [ "$(ps --no-headers -o comm 1 | tr -d '\n')" = "systemd" ]
then
if [ -f "/etc/systemd/system/dns.service" ]
then
echo "Restarting systemd service..."
systemctl restart dns.service >> $installLog 2>&1
else
echo "Configuring systemd service..."
cp $dnsDir/systemd.service /etc/systemd/system/dns.service
systemctl enable dns.service >> $installLog 2>&1
systemctl stop systemd-resolved >> $installLog 2>&1
systemctl disable systemd-resolved >> $installLog 2>&1
systemctl start dns.service >> $installLog 2>&1
rm /etc/resolv.conf >> $installLog 2>&1
echo "nameserver 127.0.0.1" > /etc/resolv.conf >> $installLog 2>&1
if [ -f "/etc/NetworkManager/NetworkManager.conf" ]
then
echo "[main]" >> /etc/NetworkManager/NetworkManager.conf
echo "dns=default" >> /etc/NetworkManager/NetworkManager.conf
fi
fi
else
if [ -f "/etc/supervisor/conf.d/dns.conf" ]
then
echo "Restarting supervisor service..."
service supervisor restart >> $installLog 2>&1
else
echo "Installing supervisor..."
until apt-get -y install supervisor >> $installLog 2>&1
do
echo "Trying again.."
sleep 2
done
echo "Configuring supervisor service..."
cp $dnsDir/supervisor.conf /etc/supervisor/conf.d/dns.conf
service supervisor restart >> $installLog 2>&1
fi
fi
echo ""
echo "Technitium DNS Server was installed succesfully!"
echo "Open http://$(hostname):5380/ to access the web console."
else
echo ""
echo "Failed to download Technitium DNS Server from: $dnsUrl"
exit 1
fi

View File

@@ -0,0 +1,40 @@
#!/bin/sh
dotnetDir="/opt/dotnet"
dnsDir="/etc/dns"
echo ""
echo "================================="
echo "Technitium DNS Server Uninstaller"
echo "================================="
echo ""
echo "Uninstalling Technitium DNS Server..."
if [ -d $dnsDir ]
then
if [ "$(ps --no-headers -o comm 1 | tr -d '\n')" = "systemd" ]
then
sudo systemctl disable dns.service >/dev/null 2>&1
sudo systemctl stop dns.service >/dev/null 2>&1
rm /etc/systemd/system/dns.service >/dev/null 2>&1
rm /etc/resolv.conf >/dev/null 2>&1
echo "nameserver 8.8.8.8" >> /etc/resolv.conf
echo "nameserver 1.1.1.1" >> /etc/resolv.conf
else
rm /etc/supervisor/conf.d/dns.conf >/dev/null 2>&1
service supervisor restart >/dev/null 2>&1
fi
rm -rf $dnsDir >/dev/null 2>&1
if [ -d $dotnetDir ]
then
echo "Uninstalling .NET Core Runtime..."
rm /usr/bin/dotnet >/dev/null 2>&1
rm -rf $dotnetDir >/dev/null 2>&1
fi
fi
echo ""
echo "Thank you for using Technitium DNS Server!"