diff --git a/DnsServerApp.NETCore/install-raspi.sh b/DnsServerApp.NETCore/install-raspi.sh index 510d3ca6..906f7e30 100644 --- a/DnsServerApp.NETCore/install-raspi.sh +++ b/DnsServerApp.NETCore/install-raspi.sh @@ -10,40 +10,45 @@ dnsUrl="https://technitium.com/download/dns/DnsServerPortable.tar.gz" mkdir -p $dnsDir installLog="$dnsDir/install.log" +echo "" > $installLog echo "" echo "===============================" echo "Technitium DNS Server Installer" echo "===============================" -echo "" -echo "Installing dependencies..." -until apt-get -y update &>> $installLog && apt-get -y install curl libunwind8 gettext apt-transport-https &>> $installLog -do - echo "Trying again.." - sleep 2 -done - -echo "" - -if [ ! -f /usr/bin/dotnet ] +if [ ! -f /etc/dns/DnsServerApp.dll ] then - echo "Downloading .NET Core Runtime..." - - mkdir -p $aspnetcoreDir - - if wget -q "$aspnetcoreUrl" -O $aspnetcoreTar + echo "" + echo "Installing dependencies..." + + until apt-get -y update &>> $installLog && apt-get -y install curl libunwind8 gettext apt-transport-https &>> $installLog + do + echo "Trying again.." + sleep 2 + done + + echo "" + + if [ ! -f /usr/bin/dotnet ] then - echo "Installing .NET Core Runtime..." - tar -zxf $aspnetcoreTar -C $aspnetcoreDir - ln -s $aspnetcoreDir/dotnet /usr/bin - echo ".NET Core Runtime was installed succesfully." + echo "Downloading .NET Core Runtime..." + + mkdir -p $aspnetcoreDir + + if wget -q "$aspnetcoreUrl" -O $aspnetcoreTar + then + echo "Installing .NET Core Runtime..." + tar -zxf $aspnetcoreTar -C $aspnetcoreDir + ln -s $aspnetcoreDir/dotnet /usr/bin + echo ".NET Core Runtime was installed succesfully." + else + echo "Failed to download .NET Core Runtime from: $aspnetcoreUrl" + exit 1 + fi else - echo "Failed to download .NET Core Runtime from: $aspnetcoreUrl" - exit 1 + echo ".NET Core Runtime was found installed." fi -else - echo ".NET Core Runtime was found installed." fi echo "" @@ -51,27 +56,45 @@ echo "Downloading Technitium DNS Server..." if wget -q "$dnsUrl" -O $dnsTar then - echo "Installing Technitium DNS Server..." + if [ -f /etc/dns/DnsServerApp.dll ] + then + echo "Updating Technitium DNS Server..." + else + echo "Installing Technitium DNS Server..." + fi + tar -zxf $dnsTar -C $dnsDir if [ "$(ps --no-headers -o comm 1 | tr -d '\n')" = "systemd" ] then - echo "Configuring systemd service..." - cp $dnsDir/systemd.service /etc/systemd/system/dns.service - systemctl enable dns.service &>> $installLog - systemctl start dns.service &>> $installLog + if [ -f /etc/systemd/system/dns.service ] + then + echo "Restarting systemd service..." + systemctl restart dns.service &>> $installLog + else + echo "Configuring systemd service..." + cp $dnsDir/systemd.service /etc/systemd/system/dns.service + systemctl enable dns.service &>> $installLog + systemctl start dns.service &>> $installLog + fi else - echo "Installing supervisor..." - - until apt-get -y install supervisor &>> $installLog - 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 + if [ -f /etc/supervisor/conf.d/dns.conf ] + then + echo "Restarting supervisor service..." + service supervisor restart &>> $installLog + else + echo "Installing supervisor..." + + until apt-get -y install supervisor &>> $installLog + 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 + fi fi echo "" diff --git a/DnsServerApp.NETCore/install-ubuntu.sh b/DnsServerApp.NETCore/install-ubuntu.sh index 9575b4bf..fb65c9ae 100644 --- a/DnsServerApp.NETCore/install-ubuntu.sh +++ b/DnsServerApp.NETCore/install-ubuntu.sh @@ -10,40 +10,45 @@ dnsUrl="https://technitium.com/download/dns/DnsServerPortable.tar.gz" mkdir -p $dnsDir installLog="$dnsDir/install.log" +echo "" > $installLog echo "" echo "===============================" echo "Technitium DNS Server Installer" echo "===============================" -echo "" -echo "Installing dependencies..." -until apt-get -y update &>> $installLog && apt-get -y install libunwind8 icu-devtools apt-transport-https &>> $installLog -do - echo "Trying again.." - sleep 2 -done - -echo "" - -if [ ! -f /usr/bin/dotnet ] +if [ ! -f /etc/dns/DnsServerApp.dll ] then - echo "Downloading .NET Core Runtime..." - - mkdir -p $aspnetcoreDir - - if wget -q "$aspnetcoreUrl" -O $aspnetcoreTar + echo "" + echo "Installing dependencies..." + + until apt-get -y update &>> $installLog && apt-get -y install libunwind8 icu-devtools apt-transport-https &>> $installLog + do + echo "Trying again.." + sleep 2 + done + + echo "" + + if [ ! -f /usr/bin/dotnet ] then - echo "Installing .NET Core Runtime..." - tar -zxf $aspnetcoreTar -C $aspnetcoreDir - ln -s $aspnetcoreDir/dotnet /usr/bin - echo ".NET Core Runtime was installed succesfully." + echo "Downloading .NET Core Runtime..." + + mkdir -p $aspnetcoreDir + + if wget -q "$aspnetcoreUrl" -O $aspnetcoreTar + then + echo "Installing .NET Core Runtime..." + tar -zxf $aspnetcoreTar -C $aspnetcoreDir + ln -s $aspnetcoreDir/dotnet /usr/bin + echo ".NET Core Runtime was installed succesfully." + else + echo "Failed to download .NET Core Runtime from: $aspnetcoreUrl" + exit 1 + fi else - echo "Failed to download .NET Core Runtime from: $aspnetcoreUrl" - exit 1 + echo ".NET Core Runtime was found installed." fi -else - echo ".NET Core Runtime was found installed." fi echo "" @@ -51,27 +56,45 @@ echo "Downloading Technitium DNS Server..." if wget -q "$dnsUrl" -O $dnsTar then - echo "Installing Technitium DNS Server..." + if [ -f /etc/dns/DnsServerApp.dll ] + then + echo "Updating Technitium DNS Server..." + else + echo "Installing Technitium DNS Server..." + fi + tar -zxf $dnsTar -C $dnsDir if [ "$(ps --no-headers -o comm 1 | tr -d '\n')" = "systemd" ] then - echo "Configuring systemd service..." - cp $dnsDir/systemd.service /etc/systemd/system/dns.service - systemctl enable dns.service &>> $installLog - systemctl start dns.service &>> $installLog + if [ -f /etc/systemd/system/dns.service ] + then + echo "Restarting systemd service..." + systemctl restart dns.service &>> $installLog + else + echo "Configuring systemd service..." + cp $dnsDir/systemd.service /etc/systemd/system/dns.service + systemctl enable dns.service &>> $installLog + systemctl start dns.service &>> $installLog + fi else - echo "Installing supervisor..." - - until apt-get -y install supervisor &>> $installLog - 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 + if [ -f /etc/supervisor/conf.d/dns.conf ] + then + echo "Restarting supervisor service..." + service supervisor restart &>> $installLog + else + echo "Installing supervisor..." + + until apt-get -y install supervisor &>> $installLog + 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 + fi fi echo ""