Refactor: Technitium DNS (#14013)

* Refactor

* Ensure root user for systemd service
This commit is contained in:
Slaviša Arežina 2026-04-26 00:37:19 +02:00 committed by GitHub
parent 19bae6935c
commit 0cfc6c89b2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 18 deletions

View file

@ -32,8 +32,8 @@ function update_script() {
systemctl daemon-reload systemctl daemon-reload
systemctl enable -q --now technitium systemctl enable -q --now technitium
fi fi
if is_package_installed "aspnetcore-runtime-8.0"; then if is_package_installed "aspnetcore-runtime-8.0" || is_package_installed "aspnetcore-runtime-9.0"; then
$STD apt remove -y aspnetcore-runtime-8.0 $STD apt remove -y aspnetcore-runtime-*
[ -f /etc/apt/sources.list.d/microsoft-prod.list ] && rm -f /etc/apt/sources.list.d/microsoft-prod.list [ -f /etc/apt/sources.list.d/microsoft-prod.list ] && rm -f /etc/apt/sources.list.d/microsoft-prod.list
[ -f /usr/share/keyrings/microsoft-prod.gpg ] && rm -f /usr/share/keyrings/microsoft-prod.gpg [ -f /usr/share/keyrings/microsoft-prod.gpg ] && rm -f /usr/share/keyrings/microsoft-prod.gpg
setup_deb822_repo \ setup_deb822_repo \
@ -42,18 +42,15 @@ function update_script() {
"https://packages.microsoft.com/debian/13/prod/" \ "https://packages.microsoft.com/debian/13/prod/" \
"trixie" \ "trixie" \
"main" "main"
$STD apt install -y aspnetcore-runtime-9.0 $STD apt install -y aspnetcore-runtime-10.0
fi fi
RELEASE=$(curl -fsSL https://technitium.com/dns/ | grep -oP 'Version \K[\d.]+') RELEASE=$(curl -fsSL https://technitium.com/dns/ | grep -oP 'Version \K[\d.]+')
if [[ ! -f ~/.technitium || ${RELEASE} != "$(cat ~/.technitium)" ]]; then if [[ ! -f ~/.technitium || ${RELEASE} != "$(cat ~/.technitium 2>/dev/null)" ]]; then
msg_info "Updating Technitium DNS" systemctl stop technitium
curl -fsSL "https://download.technitium.com/dns/DnsServerPortable.tar.gz" -o /opt/DnsServerPortable.tar.gz fetch_and_deploy_from_url "https://download.technitium.com/dns/DnsServerPortable.tar.gz" /opt/technitium/dns
$STD tar zxvf /opt/DnsServerPortable.tar.gz -C /opt/technitium/dns/
rm -f /opt/DnsServerPortable.tar.gz
echo "${RELEASE}" >~/.technitium echo "${RELEASE}" >~/.technitium
systemctl restart technitium systemctl start technitium
msg_ok "Updated Technitium DNS"
msg_ok "Updated successfully!" msg_ok "Updated successfully!"
else else
msg_ok "No update required. Technitium DNS is already at v${RELEASE}." msg_ok "No update required. Technitium DNS is already at v${RELEASE}."

View file

@ -20,19 +20,15 @@ setup_deb822_repo \
"https://packages.microsoft.com/debian/13/prod/" \ "https://packages.microsoft.com/debian/13/prod/" \
"trixie" \ "trixie" \
"main" "main"
$STD apt install -y aspnetcore-runtime-9.0 $STD apt install -y aspnetcore-runtime-10.0
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
RELEASE=$(curl -fsSL https://technitium.com/dns/ | grep -oP 'Version \K[\d.]+') RELEASE=$(curl -fsSL https://technitium.com/dns/ | grep -oP 'Version \K[\d.]+')
msg_info "Installing Technitium DNS" fetch_and_deploy_from_url "https://download.technitium.com/dns/DnsServerPortable.tar.gz" /opt/technitium/dns
mkdir -p /opt/technitium/dns
curl -fsSL "https://download.technitium.com/dns/DnsServerPortable.tar.gz" -o /opt/DnsServerPortable.tar.gz
$STD tar zxvf /opt/DnsServerPortable.tar.gz -C /opt/technitium/dns/
rm -f /opt/DnsServerPortable.tar.gz
echo "${RELEASE}" >~/.technitium echo "${RELEASE}" >~/.technitium
msg_ok "Installed Technitium DNS"
msg_info "Creating service" msg_info "Creating service"
sed -i '/^User=/d;/^Group=/d' /opt/technitium/dns/systemd.service
cp /opt/technitium/dns/systemd.service /etc/systemd/system/technitium.service cp /opt/technitium/dns/systemd.service /etc/systemd/system/technitium.service
systemctl enable -q --now technitium systemctl enable -q --now technitium
msg_ok "Service created" msg_ok "Service created"