Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- ################
- ##AwipsToLan.sh##
- ################
- #Brad Schick WFO Goodland, KS
- #11/10/2016
- ##Script used to rsync files via cron from /localapps/runtime/AwipsToLan/data to Linux VM outside of awips.
- ##Version 1.3
- #############################
- #Configuration Variables
- SID=GLD
- path=/localapps/runtime/AwipsToLan
- ldadstagearea=/data/ldad/public/AwipsToLan/
- kvmHOST2rsync=gld-ls-kvm-intra
- kvmHOSTrsyncModule=AwipsToLan
- #End of Config Variables
- #############################
- ##Log when this was ran the last time
- echo "Script launched by `whoami` on `date`">$path/log/AwipsToLan.log
- ##Check for a active lock file, if present we do not continue
- if [[ -a $path/tmp/.lock ]]; then
- echo "Lock File Present! This means AwipsToLan.sh is still running, now EXITING... $path/tmp/.lock" >>$path/log/AwipsToLan.log
- exit
- fi
- ##Run a quick check and see if we have data to move, if not we exit gracefully.
- if [ "$(ls $path/data)" ]; then
- echo "We have files to rsync, so lets get to it!">>$path/log/AwipsToLan.log
- ##Create a lock file to keep another instance of this from stepping itself
- echo "Creating a $path/tmp/.lock to keep another instance of this script from stepping on itself">>$path/log/AwipsToLan.log
- touch $path/tmp/.lock
- ##Grab a listing of the files we are going to rsync
- files2rsync=`ls $path/data`
- echo "The following files/directories will be rsync'd this session">>$path/log/AwipsToLan.log
- ##SCP any data to LDAD
- scp -qr $path/data/* ldad@ls:$ldadstagearea
- ##Remove the files from this location since they have been moved over to LDAD
- for x in $files2rsync
- do
- echo "Files rsync'd to ldad, so now deleting $path/data/$x">>$path/log/AwipsToLan.log
- rm -rf $path/data/$x
- done
- #ssh to ldad and run the rsync to the VM
- ssh -q ldad@ls rsync -poqrtzv --force --progress --stats --remove-source-files $ldadstagearea $kvmHOST2rsync::$kvmHOSTrsyncModule
- echo "Rsync complete" >>$path/log/AwipsToLan.log
- ##Remove the Lock File
- rm -rf $path/tmp/.lock
- echo "Lock File removed... now exiting.">>$path/log/AwipsToLan.log
- else
- echo "No new files found, so exiting...">>$path/log/AwipsToLan.log
- fi
- ##Exit, that's all folks!
- exit
Add Comment
Please, Sign In to add comment