From 5bad3969b4aae368a45798dbf935531c24a9aceb Mon Sep 17 00:00:00 2001 From: Edoardo Pavan Date: Wed, 23 Apr 2025 22:59:05 +0200 Subject: [PATCH 1/7] feat: add cloudflare-ddns --- ct/cloudflare-ddns.sh | 45 ++++++++++++++ install/cloudflare-ddns-install.sh | 99 ++++++++++++++++++++++++++++++ 2 files changed, 144 insertions(+) create mode 100644 ct/cloudflare-ddns.sh create mode 100644 install/cloudflare-ddns-install.sh diff --git a/ct/cloudflare-ddns.sh b/ct/cloudflare-ddns.sh new file mode 100644 index 0000000..838365d --- /dev/null +++ b/ct/cloudflare-ddns.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +# Copyright (c) 2021-2025 community-scripts ORG +# Author: edoardop13 +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/favonia/cloudflare-ddns + +APP="Cloudflare-DDNS" +var_tags="" +var_cpu="1" +var_ram="512" +var_disk="2" +var_os="debian" +var_version="12" +var_unprivileged="1" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + if [[ ! -f /etc/systemd/system/cloudflare-ddns.service ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + msg_error "We don't provide an update function because the service ${APP} use every time the latest version." + exit +} + +start +build_container +description +msg_ok "Completed Successfully!\n" +echo -e "${APP} setup has been successfully initialized!\n" +echo -e "If you want to update the service go to the container and run the command:\n" +echo -e "sudo nano /etc/systemd/system/cloudflare-ddns.service\n" +echo -e "Update the token or the other environment variables and save the file.\n" +echo -e "Then run the command:\n" +echo -e "sudo systemctl daemon-reload\n" +echo -e "And finally restart the service with:\n" +echo -e "sudo systemctl restart cloudflare-ddns.service" \ No newline at end of file diff --git a/install/cloudflare-ddns-install.sh b/install/cloudflare-ddns-install.sh new file mode 100644 index 0000000..b4ea27f --- /dev/null +++ b/install/cloudflare-ddns-install.sh @@ -0,0 +1,99 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 community-scripts ORG +# Author: edoardop13 +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/favonia/cloudflare-ddns + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing dependencies" +$STD apt-get update +$STD apt-get install -y curl systemd + +msg_info "Installing Go" +GO_VERSION=$(curl -s https://go.dev/VERSION?m=text | grep -m1 '^go') +GO_TARBALL="${GO_VERSION}.linux-amd64.tar.gz" +GO_URL="https://go.dev/dl/${GO_TARBALL}" +INSTALL_DIR="/usr/bin" +echo "📦 Download Go ${GO_VERSION} from ${GO_URL}..." + +rm -rf "${INSTALL_DIR}/go" + +curl -LO "$GO_URL" +tar -C "$INSTALL_DIR" -xzf "$GO_TARBALL" +rm "$GO_TARBALL" + +echo 'export PATH=$PATH:/usr/bin/go/bin' >> ~/.bashrc +source ~/.bashrc +go version + +msg_ok "Dependencies installed" + +msg_info "Configure Application" + +var_cf_api_token="default" +var_cf_api_token=$(whiptail --title "CLOUDFLARE TOKEN" --backtitle "Type the Cloudflare Api Token:" --inputbox "token" 10 60 3>&1 1>&2 2>&3) +msg_ok "Cloudflare Api Token: '${var_cf_api_token}'" + +var_cf_domains="default" +var_cf_domains=$(whiptail --title "CLOUDFLARE DOMAINS" --backtitle "Type the domains separated with a comma (example.org,www.example.org)" --inputbox "*.example.com" 10 60 3>&1 1>&2 2>&3) +msg_ok "Cloudflare Domains: '${var_cf_domains}'" + +var_cf_proxied="false" +if whiptail --yesno "Proxied?" 8 45; then + var_cf_proxied="true" +fi +var_cf_ip6_provider="none" +if whiptail --yesno "IPv6 Provider?" 8 45; then + var_cf_ip6_provider="cloudflare" +else + var_cf_ip6_provider="none" +fi + +msg_ok "Application Configured" + +msg_info "Setting up systemd service" +mkdir -p /root/go +chown -R root:root /root/go +cat </etc/systemd/system/cloudflare-ddns.service +[Unit] +Description=Cloudflare DDNS Service (Go run) +After=network.target + +[Service] +Environment="CLOUDFLARE_API_TOKEN=${var_cf_api_token}" +Environment="DOMAINS=${var_cf_domains}" +Environment="PROXIED=${var_cf_proxied}" +Environment="IP6_PROVIDER=${var_cf_ip6_provider}" +Environment="GOPATH=/root/go" +Environment="GOCACHE=/tmp/go-build" +ExecStart=/usr/bin/go/bin/go run github.com/favonia/cloudflare-ddns/cmd/ddns@latest +Restart=always +RestartSec=300 + +[Install] +WantedBy=multi-user.target +EOF +msg_ok "Systemd service configured" + +msg_info "Enabling and starting service" +systemctl daemon-reload +systemctl enable --now cloudflare-ddns.service +msg_ok "Cloudflare DDNS service started" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" + +msg_ok "Completed Successfully! Cloudflare DDNS is running in the background.\n" From 33c2469174a5bba45146a6dd0edbb1ec312a84b2 Mon Sep 17 00:00:00 2001 From: Edoardo Pavan Date: Thu, 24 Apr 2025 17:47:04 +0200 Subject: [PATCH 2/7] fix: suggestions from PR --- ct/cloudflare-ddns.sh | 10 +----- install/cloudflare-ddns-install.sh | 54 +++++++++++++----------------- 2 files changed, 25 insertions(+), 39 deletions(-) diff --git a/ct/cloudflare-ddns.sh b/ct/cloudflare-ddns.sh index 838365d..9c6f604 100644 --- a/ct/cloudflare-ddns.sh +++ b/ct/cloudflare-ddns.sh @@ -27,7 +27,7 @@ function update_script() { msg_error "No ${APP} Installation Found!" exit fi - msg_error "We don't provide an update function because the service ${APP} use every time the latest version." + msg_error "There is no update function for ${APP}." exit } @@ -35,11 +35,3 @@ start build_container description msg_ok "Completed Successfully!\n" -echo -e "${APP} setup has been successfully initialized!\n" -echo -e "If you want to update the service go to the container and run the command:\n" -echo -e "sudo nano /etc/systemd/system/cloudflare-ddns.service\n" -echo -e "Update the token or the other environment variables and save the file.\n" -echo -e "Then run the command:\n" -echo -e "sudo systemctl daemon-reload\n" -echo -e "And finally restart the service with:\n" -echo -e "sudo systemctl restart cloudflare-ddns.service" \ No newline at end of file diff --git a/install/cloudflare-ddns-install.sh b/install/cloudflare-ddns-install.sh index b4ea27f..daf4de0 100644 --- a/install/cloudflare-ddns-install.sh +++ b/install/cloudflare-ddns-install.sh @@ -14,54 +14,50 @@ network_check update_os msg_info "Installing dependencies" -$STD apt-get update $STD apt-get install -y curl systemd +msg_ok "Installed dependencies" msg_info "Installing Go" GO_VERSION=$(curl -s https://go.dev/VERSION?m=text | grep -m1 '^go') GO_TARBALL="${GO_VERSION}.linux-amd64.tar.gz" GO_URL="https://go.dev/dl/${GO_TARBALL}" INSTALL_DIR="/usr/bin" -echo "📦 Download Go ${GO_VERSION} from ${GO_URL}..." - rm -rf "${INSTALL_DIR}/go" - curl -LO "$GO_URL" tar -C "$INSTALL_DIR" -xzf "$GO_TARBALL" -rm "$GO_TARBALL" - echo 'export PATH=$PATH:/usr/bin/go/bin' >> ~/.bashrc source ~/.bashrc -go version - -msg_ok "Dependencies installed" +msg_ok "Installed Go" msg_info "Configure Application" - var_cf_api_token="default" -var_cf_api_token=$(whiptail --title "CLOUDFLARE TOKEN" --backtitle "Type the Cloudflare Api Token:" --inputbox "token" 10 60 3>&1 1>&2 2>&3) -msg_ok "Cloudflare Api Token: '${var_cf_api_token}'" +read -rp "Enter the Cloudflare API token: " var_cf_api_token var_cf_domains="default" -var_cf_domains=$(whiptail --title "CLOUDFLARE DOMAINS" --backtitle "Type the domains separated with a comma (example.org,www.example.org)" --inputbox "*.example.com" 10 60 3>&1 1>&2 2>&3) -msg_ok "Cloudflare Domains: '${var_cf_domains}'" +read -rp "Enter the domains separated with a comma (*.example.org,www.example.org) " var_cf_domains var_cf_proxied="false" -if whiptail --yesno "Proxied?" 8 45; then - var_cf_proxied="true" -fi +while true; do + read -rp "Proxied? (y/n): " answer + case "$answer" in + [Yy]* ) var_cf_proxied="true"; break;; + [Nn]* ) var_cf_proxied="false"; break;; + * ) echo "Please answer y or n.";; + esac +done var_cf_ip6_provider="none" -if whiptail --yesno "IPv6 Provider?" 8 45; then - var_cf_ip6_provider="cloudflare" -else - var_cf_ip6_provider="none" -fi +while true; do + read -rp "Enable IPv6 support? (y/n): " answer + case "$answer" in + [Yy]* ) var_cf_ip6_provider="auto"; break;; + [Nn]* ) var_cf_ip6_provider="none"; break;; + * ) echo "Please answer y or n.";; + esac +done +msg_ok "Configured Application" -msg_ok "Application Configured" - -msg_info "Setting up systemd service" +msg_info "Setting up service" mkdir -p /root/go -chown -R root:root /root/go cat </etc/systemd/system/cloudflare-ddns.service [Unit] Description=Cloudflare DDNS Service (Go run) @@ -84,8 +80,7 @@ EOF msg_ok "Systemd service configured" msg_info "Enabling and starting service" -systemctl daemon-reload -systemctl enable --now cloudflare-ddns.service +systemctl enable -q --now cloudflare-ddns.service msg_ok "Cloudflare DDNS service started" motd_ssh @@ -94,6 +89,5 @@ customize msg_info "Cleaning up" $STD apt-get -y autoremove $STD apt-get -y autoclean +rm -f "$GO_TARBALL" msg_ok "Cleaned" - -msg_ok "Completed Successfully! Cloudflare DDNS is running in the background.\n" From 5e1ce1504e7eb255f7afc70f8e02285dc82f4b86 Mon Sep 17 00:00:00 2001 From: Edoardo Pavan Date: Thu, 24 Apr 2025 18:19:36 +0200 Subject: [PATCH 3/7] feat: add cloudflare-ddns.json --- frontend/public/json/cloudflare-ddns.json | 44 +++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 frontend/public/json/cloudflare-ddns.json diff --git a/frontend/public/json/cloudflare-ddns.json b/frontend/public/json/cloudflare-ddns.json new file mode 100644 index 0000000..29ee612 --- /dev/null +++ b/frontend/public/json/cloudflare-ddns.json @@ -0,0 +1,44 @@ +{ + "name": "Cloudflare-DDNS", + "slug": "cloudflare-ddns", + "categories": [ + 4 + ], + "date_created": "2025-04-23", + "type": "ct", + "updateable": false, + "privileged": false, + "interface_port": null, + "documentation": "https://github.com/favonia/cloudflare-ddns", + "config_path": "/etc/systemd/system/cloudflare-ddns.service", + "website": null, + "logo": null, + "description": "A feature-rich and robust Cloudflare DDNS updater with a small footprint. The program will detect your machine’s public IP addresses and update DNS records using the Cloudflare API", + "install_methods": [ + { + "type": "default", + "script": "ct/cloudflare-ddns.sh", + "resources": { + "cpu": 1, + "ram": 512, + "hdd": 2, + "os": "Debian", + "version": "12" + } + } + ], + "default_credentials": { + "username": null, + "password": null + }, + "notes": [ + { + "text": "To setup the updater you must have the Cloudflare Token and the domains, please read the Github documentation at \"Step 1: Updating the Compose File\" (only the expandable section)", + "type": "warning" + }, + { + "text": "To update the configuration edit `/etc/systemd/system/cloudflare-ddns.service`. After edit please restard with `sudo systemctl restart cloudflare-ddns.service`", + "type": "info" + } + ] +} \ No newline at end of file From d8f6acb17c6ebe8712512bd68711d23726385a43 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Mon, 28 Apr 2025 18:55:16 +0200 Subject: [PATCH 4/7] Update ct/cloudflare-ddns.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Slaviša Arežina <58952836+tremor021@users.noreply.github.com> --- ct/cloudflare-ddns.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ct/cloudflare-ddns.sh b/ct/cloudflare-ddns.sh index 9c6f604..0cc2387 100644 --- a/ct/cloudflare-ddns.sh +++ b/ct/cloudflare-ddns.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func) # Copyright (c) 2021-2025 community-scripts ORG # Author: edoardop13 # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE From 1d47fea34acf8f678f6b802713ce70e2ce10a02a Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 29 Apr 2025 15:02:19 +0200 Subject: [PATCH 5/7] Update frontend/public/json/cloudflare-ddns.json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Slaviša Arežina <58952836+tremor021@users.noreply.github.com> --- frontend/public/json/cloudflare-ddns.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/public/json/cloudflare-ddns.json b/frontend/public/json/cloudflare-ddns.json index 29ee612..491a3bc 100644 --- a/frontend/public/json/cloudflare-ddns.json +++ b/frontend/public/json/cloudflare-ddns.json @@ -11,7 +11,7 @@ "interface_port": null, "documentation": "https://github.com/favonia/cloudflare-ddns", "config_path": "/etc/systemd/system/cloudflare-ddns.service", - "website": null, + "website": "https://github.com/favonia/cloudflare-ddns", "logo": null, "description": "A feature-rich and robust Cloudflare DDNS updater with a small footprint. The program will detect your machine’s public IP addresses and update DNS records using the Cloudflare API", "install_methods": [ From 2b951d50201e8ea6c2bb81bf757ad35009a596e5 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 29 Apr 2025 15:02:27 +0200 Subject: [PATCH 6/7] Update frontend/public/json/cloudflare-ddns.json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Slaviša Arežina <58952836+tremor021@users.noreply.github.com> --- frontend/public/json/cloudflare-ddns.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/public/json/cloudflare-ddns.json b/frontend/public/json/cloudflare-ddns.json index 491a3bc..f40b68f 100644 --- a/frontend/public/json/cloudflare-ddns.json +++ b/frontend/public/json/cloudflare-ddns.json @@ -9,7 +9,7 @@ "updateable": false, "privileged": false, "interface_port": null, - "documentation": "https://github.com/favonia/cloudflare-ddns", + "documentation": "https://github.com/favonia/cloudflare-ddns/blob/main/README.markdown", "config_path": "/etc/systemd/system/cloudflare-ddns.service", "website": "https://github.com/favonia/cloudflare-ddns", "logo": null, From 805701e965f972261ed0af1861c2d38218ed2e40 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 29 Apr 2025 15:02:35 +0200 Subject: [PATCH 7/7] Update frontend/public/json/cloudflare-ddns.json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Slaviša Arežina <58952836+tremor021@users.noreply.github.com> --- frontend/public/json/cloudflare-ddns.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/public/json/cloudflare-ddns.json b/frontend/public/json/cloudflare-ddns.json index f40b68f..55e0acd 100644 --- a/frontend/public/json/cloudflare-ddns.json +++ b/frontend/public/json/cloudflare-ddns.json @@ -12,7 +12,7 @@ "documentation": "https://github.com/favonia/cloudflare-ddns/blob/main/README.markdown", "config_path": "/etc/systemd/system/cloudflare-ddns.service", "website": "https://github.com/favonia/cloudflare-ddns", - "logo": null, + "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/svg/cloudflare.svg", "description": "A feature-rich and robust Cloudflare DDNS updater with a small footprint. The program will detect your machine’s public IP addresses and update DNS records using the Cloudflare API", "install_methods": [ {