Skip to content

Commit

Permalink
v9.9
Browse files Browse the repository at this point in the history
- DietPi-DDNS | Do not overwrite CLI address family input with existing cron job. Fix cron job logs in main menu.
- DietPi-DDNS | The cron job does now log server response messages and connection errors separately with respective severities. Some DDNS providers do not return an HTTP error code, but an error text embadded into a regular HTTP 200 response. This, as well as success responses can now be seen via "journalctl -t dietpi-ddns".
  • Loading branch information
MichaIng committed Dec 15, 2024
1 parent 9c0dd2f commit 03e1195
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ New images:
- NanoPi M6 | Support for this FriendlyELEC SBC with RK3588 SoC has been added to DietPi.

Enhancements:
- DietPi-DDNS | The "IPv6or4" option to update IPv6 only, if supported by server, network and provider, has been replaced with "IPv4and6". A server being reachable via IPv6 only is rarely wanted, as many networks do not support it. Instead, usually one will want to have it reachable via both, IPv4 as well as IPv6, which is now possible when using DietPi-DDNS, and the new default. When selected, the IPv4 update needs to succeed to proceed and install the cron job, while the IPv6 update is allowed to fail. In the logs, it will however produce a warning, so admins can check back and in case select IPv4 only, if IPv6 is not supported by server, network or provider. If, e.g. for security reason, IPv6 only is wanted, this option of course remains available, like before. Many thanks to @LOGIN-TB for doing this suggestion: https://github.com/MichaIng/DietPi/issues/7278
- DietPi-DDNS | The "IPv6or4" option to update IPv6 only, if supported by server, network and provider, has been replaced with "IPv4and6". A server being reachable via IPv6 only is rarely wanted, as many networks do not support it. Instead, usually one will want to have it reachable via both, IPv4 as well as IPv6, which is now possible when using DietPi-DDNS, and the new default. If, e.g. for security reason, IPv6 only is wanted, this option of course remains available, like before. Many thanks to @LOGIN-TB for doing this suggestion: https://github.com/MichaIng/DietPi/issues/7278
- DietPi-DDNS | The cron job does now log server response messages and connection errors separately with respective severities. Some DDNS providers do not return an HTTP error code, but an error text embedded into a regular HTTP 200 response. This, as well as success responses can now be seen via "journalctl -t dietpi-ddns". Many thanks to @jtmoon79 for doing this suggestion: https://github.com/MichaIng/DietPi/issues/5954
- DietPi-Services | "dietpi-services start" will not start disabled services anymore. This aligns with the behaviour of the "restart" command, which as well skips disabled services. The script is used within other DietPi scripts to (re)start services after maintenance operations, and it is unexpected when services, who were not running before, but explicitly disabled, are running afterwards. To manually start/stop individual services from the console, we recommend using "systemctl" directly, like on any other Linux distribution with systemd. Many thanks to @intiplink for reporting this unexpected behaviour while using dietpi-drive_manager: https://github.com/MichaIng/DietPi/issues/7302
- DietPi-Software | NFS Server: The "fsid=0" option has been removed from the /mnt/dietpi_userdata default export. As it is uncommon and not respected in "showmount -e" export lists, it caused confusion and issues.
- DietPi-Software | YaCy: The latest YaCy version will now be installed, and the global software password will be set as default admin password on fresh installs.
Expand Down
38 changes: 21 additions & 17 deletions dietpi/dietpi-ddns
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ DOMAINS=
USERNAME=
PASSWORD=
TIMESPAN=
IPFAMILY='-4and6'
IPFAMILY=

# --------------------------------------------
# Functions
Expand Down Expand Up @@ -142,20 +142,23 @@ Read()
fi

# IP family
if grep -q '^curl -4' /var/lib/dietpi/dietpi-ddns/update.sh
if [[ ! $IPFAMILY ]]
then
if grep -q '^curl -6' /var/lib/dietpi/dietpi-ddns/update.sh
if grep -q 'curl -4 ' /var/lib/dietpi/dietpi-ddns/update.sh
then
IPFAMILY='-4and6'
if grep -q 'curl -6 ' /var/lib/dietpi/dietpi-ddns/update.sh
then
IPFAMILY='-4and6'
else
IPFAMILY='-4'
fi

elif grep -q 'curl -6 ' /var/lib/dietpi/dietpi-ddns/update.sh
then
IPFAMILY='-6'
else
IPFAMILY='-4'
IPFAMILY='-4and6' # Pre-v9.9
fi

elif grep -q '^curl -6' /var/lib/dietpi/dietpi-ddns/update.sh
then
IPFAMILY='-6'
else
IPFAMILY='-4and6' # Pre-v9.9
fi

# Time span
Expand All @@ -169,6 +172,7 @@ Apply()
{
# Generate URL and set HTTP authentication flag based on provider
local url http_auth=1
[[ $IPFAMILY ]] || IPFAMILY='-4and6'
# - DuckDNS
if [[ $PROVIDER == 'DuckDNS' ]]
then
Expand Down Expand Up @@ -291,9 +295,9 @@ Apply()
G_EXEC chown dietpi-ddns:dietpi-ddns /var/lib/dietpi/dietpi-ddns/update.sh
# Shellcheck false positive: https://github.com/koalaman/shellcheck/issues/2168
# shellcheck disable=SC2016
echo "curl ${IPFAMILY%and6} -sSfL${http_auth:+ -u '$USERNAME:$PASSWORD'} '$url' 2>&1 > /dev/null | logger -t dietpi-ddns -p 4" >> /var/lib/dietpi/dietpi-ddns/update.sh
echo "{ curl ${IPFAMILY%and6} -sSfL${http_auth:+ -u '$USERNAME:$PASSWORD'} '$url' | logger -t dietpi-ddns -p 6; } 2>&1 | logger -t dietpi-ddns -p 3" >> /var/lib/dietpi/dietpi-ddns/update.sh
# shellcheck disable=SC2016
[[ $IPFAMILY == '-4and6' ]] && echo "curl ${IPFAMILY/4and} -sSfL${http_auth:+ -u '$USERNAME:$PASSWORD'} '$url' 2>&1 > /dev/null | logger -t dietpi-ddns -p 4" >> /var/lib/dietpi/dietpi-ddns/update.sh
[[ $IPFAMILY == '-4and6' ]] && echo "{ curl ${IPFAMILY/4and} -sSfL${http_auth:+ -u '$USERNAME:$PASSWORD'} '$url' | logger -t dietpi-ddns -p 6; } 2>&1 | logger -t dietpi-ddns -p 3" >> /var/lib/dietpi/dietpi-ddns/update.sh

# Apply Cron job
G_DIETPI-NOTIFY 2 'Applying DietPi-DDNS Cron job ...'
Expand All @@ -311,9 +315,8 @@ Remove()
getent passwd dietpi-ddns > /dev/null && G_EXEC_DESC='Removing DietPi-DDNS UNIX user' G_EXEC userdel dietpi-ddns
getent group dietpi-ddns > /dev/null && G_EXEC_DESC='Removing DietPi-DDNS UNIX group' G_EXEC groupdel dietpi-ddns

# Reset variables
unset -v USERNAME PASSWORD TIMESPAN PROVIDER
IPFAMILY='-4and6'
# Unset variables
unset -v USERNAME PASSWORD TIMESPAN PROVIDER IPFAMILY
}

# --------------------------------------------
Expand Down Expand Up @@ -488,10 +491,11 @@ then
else
# Read current settings from existing Cron job
Read
[[ $IPFAMILY ]] || IPFAMILY='-4and6'

# Read status of existing Cron job via last two journal lines: "dietpi-ddns" tag shows curl errors, "cron" tag with "dietpi-ddns" string shows Cron job execution
STATUS='Manage DDNS settings to keep your dynamic IP with the static domain provided by your DDNS provider in sync'
[[ $PROVIDER ]] && STATUS="Last DietPi-DDNS logs:\n$(journalctl -t dietpi-ddns -t CRON | grep -m4 dietpi-ddns)"
[[ $PROVIDER ]] && STATUS="Last DietPi-DDNS logs:\n$(journalctl -r -t dietpi-ddns -t CRON | grep -m4 dietpi-ddns | sort)"

NEXT_MENU_START='Provider'
while Menu_Main; do :; done
Expand Down

0 comments on commit 03e1195

Please sign in to comment.