#!/bin/bash # ssync--If anything has changed, creates a tarball and syncs a remote # directory via sftp using sftpsync. setglobal sftpacct = '"taylor@intuitive.com'" setglobal tarballname = '"AllFiles.tgz'" setglobal localsource = ""$HOME/Desktop/Wicked Cool Scripts/scripts"" setglobal remotedir = '"/wicked/scripts'" setglobal timestamp = '".timestamp'" setglobal count = '0' # First off, let's see if the local dir exists and has files. if test ! -d $localsource { echo "$0: Error: directory $localsource doesn't exist?" > !2 exit 1 } cd $localsource # Now let's count files to ensure something's changed. if test ! -f $timestamp { for filename in [*] { if test -f $filename { setglobal count = $shExpr(' $count + 1 ') } } } else { setglobal count = $[find . -newer $timestamp -type f -print | wc -l] } if test $count -eq 0 { echo "$[basename $0]: No files found in $localsource to sync with remote."; exit 0 } echo "Making tarball archive file for upload" tar -czf $tarballname ./* # Done! Now let's switch to the sftpsync script. exec sftpsync $sftpacct $remotedir