Skip to content

Instantly share code, notes, and snippets.

@bradschm
Created October 12, 2016 18:18
Show Gist options
  • Select an option

  • Save bradschm/4881c3d5c706eee8dd1603d48632d31d to your computer and use it in GitHub Desktop.

Select an option

Save bradschm/4881c3d5c706eee8dd1603d48632d31d to your computer and use it in GitHub Desktop.
Use rsync to sync Casper distribution points and restrict packages to specific subnets.
#!/bin/bash
##########################################
### Script to rsync Caspershare points
### Name site based packages SB-###-Package name
### All pacakges with SB-* will be ignored and SB-<matching octet>-filename will be synced
### Author B. Schmidt 12-31-2012
##########################################
# Get IP Subnet
ipsub=$(ifconfig | grep 10. | grep inet | cut -f2 -d " " | cut -f2 -d "." | head -1)
# Get Caspershare location if it is not on the boot drive.
cd /Volumes/*/Caspershare
cd ..
csloc=$(pwd)
# Randomize timing so cron/launchd can be the same time.
sleep $(echo $RANDOM*10%25200 | bc)
# Do the rsync exluding other site based packgaes but included own subnet
/usr/bin/rsync -avx --delete-before --include=*SB-$ipsub* --exclude=*Temporary* --exclude=SB-* --exclude=*Deleted* -e ssh sync@server.com:/Volumes/Data/CasperShare "$csloc"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment