Skip to content

Instantly share code, notes, and snippets.

@nczz
Last active October 27, 2015 06:18
Show Gist options
  • Save nczz/69bcabbcbad7874d4e01 to your computer and use it in GitHub Desktop.
Save nczz/69bcabbcbad7874d4e01 to your computer and use it in GitHub Desktop.
Update dynamic IP to server
#!/bin/bash
ip=`ip -4 route get 1 | head -1 | cut -d' ' -f8 | tr -d '\n'`
now=`date`
printf -v data '{"IP":"%s","UpdatedAt":"%s"}' $ip "$now"
curl -X PATCH -d "$data" 'http://path.to/server/log'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment