Guest User

Untitled

a guest
Feb 14th, 2020
105
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2.  
  3. # This script checks my Public IP using dig and uploads it in github.com
  4. # Name the output file with the descrition of the target network e.g. home_in_Sofia
  5.  
  6. # Base variables
  7. root="${HOME}/myip"
  8. file="${root}/ideapad_ruse_ip.txt"
  9.  
  10. # Ensure root dir
  11. mkdir -p "${root}"
  12.  
  13. # Ensure git repo
  14. cd "${root}"
  15. [[ -d "${root}/.git" ]] || {
  16.   git init
  17.   git remote add origin git@github.com:alabalistic/myip.git
  18. }
  19.  
  20. # Recreate file
  21. > "${file}"
  22. # Print date and time
  23. date '+%c' >> "${file}"
  24. # Print machine name
  25. echo "${HOSTNAME}" >> "${file}"
  26. # Print the public ip address
  27. dig +short TXT o-o.myaddr.l.google.com @ns1.google.com >> "${file}"
  28.  
  29. # Stash changes
  30. git stash
  31. # Fetch and apply latest master
  32. git fetch origin master
  33. git reset origin/master
  34. # Apply stash over
  35. git stash pop
  36. # Add, commit, push
  37. git add .
  38. git commit -m 'Update'
  39. git push origin master
RAW Paste Data