Skip to content

Commit

Permalink
v7.2 (#4404)
Browse files Browse the repository at this point in the history
+ DietPi-DDNS | Add support for FreeDNS: https://freedns.afraid.org/
  • Loading branch information
MichaIng committed May 22, 2021
1 parent 7573de5 commit 5579538
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ New SBC support:
- NanoPi R1 | Initial hardware identifier (ID: 48) and support for this device has been added to DietPi.

Changes:
- DietPi-DDNS | Added native support for FreeDNS: https://freedns.afraid.org/
- DietPi-VPN | When "Reset" is selected, you're now offered to purge the OpenVPN package, as long as neither the OpenVPN (server) install option nor PiVPN is installed. Many thanks to @maartenlangeveld for doing this suggestion: https://github.com/MichaIng/DietPi/issues/4346
- DietPi-AutoStart | Selecting desktop autologin with non-root user has been made much more reliabe. Previously the X server itself was started by the login user, which often requires additional permissions and sometimes, based on GPU and driver, is not possible at all without further customisation. The method has been changed so that LightDM is used for non-root autologins, just like it is for manual desktop logins, but logging into the desktop automatically with the chosen user.
- DietPi-Software | A desktop preference choice has been added. Before first boot via new dietpi.txt AUTO_SETUP_DESKTOP_INDEX setting or with the new menu entry it can be now chosen which desktop to install when another software selection requires one, especially remote desktop solutions. It works like the webserver preference, so it only play a role when a desktop is installed as dependency and is overridden by manual desktop selections.
Expand Down
37 changes: 26 additions & 11 deletions dietpi/dietpi-ddns
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ Available providers:
Use the "-u" and "-p" options if HTTP authentication is required.
DuckDNS Read more: https://www.duckdns.org/about.jsp
Use the "-d" and "-p" options to set domains and account token.
No-IP Read more: https://www.noip.com/about
Use the "-d", "-u" and "-p" options to set domains, username and password.
Dynu Read more: https://www.dynu.com/DynamicDNS
No-IP Read more: https://www.noip.com/about
Use the "-d", "-u" and "-p" options to set domains, username and password.
Dynu Read more: https://www.dynu.com/DynamicDNS
Use the "-d" and "-p" options to set domains and account password.
FreeDNS Read more: https://freedns.afraid.org/
Use the "-p" option to set the token.
'

# Load DietPi-Globals
Expand Down Expand Up @@ -96,6 +98,12 @@ Read()
[[ $DOMAINS ]] || DOMAINS=${command#*hostname=} DOMAINS=${DOMAINS%&password*}
[[ $PASSWORD ]] || PASSWORD=${command#*password=} PASSWORD=${PASSWORD%\'*}

# FreeDNS
elif [[ $command == *'sync.afraid.org'* ]]
then
[[ $PROVIDER ]] || PROVIDER='FreeDNS'
[[ $PASSWORD ]] || PASSWORD=${command%/\'*} PASSWORD=${PASSWORD##*/}

# Custom
else
[[ $PROVIDER ]] || PROVIDER=${command%\'*} PROVIDER=${PROVIDER##*\'}
Expand Down Expand Up @@ -135,6 +143,12 @@ Apply()
url="https://api.dynu.com/nic/update?hostname=$DOMAINS&password=$PASSWORD"
http_auth=

# - FreeDNS
elif [[ $PROVIDER == 'FreeDNS' ]]
then
url="https://sync.afraid.org/u/$PASSWORD/"
http_auth=

# - Custom
else
url=$PROVIDER
Expand Down Expand Up @@ -245,6 +259,7 @@ Menu_Provider()
'DuckDNS' ': Read more: https://www.duckdns.org/about.jsp'
'No-IP' ': Read more: https://www.noip.com/about'
'Dynu' ': Read more: https://www.dynu.com/DynamicDNS'
'FreeDNS' ': Read more: https://freedns.afraid.org/'
'Custom' ": $custom_text"
)
G_WHIP_MENU 'Please select your DDNS provider:' || return 1
Expand All @@ -257,12 +272,12 @@ Menu_Provider()
esac

# Update credentials names
[[ $PROVIDER == 'DuckDNS' ]] && password='Token' || password='Password'
[[ $PROVIDER == 'DuckDNS' || $PROVIDER == 'FreeDNS' ]] && password='Token' || password='Password'
}

Menu_Domains()
{
# Skip with custom provider
# Skip with FreeDNS and custom provider
[[ $PROVIDER == 'DuckDNS' || $PROVIDER == 'No-IP' || $PROVIDER == 'Dynu' ]] || return 0

G_WHIP_DEFAULT_ITEM=$DOMAINS
Expand All @@ -272,8 +287,8 @@ Menu_Domains()

Menu_Username()
{
# Skip with DuckDNS and Dynu
[[ $PROVIDER == 'DuckDNS' || $PROVIDER == 'Dynu' ]] && return 0
# Skip with DuckDNS, Dynu and FreeDNS
[[ $PROVIDER == 'DuckDNS' || $PROVIDER == 'Dynu' || $PROVIDER == 'FreeDNS' ]] && return 0

# Add note for custom provider
local text="Please enter the $username to update your dynamic IP against your DDNS provider.\n - The colon character : is currently not supported!"
Expand All @@ -291,14 +306,14 @@ Menu_Password()
{
# Add note for custom provider
local text="Please enter the $password to update your dynamic IP against your DDNS provider.\n - The single quote character ' is currently not supported!"
[[ $PROVIDER == 'DuckDNS' || $PROVIDER == 'No-IP' || $PROVIDER == 'Dynu' ]] || text+='\n\nThis is used for HTTP authentication. If no HTTP authentication is required, type in a \"0\" to skip the password.'
[[ $PROVIDER == 'DuckDNS' || $PROVIDER == 'No-IP' || $PROVIDER == 'Dynu' || $PROVIDER == 'FreeDNS' ]] || text+='\n\nThis is used for HTTP authentication. If no HTTP authentication is required, type in a \"0\" to skip the password.'

G_WHIP_PASSWORD "$text" || return 1
PASSWORD=$result
unset -v result

# Unset with custom provider when "0" is given
[[ $PROVIDER == 'DuckDNS' || $PROVIDER == 'No-IP' || $PROVIDER == 'Dynu' || $G_WHIP_RETURNED_VALUE != 0 ]] || unset -v PASSWORD
[[ $PROVIDER == 'DuckDNS' || $PROVIDER == 'No-IP' || $PROVIDER == 'Dynu' || $PROVIDER == 'FreeDNS' || $G_WHIP_RETURNED_VALUE != 0 ]] || unset -v PASSWORD
}

Menu_Timespan()
Expand All @@ -312,14 +327,14 @@ Menu_Main()
{
# Adjust credentials names
local username='Username' password='Password'
[[ $PROVIDER == 'DuckDNS' ]] && password='Token'
[[ $PROVIDER == 'DuckDNS' || $PROVIDER == 'FreeDNS' ]] && password='Token'

# Loop through sub menus directly if no provider has been chosen yet, else show main menu
[[ $PROVIDER ]] || { G_WHIP_BUTTON_CANCEL_TEXT='Exit' Menu_Provider || exit 0 && Menu_Domains && Menu_Username && Menu_Password && NEXT_MENU_START='Apply'; }

G_WHIP_MENU_ARRAY=('Provider' ": [$PROVIDER]")
[[ $PROVIDER == 'DuckDNS' || $PROVIDER == 'No-IP' || $PROVIDER == 'Dynu' ]] && G_WHIP_MENU_ARRAY+=('Domains' ": [$DOMAINS]")
[[ $PROVIDER == 'DuckDNS' || $PROVIDER == 'Dynu' ]] || G_WHIP_MENU_ARRAY+=("$username" ": [$USERNAME]")
[[ $PROVIDER == 'DuckDNS' || $PROVIDER == 'Dynu' || $PROVIDER == 'FreeDNS' ]] || G_WHIP_MENU_ARRAY+=("$username" ": [$USERNAME]")
G_WHIP_MENU_ARRAY+=(
"$password" ": [${PASSWORD//?/*}]"
'Timespan' ": [${TIMESPAN:-10} minutes]"
Expand Down

0 comments on commit 5579538

Please sign in to comment.