diff --git a/ct/powerdns.sh b/ct/powerdns.sh new file mode 100644 index 000000000..f7e41bc42 --- /dev/null +++ b/ct/powerdns.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) + +# Copyright (c) 2021-2026 community-scripts ORG +# Author: Slaviša Arežina (tremor021) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://www.powerdns.com/ + +APP="PowerDNS" +var_tags="${var_tags:-dns}" +var_cpu="${var_cpu:-1}" +var_ram="${var_ram:-1024}" +var_disk="${var_disk:-4}" +var_os="${var_os:-debian}" +var_version="${var_version:-13}" +var_unprivileged="${var_unprivileged:-1}" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + if [[ ! -d /opt/poweradmin ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + msg_info "Updating PowerDNS" + $STD apt update + $STD apt install -y --only-upgrade pdns-server pdns-backend-sqlite3 + msg_ok "Updated PowerDNS" + + if check_for_gh_release "poweradmin" "poweradmin/poweradmin"; then + msg_info "Backing up Configuration" + cp /opt/poweradmin/config/settings.php /opt/poweradmin_settings.php.bak + cp /opt/poweradmin/powerdns.db /opt/poweradmin_powerdns.db.bak + msg_ok "Backed up Configuration" + + CLEAN_INSTALL=1 fetch_and_deploy_gh_release "poweradmin" "poweradmin/poweradmin" "tarball" + + msg_info "Updating Poweradmin" + cp /opt/poweradmin_settings.php.bak /opt/poweradmin/config/settings.php + cp /opt/poweradmin_powerdns.db.bak /opt/poweradmin/powerdns.db + rm -rf /opt/poweradmin/install + rm -f /opt/poweradmin_settings.php.bak /opt/poweradmin_powerdns.db.bak + chown -R www-data:www-data /opt/poweradmin + msg_ok "Updated Poweradmin" + + msg_info "Restarting Services" + systemctl restart pdns apache2 + msg_ok "Restarted Services" + msg_ok "Updated successfully!" + fi + exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" +echo -e "${INFO}${YW} Access it using the following URL:${CL}" +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}${CL}" diff --git a/frontend/public/json/powerdns.json b/frontend/public/json/powerdns.json new file mode 100644 index 000000000..8813de7e2 --- /dev/null +++ b/frontend/public/json/powerdns.json @@ -0,0 +1,40 @@ +{ + "name": "PowerDNS", + "slug": "powerdns", + "categories": [ + 5 + ], + "date_created": "2026-02-11", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": 80, + "documentation": "https://doc.powerdns.com/index.html", + "config_path": "/opt/poweradmin/config/settings.php", + "website": "https://www.powerdns.com/", + "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons@main/webp/powerdns.webp", + "description": "The PowerDNS Authoritative Server is a versatile nameserver which supports a large number of backends. These backends can either be plain zone files or be more dynamic in nature. PowerDNS has the concepts of ‘backends’. A backend is a datastore that the server will consult that contains DNS records (and some metadata). The backends range from database backends (MySQL, PostgreSQL) and BIND zone files to co-processes and JSON API’s.", + "install_methods": [ + { + "type": "default", + "script": "ct/powerdns.sh", + "resources": { + "cpu": 1, + "ram": 1024, + "hdd": 4, + "os": "Debian", + "version": "13" + } + } + ], + "default_credentials": { + "username": null, + "password": null + }, + "notes": [ + { + "text": "For administrator credentials type: `cat ~/poweradmin.creds` inside LXC.", + "type": "info" + } + ] +} \ No newline at end of file diff --git a/install/powerdns-install.sh b/install/powerdns-install.sh new file mode 100644 index 000000000..1f7004c72 --- /dev/null +++ b/install/powerdns-install.sh @@ -0,0 +1,134 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2026 community-scripts ORG +# Author: Slaviša Arežina (tremor021) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://www.powerdns.com/ + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt install -y sqlite3 +msg_ok "Installed Dependencies" + +PHP_VERSION="8.3" PHP_APACHE="YES" PHP_FPM="YES" PHP_MODULE="gettext,tokenizer,sqlite3,ldap" setup_php +setup_deb822_repo \ + "pdns" \ + "https://repo.powerdns.com/FD380FBB-pub.asc" \ + "http://repo.powerdns.com/debian" \ + "trixie-auth-50" + +cat </etc/apt/preferences.d/auth-50 +Package: pdns-* +Pin: origin repo.powerdns.com +Pin-Priority: 600 +EOF + +escape_sql() { + printf '%s' "$1" | sed "s/'/''/g" +} + +msg_info "Setting up PowerDNS" +$STD apt install -y \ + pdns-server \ + pdns-backend-sqlite3 +msg_ok "Setup PowerDNS" + +fetch_and_deploy_gh_release "poweradmin" "poweradmin/poweradmin" "tarball" + +msg_info "Setting up Poweradmin" +sqlite3 /opt/poweradmin/powerdns.db /dev/null) +sqlite3 /opt/poweradmin/powerdns.db "INSERT INTO users (username, password, fullname, email, description, perm_templ, active, use_ldap) \ + VALUES ('$(escape_sql "${PA_ADMIN_USERNAME}")', '$(escape_sql "${PASSWORD_HASH}")', '$(escape_sql "${PA_ADMIN_FULLNAME}")', \ + '$(escape_sql "${PA_ADMIN_EMAIL}")', 'System Administrator', 1, 1, 0);" + +cat <~/poweradmin.creds +Admin Username: ${PA_ADMIN_USERNAME} +Admin Password: ${PA_ADMIN_PASSWORD} +EOF + +cat </opt/poweradmin/config/settings.php + [ + 'type' => 'sqlite', + 'file' => '/opt/poweradmin/powerdns.db', + ], + + /** + * Security Settings + */ + 'security' => [ + 'session_key' => '${PA_SESSION_KEY}', + ], + + /** + * Interface Settings + */ + 'interface' => [ + 'language' => 'en_EN', + ], + + /** + * DNS Settings + */ + 'dns' => [ + 'hostmaster' => 'localhost.lan', + 'ns1' => '8.8.8.8', + 'ns2' => '9.9.9.9', + ] +]; +EOF +rm -rf /opt/poweradmin/install +msg_ok "Setup Poweradmin" + +msg_info "Creating Service" +rm /etc/apache2/sites-enabled/000-default.conf +cat </etc/apache2/sites-enabled/poweradmin.conf + + ServerName localhost + DocumentRoot /opt/poweradmin + + + Options -Indexes +FollowSymLinks + AllowOverride All + Require all granted + + + # For DDNS update functionality + RewriteEngine On + RewriteRule ^/update(.*)\$ /dynamic_update.php [L] + RewriteRule ^/nic/update(.*)\$ /dynamic_update.php [L] + +EOF +$STD a2enmod rewrite headers +chown -R www-data:www-data /opt/poweradmin +$STD systemctl restart apache2 +msg_info "Created Service" + +motd_ssh +customize +cleanup_lxc