- if myip is None:
- raise IpMissing()
- try:
- ip = ipaddr.IPAddress(myip) # throws an exception if the IP address is not valid
- except ValueError:
- raise IpInvalid()
- if isinstance(ip, ipaddr.IPv4Address):
- iptype = 'A'
- elif isinstance(ip, ipaddr.IPv6Address):
- iptype = 'AAAA'
+ if not offline:
+ if myip is None:
+ raise MyipMissing()
+ try:
+ ip = ipaddr.IPAddress(myip) # throws an exception if the IP address is not valid
+ except ValueError:
+ raise MyipInvalid()
+ if isinstance(ip, ipaddr.IPv4Address):
+ iptype = 'A'
+ elif isinstance(ip, ipaddr.IPv6Address):
+ iptype = 'AAAA'
+ else:
+ raise MyipInvalid() # should never happen
+
+ # update bind
+ if offline:
+ call(['sudo', '/usr/local/bin/nsupdate_dyndns_del', hostname, 'A'])
+ call(['sudo', '/usr/local/bin/nsupdate_dyndns_del', hostname, 'AAAA'])