Created
February 17, 2012 06:13
-
-
Save gsong/1851146 to your computer and use it in GitHub Desktop.
AppleScript to start/stop CrashPlan
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
log "Deciding what to do with CrashPlan…" | |
set isCrashPlanRunning to false | |
try | |
set pid to do shell script "sudo launchctl list | grep com.crashplan.engine" ¬ | |
user name "@{admin_user}" password "@{admin_password}" ¬ | |
with administrator privileges | |
set isCrashPlanRunning to true | |
end try | |
if isCrashPlanRunning then | |
log "CrashPlan is already running: " & pid | |
else | |
log "CrashPlan is not currently running…" | |
end if | |
set acStatus to do shell script "pmset -g ac" | |
if acStatus is "No adapter attached." then | |
log "Computer is running on battery…" | |
set isPluggedIn to false | |
else | |
log "Computer is plugged in…" | |
set isPluggedIn to true | |
end if | |
if isCrashPlanRunning and not isPluggedIn then | |
run script POSIX file "@directory/unload_crashplan.scpt" | |
else if isPluggedIn and not isCrashPlanRunning then | |
log "Loading CrashPlan engine…" | |
do shell script "launchctl load -w /Library/LaunchDaemons/com.crashplan.engine.plist" ¬ | |
user name "@{admin_user}" password "@{admin_password}" ¬ | |
with administrator privileges | |
else | |
log "Nothing needs to be done." | |
end if |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment