Skip to content

Instantly share code, notes, and snippets.

@syzdek
Created August 9, 2018 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save syzdek/4e59c61e4163ed2f057b3df1e6e87150 to your computer and use it in GitHub Desktop.
Save syzdek/4e59c61e4163ed2f057b3df1e6e87150 to your computer and use it in GitHub Desktop.

This following can used to distribute common files amoung hosts. For example, to distribute a shared hosts file.

Initial Setup:

  mkdir /etc/gitfiles
  cd /etc/gitfiles
  git init
  git remote add origin https://1.2.3.4/path/to/shared/repo.git
  git fetch origin
  git branch -f master origin/master
  git checkout master
  
  cd /etc
  ln -sf /etc/gitfiles/hosts

Create update script (/etc/gitfiles/update-repo.sh):

  #!/bin/bash
  update_repo()
  {  
     cd "$(dirname "${0}")"  || exit 1
     git fetch origin        || exit 1
     git merge origin/master || exit 1
  }
  update_repo

Add to Cron:

  */15 * * * * bash /etc/gitfiles/update-repo.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment