forked from nextcloud/vm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathddclient-configuration.sh
210 lines (187 loc) Β· 5.78 KB
/
ddclient-configuration.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#!/bin/bash
# T&M Hansson IT AB Β© - 2022, https://www.hanssonit.se/
# Copyright Β© 2021 Simon Lindner (https://github.com/szaimen)
true
SCRIPT_NAME="DynDNS with ddclient"
SCRIPT_EXPLAINER="This script lets you set up DynDNS by using the Linux ddclient software."
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh
# Check for errors + debug code and abort if something isn't right
# 1 = ON
# 0 = OFF
DEBUG=0
debug_mode
# Check if root
root_check
# Check if ddclient is already installed
if [ -n "$DEDYNDOMAIN" ]
then
print_text_in_color "$ICyan" "Setting up ddclient for deSEC..."
elif ! is_this_installed ddclient
then
# Ask for installing
install_popup "$SCRIPT_NAME"
else
# Ask for removal or reinstallation
reinstall_remove_menu "$SCRIPT_NAME"
# Removal
apt-get purge ddclient -y
if is_this_installed libjson-any-perl
then
apt-get purge libjson-any-perl -y
fi
apt-get autoremove -y
rm -f /etc/ddclient.conf
# Show successful uninstall if applicable
removal_popup "$SCRIPT_NAME"
fi
# install needed tool
apt-get update -q4 & spinner_loading
DEBIAN_FRONTEND=noninteractive apt-get install ddclient -y
# Test if file exists
if [ ! -f /etc/ddclient.conf ]
then
msg_box "The default ddclient.conf doesn't seem to exist.\nPlease report this to\n$ISSUES."
exit 1
fi
if [ -n "$DEDYNDOMAIN" ]
then
choice="deSEC"
else
choice=$(whiptail --title "$TITLE" --menu \
"Please choose your DynDNS-Provider.\nYou have to set up an account before you can start.\n
If your DDNS provider isn't already supported, please open a new issue here:\n$ISSUES
$MENU_GUIDE\n\n$RUN_LATER_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \
"Cloudflare" "(cloudflare.com)" \
"deSEC" "(desec.io)" \
"Duck DNS" "(duckdns.org)" \
"Google Domains" "(domains.google)" \
"No-IP" "(noip.com)" \
"Strato" "(strato.de)" 3>&1 1>&2 2>&3)
fi
case "$choice" in
"Cloudflare")
PROVIDER="Cloudflare"
INSTRUCTIONS="register an email address for your domain and get an Cloudflare API-key"
GUIDE="https://www.techandme.se/setup-multiple-accounts-with-ddclient-and-cloudflare/"
PROTOCOL="cloudflare"
SERVER="www.cloudflare.com"
USE_SSL="yes"
;;
"deSEC")
PROVIDER="deSEC"
INSTRUCTIONS="get a DDNS account with password"
GUIDE="https://desec.io/#"
PROTOCOL="dyndns2"
SERVER="update.dedyn.io"
USE_SSL="yes"
;;
"Duck DNS")
PROVIDER="Duck DNS"
INSTRUCTIONS="get a DDNS account with password"
GUIDE="https://www.duckdns.org/faqs.jsp"
PROTOCOL="duckdns"
SERVER="www.duckdns.org"
USE_SSL="yes"
;;
"Google Domains")
PROVIDER="Google Domains"
INSTRUCTIONS="activate DynDNS for your Domain"
GUIDE="https://support.google.com/domains/answer/6147083"
PROTOCOL="dyndns2"
SERVER="domains.google.com"
USE_SSL="yes"
;;
"No-IP")
PROVIDER="No-IP"
INSTRUCTIONS="get a DDNS account with password"
GUIDE="https://youtu.be/1eeMxhpT868"
PROTOCOL="dyndns2"
SERVER="dynupdate.no-ip.com"
USE_SSL="yes"
;;
"Strato")
PROVIDER="Strato"
INSTRUCTIONS="activate DynDNS for your Domain"
GUIDE="https://www.strato.de/faq/domains/so-einfach-richten-sie-dyndns-fuer-ihre-domains-ein/"
PROTOCOL="dyndns2"
SERVER="dyndns.strato.com"
USE_SSL="yes"
;;
"")
msg_box "You haven't selected any option. Exiting!"
exit 1
;;
*)
;;
esac
if [ -n "$DEDYNDOMAIN" ]
then
HOSTNAME="$DEDYNDOMAIN"
LOGIN="$DEDYNDOMAIN"
PASSWORD="$DEDYNAUTHTOKEN"
else
# Instructions
msg_box "Before you can continue, you have to access $PROVIDER and $INSTRUCTIONS.\n\nHere is a guide:\n$GUIDE"
# Ask if everything is prepared
if ! yesno_box_yes "Are you ready to continue?"
then
exit
fi
# Enter your Hostname
HOSTNAME=$(input_box_flow "Please enter the Host that you want to configure DDNS for.\nE.g. 'example.com'")
# Enter your login
LOGIN=$(input_box_flow "Please enter the login for your DDNS provider.\nIt will be most likely the domain \
or registered email address depending on your DDNS Provider.\nE.g. 'example.com' or '[email protected]'
If you are not sure, please refer to the documentation of your DDNS provider.")
# Enter your password
PASSWORD=$(input_box_flow "Please enter the password or api-key that you've got for DynDNS from your DDNS provider.
If you are not sure, please refer to the documentation of your DDNS provider.")
# Present what we gathered
msg_box "You will see now a list of all entered information. Please check that everything seems correct.\n
Provider=$PROVIDER
Host=$HOSTNAME
Login=$LOGIN
Password=$PASSWORD"
# If everything okay, write to file
if ! yesno_box_yes "Do you want to proceed?"
then
exit
fi
# needed for cloudflare to work
if [ "$PROVIDER" = "Cloudflare" ]
then
install_if_not libjson-any-perl
fi
fi
# Write information to ddclient.conf
cat << DDCLIENT_CONF > "/etc/ddclient.conf"
# Configuration file for ddclient generated by debconf
#
# /etc/ddclient.conf
# Default system settings
use=if, if=$IFACE
use=web, web=https://api.ipify.org
# DDNS-service specific setting
# Provider=$PROVIDER
protocol=$PROTOCOL
server=$SERVER
ssl=$USE_SSL
# user specific setting
login=$LOGIN
password=$PASSWORD
# Hostname follows:
zone=$HOSTNAME
$HOSTNAME
DDCLIENT_CONF
# Test connection
msg_box "Everything is set up by now and we will check the connection."
if ! ddclient -verbose
then
msg_box "Something failed while testing the DDNS update.
Please try again by running this script again!"
else
msg_box "Congratulations, it seems like the initial DDNS update worked!
DDclient is now set up correctly!"
fi
exit