Skip to content

Instantly share code, notes, and snippets.

@Strykar
Last active November 4, 2016 22:44
Show Gist options
  • Select an option

  • Save Strykar/f4e4a093ea0c8cea2e0c967da127dfd0 to your computer and use it in GitHub Desktop.

Select an option

Save Strykar/f4e4a093ea0c8cea2e0c967da127dfd0 to your computer and use it in GitHub Desktop.
Create and maintain a local mirror of a remote rsync directory. Use this method to update Slackware.
#!/bin/sh
#
# create and maintain a local mirror of a remote rsync directory
# ex. rsync://mirror.its.dal.ca/debian/dists/sid/
# run daily in cron '0 2 * * * /path/to/update.sh > /dev/null 2>&1'
# strykar <strykar@hotmail.com> date 1109945833
# define local mirror path and exclude.txt, a newline list like: *.txt
# do not add anything to the _targetpath dir, it will get deleted the next sync
targetpath='/root/updates'
pathexclude='/root/exclude.txt'
# 'rysnc -a' implies '-rlptgoD' do not enable compression
options="-avh \
--stats \
--no-motd \
-F --exclude-from $pathexclude \
--delete-after \
--delete-excluded"
# rsync binary
rsyncbin='/usr/bin/rsync'
# remote rsync://dir path, this must end with a / do not use /* or rsync://
targetdest='rsync.osuosl.org/slackware/slackware64-14.2/patches/packages/'
# Search for new remote updates, delete stale local files/dir, rsync remote dir+sub-dir
$rsyncbin $options rsync://$targetdest $targetpath
printf '\nRsync complete! Verifying signatures.....\n\n'
sleep 2
# comment the lines below if called from cron
# _targetpath now contains latest Slackware security updates, verify their signatures
# [<security@slackware.com> 1024D/40102233] http://www.slackware.com/gpg-key
/usr/bin/gpg --verify-files $targetpath/*.asc
printf "\n...Done! You could now try: upgradepkg --install-new $targetpath/*.txz\n\n"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment