Skip to content

Commit

Permalink
support for getting the ip via bash command
Browse files Browse the repository at this point in the history
  • Loading branch information
mattesno1 authored and ddamm committed May 2, 2019
1 parent bcae18b commit b9a7e2b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/example.config.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,11 @@
+ many more ...
'''
ifconfig = 'choose_from_above_or_run_your_own'

'''
A bash command to run in order to retrieve the current IPv4.
If set, takes precedence over 'ifconfig'.
The command used should only output the ip address with no additional output!
'''
ipcommand = ''
9 changes: 8 additions & 1 deletion src/gandi-live-dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@
import requests, json
import config
import argparse
import subprocess

def get_dynip_cmd(ip_command):
''' find out own IPv4 at home <-- this is the dynamic IP which changes more or less frequently
e.g., "curl ifconfig.me/ip", see example.config.py for details to ipcommand providers
'''
ip = subprocess.Popen(ip_command.split(), stdout=subprocess.PIPE).communicate()[0]
return ip.strip('\n')

def get_dynip(ifconfig_provider):
''' find out own IPv4 at home <-- this is the dynamic IP which changes more or less frequently
Expand Down Expand Up @@ -99,7 +106,7 @@ def main(force_update, verbosity):
uuid = get_uuid()

#compare dynIP and DNS IP
dynIP = get_dynip(config.ifconfig)
dynIP = get_dynip_cmd(config.ipcommand) if config.ipcommand else get_dynip(config.ifconfig)
dnsIP = get_dnsip(uuid)

if force_update:
Expand Down

0 comments on commit b9a7e2b

Please sign in to comment.