Follow this script for installing the LXC : https://community-scripts.org/scripts/cloudflare-ddns
Do the setup as you would normally, add your api-key, at least 1 domain and the questions after.
If everything went well, this file should be available /etc/systemd/system/cloudflare-ddns.service
Download the file from this gist with wget https://gist.githubusercontent.com/noahbleau/bfc19ed738829b2a55adbfd502266037/raw/edit-ddns-domains.sh or create the file with the name of your choice (ex.: edit-ddns-domains.sh) with nano or your favorite editor and add the following:
Note
This script was generated by ChatGPT, it's not intended for productive environnement. I do not take credit for it.
#!/bin/bash
SERVICE_FILE="/etc/systemd/system/cloudflare-ddns.service"
# Verify if dialog is installed
if ! command -v dialog &> /dev/null; then
echo "Dialog is not installed. Install with: sudo apt install dialog"
exit 1
fi
# Get current domains
DOMAINS_LINE=$(grep '^Environment="DOMAINS=' "$SERVICE_FILE")
DOMAINS=$(echo "$DOMAINS_LINE" | sed -E 's/.*DOMAINS=([^"]*)".*/\1/')
IFS=',' read -ra DOMAIN_ARRAY <<< "$DOMAINS"
# Prepare checklist
CHECKLIST=()
for domain in "${DOMAIN_ARRAY[@]}"; do
CHECKLIST+=("$domain" "" "on")
done
# Show dialog with checklist
SELECTED=$(dialog --clear \
--title "Cloudflare DDNS Domains" \
--checklist "Uncheck to remove:" 20 60 15 \
"${CHECKLIST[@]}" \
3>&1 1>&2 2>&3)
# Quit if canceled
if [ $? -ne 0 ]; then
clear
echo "Cancel"
exit 0
fi
SELECTED=$(echo "$SELECTED" | tr -d '"')
# Convert into a list
IFS=' ' read -ra SELECTED_ARRAY <<< "$SELECTED"
# Ask if domain need to be added
NEW_DOMAIN=$(dialog --inputbox "Add a domain (leave empty to skip):" 10 50 3>&1 1>&2 2>&3)
# Make the new list
FINAL_DOMAINS=("${SELECTED_ARRAY[@]}")
if [ -n "$NEW_DOMAIN" ]; then
FINAL_DOMAINS+=("$NEW_DOMAIN")
fi
# Create final string
NEW_DOMAINS=$(IFS=','; echo "${FINAL_DOMAINS[*]}")
# Confirm remove
REMOVED=()
for domain in "${DOMAIN_ARRAY[@]}"; do
if [[ ! " ${FINAL_DOMAINS[*]} " =~ " $domain " ]]; then
REMOVED+=("$domain")
fi
done
if [ ${#REMOVED[@]} -gt 0 ]; then
dialog --yesno "These domains will be removed:\n\n${REMOVED[*]}\n\nConfirm ?" 12 50
if [ $? -ne 0 ]; then
clear
echo "Canceled"
exit 0
fi
fi
# Backup
cp "$SERVICE_FILE" "${SERVICE_FILE}.bak"
# Modify the file
sed -i -E "s|Environment=\"DOMAINS=.*\"|Environment=\"DOMAINS=$NEW_DOMAINS\"|" "$SERVICE_FI>
# Reload + restart
systemctl daemon-reload
systemctl restart cloudflare-ddns
clear
echo "✅ Update Done!"
echo "Current domains: $NEW_DOMAINS"The script will automatically restart the cloudflare-ddns service.
Make the script executable with chmod +x edit-ddns-domains.sh.
And run it anytime you want to make changes with sudo ./edit-ddns-domains.sh.