-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
terminal-notifier and rollBack script for testing
- Loading branch information
1 parent
9976e0a
commit 36b28f4
Showing
4 changed files
with
231 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,35 @@ | ||
XProtectWatch | ||
============= | ||
|
||
This a tool to copy the XProtect.plist file whenever it changes via LaunchDaemon. This is not a managment system for XProtect. | ||
XProtectWatch | ||
------------- | ||
This a tool to copy the XProtect.plist file whenever it changes via a User LaunchAgents. This is not a managment system for XProtect. | ||
|
||
Copy the files as needed: | ||
|
||
* /usr/local/bin/watchProtect.sh | ||
* /Library/LaunchDaemons/com.stonyrivertech.XProtect.plist | ||
* ~/Library/LaunchAgents/com.stonyrivertech.XProtect.plist | ||
|
||
Be sure to chmod +x /usr/local/bin/watchProtect.sh so it's an executable script and that the plist permisions are ```rw-r--r-- 1 root wheel``` | ||
Be sure to chmod +x /usr/local/bin/watchProtect.sh so it's an executable script and that the plist permisions are ```rw-r--r-- 1 username staff``` | ||
|
||
Once the files are copied to your computer in the correct locations you can load the LaunchDaemon via: | ||
|
||
```sudo launchctl load /Library/LaunchDaemons/com.stonyrivertech.XProtect.plist``` | ||
```sudo launchctl load ~/Library/LaunchAgents/com.stonyrivertech.XProtect.plist``` | ||
|
||
Debug | ||
----- | ||
You can enable debug mode by changing the value of the following loke on watchProtect.sh | ||
```debug_log="disabled" # Change to "enable" to start debug logs``` | ||
|
||
RollBack | ||
-------- | ||
### rollBack.sh ### | ||
THIS IS A HACK SCRIPT! I just created this to help me test terminal-notifier to force a new update by copping the old data and removing some archives. Not a true managment solution. | ||
|
||
terminal-notifier | ||
----------------- | ||
If you want to be notified of updates via Notification Center, I've enabled some small validation items to utilize [terminal-notifier][terminal-notifier]. You can run the terminal-notifier.sh script from this repot which will download, verify md5 hash, unzip, and install to your /Applications folder. | ||
|
||
![Terminal Notifier Example](https://zcd-03.s3-external-1.amazonaws.com/ACLIDWKJQ5ZFC%2FXR4tJbM%2Fknp30lALVCx8YBdy%2B4AiiXCBFhkYigRQKVTg1j4qjJvgWMHRDD0C2UbFmX6IfPSQ9VvIRBOGr67DvYa3yB5dT1CueKGXWWbXqy3H4Sg3RM%2FDi0UpNKjJ092aHvCVErOMGrewEave84Q3H6W%2Bg%2Bj8t2TCHVCZVZDqmbUTMxdi9tjryrJLs4CtAJ9pwDehbnFtFaVgLX79Ig2z%2FgeAAmk4QyKcIDIISCOPYTUycUzgGwTgRu3LGrSRzWT5Dtqi9FoewuDW4eleDSBk4MYm7HjpZOvQEtzok%2Bi91hVyXpg%2F1FIxjBLoWSneNTE%2F%2F356x121.jpg?Expires=1364121878&response-expires=Sun%2C%2024%20Mar%202013%2010%3A44%3A38%20GMT&response-content-disposition=filename%3D%22356x121.jpg%22&x-amz-security-token=AQoDYXdzEIH%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEa4AOuGqd3ZxRm6YB9jlIV3StNgxntoktOD4PhaNq0K4BjmXne3B8ls3AbebMMU2Jy%2BgzR%2B1c5f2jeRLS4vTFZqWk45Yq2%2BOYeJ6uakkMz0unwzfN0w%2BKChVQ6m2FjuffWxKAxfZ7WVLi%2BcHJt%2B%2BFxtQm6wi%2FTmf23gtHq2TGH7GEoE%2FrMQ3Pf04BTm%2Bmpkg3WxhOjcj%2Fb55gBOil0LfTZaYnaD2xqBPkYUMr0Kdvuu5pW%2Fb0DrxUuIb0dQS57hQtD4QszMn37VCfawDQQx%2B1ckKL9UUNzyODKqSMhcImr9bUktwj6XE9WYbcoSE6OjHbrfThKcnzerfiWpHGuG311kpK9gWugoixeRdXD5kG4weCNiloDEWQo%2FwbUBXeSxB7vkzEBlBvNwwHh5oc9KuhuRPkhdGQO8pP%2Br8LmIeyNjqsM8n%2Fo0g8LgTQgpPV0yURSQuVycdSLg5%2B39w8x0KwIT5hhESAeiLaAQ4Xwyug19QevyUtDRAjW9fwVlrL1ovTb4ugFRKGTy7%2BlljmSk9zPcfaGnLjjnG5N1in12WAlOyJ5CfaSh4eCKn213CsKsE4SrEPfQckrxkB512WhP1EvGVVVsL5gnvUm0VKEK3yYq7Szq%2Fvffy%2FNIk%2Bfggc%2BMcLuQAUgotazigU%3D&AWSAccessKeyId=ASIAJA3O7BGY6U3UJFXA&Signature=QIdgiJO3E22lM7CpqRsNLrWeINE%3D "Terminal Notifier Example") | ||
|
||
[terminal-notifier]: https://github.com/alloy/terminal-notifier |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/bash | ||
|
||
# This script was developed BY Stony River Technologies (SRT) | ||
# ALL scripts are covered by SRT's Licnese found at: | ||
# https://raw.github.com/stonyrivertech/SRT-Public/master/LICENSE | ||
|
||
# Created by Justin Rummel | ||
# Version 1.0.0 - 3/06/2013 | ||
|
||
# Modified by | ||
# Version | ||
|
||
|
||
### Description | ||
# Goal is install terminal-notifier zipped binary from their git repo. | ||
|
||
# Base Variables that I use for all scripts. Creates Log files and sets date/time info | ||
declare -x SCRIPTPATH="${0}" | ||
declare -x RUNDIRECTORY="${0%/*}" | ||
declare -x SCRIPTNAME="${0##*/}" | ||
|
||
logtag="${0##*/}" | ||
debug_log="enable" | ||
logDate=`date +"% Y.% m.% d"` | ||
logDateTime=`date +"% Y.% m.06_% H-% M-% S"` | ||
log_dir="/Library/Logs/${logtag}" | ||
LogFile="${logtag}-${logDate}.log" | ||
|
||
# Script Variables | ||
tn="terminal-notifier_1.4.2.zip" | ||
dl="https://github.com/downloads/alloy/terminal-notifier/${tn}" | ||
tnHash="b5bc814b4872c9e381390d4fe11ad367" | ||
dest="/Applications/" | ||
|
||
# Script Functions | ||
download () { | ||
cd /tmp | ||
curl -OL "${dl}" | ||
} | ||
|
||
unzipTN () { | ||
cd /tmp | ||
hash=`openssl md5 /tmp/"${tn}" | awk -F "= " '{print $2}'` | ||
|
||
[ "${hash}" == "${tnHash}" ] && { unzip "${tn}"; mv /tmp/terminal-notifier_1.4.2/terminal-notifier.app "${dest}"; } || { logger "hash ${hash} did not match ${tnHash}. Stopping now."; exit 1; } | ||
} | ||
|
||
|
||
|
||
download | ||
unzipTN | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
#!/bin/bash | ||
|
||
# This script was developed BY Stony River Technologies (SRT) | ||
# ALL scripts are covered by SRT's License found at: | ||
# https://raw.github.com/stonyrivertech/SRT-Public/master/LICENSE | ||
|
||
# Created by Justin Rummel | ||
# Version 1.0.0 - 2013-3-22 | ||
|
||
# Modified by | ||
# Version | ||
|
||
|
||
### Description | ||
# Goal is to | ||
|
||
# Base Variables that I use for all scripts. Creates Log files and sets date/time info | ||
declare -x SCRIPTPATH="${0}" | ||
declare -x RUNDIRECTORY="${0%/*}" | ||
declare -x SCRIPTNAME="${0##*/}" | ||
|
||
logtag="${0##*/}" | ||
debug_log="disabled" # Change to "enable" to start debug logs | ||
logDate=`date +"%Y-%m-%d"` | ||
logDateTime=`date +"%Y-%m-%d_%H.%M.%S"` | ||
log_dir="/Library/Logs/${logtag}" | ||
LogFile="${logtag}-${logDate}.log" | ||
|
||
# Script Variables | ||
sourceDir="/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/" | ||
destineDir="/Users/Shared/XProtect/" | ||
XPath=".version/" | ||
file="XProtect.plist" | ||
metaFile="XProtect.meta.plist" | ||
version=`/usr/libexec/PlistBuddy -c "print :Version" /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/XProtect.meta.plist` | ||
#rm=`ls -al /Users/Shared/XProtect/ | tail -1 | awk '{print $9}'` | ||
#meta=`echo "${lastX}" | sed 's/plist/meta.plist/'` | ||
|
||
# Script Functions | ||
verifyRoot () { | ||
#Make sure we are root before proceeding. | ||
[ `id -u` != 0 ] && { echo "$0: Please run this as root."; exit 0; } | ||
} | ||
|
||
# Output to stdout and LogFile. | ||
logThis () { | ||
logger -s -t "${logtag}" "$1" | ||
[ "${debug_log}" == "enable" ] && { echo "${logDateTime}: ${1}" >> "${log_dir}/${LogFile}"; } | ||
} | ||
|
||
init () { | ||
# Make our log directory | ||
[ ! -d $log_dir ] && { mkdir $log_dir; } | ||
|
||
# Now make our log file | ||
if [ -d $log_dir ]; then | ||
[ ! -e "${log_dir}/${LogFile}" ] && { touch $log_dir/${LogFile}; logThis "Log file ${LogFile} created"; logThis "Date: ${logDateTime}"; } | ||
else | ||
echo "Error: Could not create log file in directory $log_dir." | ||
exit 1 | ||
fi | ||
echo " " >> "${log_dir}/${LogFile}" | ||
} | ||
|
||
stop () { | ||
logThis "Stopping com.apple.xprotectupdater" | ||
launchctl unload /System/Library/LaunchDaemons/com.apple.xprotectupdater.plist | ||
launchctl unload /Library/LaunchDaemons/com.stonyrivertech.XProtect.plist | ||
} | ||
|
||
clean () { | ||
# remove the .version file | ||
logThis "removing ${destineDir}${XPath}${version}" | ||
rm "${destineDir}${XPath}${version}" | ||
|
||
# remove the last two plist files in the destination folder /Users/Shared/XProtect | ||
logThis "removing last two files in ${destineDir}" | ||
last1=`ls -al /Users/Shared/XProtect/ | tail -1 | awk '{print $9}'` | ||
rm "${destineDir}${last1}" | ||
last2=`ls -al /Users/Shared/XProtect/ | tail -1 | awk '{print $9}'` | ||
rm "${destineDir}${last2}" | ||
} | ||
|
||
replace () { | ||
logThis "Begin replacing old data to be 'current'" | ||
|
||
last3=`ls -al /Users/Shared/XProtect/ | grep -v meta | tail -1 | awk '{print $9}'` | ||
logThis "copping ${last3} to it's old house" | ||
cp "${destineDir}${last3}" /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/XProtect.plist | ||
|
||
meta3=`echo "${last3}" | sed 's/plist/meta.plist/'` | ||
logThis "copping ${meta3} to it's old house" | ||
cp "${destineDir}${meta3}" /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/XProtect.meta.plist | ||
} | ||
|
||
start () { | ||
logThis "Starting com.apple.xprotectupdater" | ||
launchctl load /Library/LaunchDaemons/com.stonyrivertech.XProtect.plist | ||
launchctl load /System/Library/LaunchDaemons/com.apple.xprotectupdater.plist | ||
} | ||
|
||
verifyRoot | ||
init | ||
stop | ||
clean | ||
replace | ||
start | ||
|
||
exit 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters