Skip to content

Instantly share code, notes, and snippets.

@fguchelaar
Last active February 2, 2022 19:35
Show Gist options
  • Save fguchelaar/5956211 to your computer and use it in GitHub Desktop.
Save fguchelaar/5956211 to your computer and use it in GitHub Desktop.
Auto update SABnzbd on Mac OS X. This AppleScript checks if you're running the latest version of SABnzbd and, if necessary, updates. It assumes SABnzbd is located in the '/Applications' folder.
-- Choose your OS X version
--set osx to "OS X 10.5 and 10.6 (Leopards)"
--set osx to "OS X 10.7 (Lion)"
set osx to "OS X 10.8 (Mountain Lion)"
set currentVersion to get version of application "SABnzbd"
log "You are running: " & currentVersion
set versionUrl to "http://sabnzbdplus.sourceforge.net/version/latest"
set versionContent to do shell script "curl " & quoted form of versionUrl
set latestVersion to first paragraph of versionContent
if latestVersion > currentVersion then
log "A new version is available: " & latestVersion
tell application "SABnzbd" to quit
set downloadUrl to "http://downloads.sourceforge.net/project/sabnzbdplus/sabnzbdplus/" & latestVersion & "/SABnzbd-" & latestVersion & "-osx.dmg"
set diskImageName to "SABnzbd-" & latestVersion
set diskImagePath to "~/Downloads/" & diskImageName & "-osx.dmg"
do shell script "curl -L " & quoted form of downloadUrl & " > " & diskImagePath
tell application "Finder"
if (exists diskImageName) then
eject disk diskImageName
end if
end tell
do shell script "hdiutil attach " & diskImagePath
tell application "Finder"
set sourceFile to file "SABnzbd.app" of folder osx of disk diskImageName
set destination to path to applications folder
duplicate sourceFile to destination with replacing
eject disk diskImageName
end tell
tell application "SABnzbd" to launch
log "Done. Up and running."
else
log "You are running the latest version: " & latestVersion
end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment