Monday, November 24, 2014

arch sonarr auto update sonarr PKGBUILD script

sonarr-develop in aur now automatically installs the latest version. (pkgver) https://wiki.archlinux.org/index.php/VCS_package_guidelines#The_pkgver.28.29_function
 #!/bin/sh  
 # Where the release information is.  
 API_ENDPOINT="https://services.sonarr.tv/v1/update/develop?os=linux"  
 # Put the release info into a variable.  
 json=$(curl -s $API_ENDPOINT)  
 # Get version and hash using JSON parser for the shell.  
 VERSION=$(jshon -e updatePackage -e version -u <<< $json)  
 HASH=$(jshon -e updatePackage -e hash -u <<< $json)  
 echo "Found latest version:" $VERSION  
 echo "Changing PKGBUILD"  
 # Get the version inside the PKGBUILD.  
 PREV_VER=$(grep pkgver PKGBUILD | head -n1 | awk -F= '{print $2;}' | sed 's/\"//g')  
 # Replace old version with new.  
 sed -i "s/^pkgver=\"$PREV_VER\"$/pkgver=\"$VERSION\"/" PKGBUILD  
 echo "Downloading Release"  
 # Get the release.  
 if [ -f NzbDrone.master.$VERSION.mono.tar.gz ]; then  
   echo "Already have latest version"  
   return   
 fi  
 wget http://update.nzbdrone.com/v2/develop/mono/NzbDrone.develop.$VERSION.mono.tar.gz  
 echo $HASH "NzbDrone.develop."$VERSION".mono.tar.gz"| sha256sum -c - --status  
 if [ $? = 0 ]; then  
      updpkgsums  
      makepkg -f  
      sudo pacman -U "sonarr-develop-"$VERSION"-1-any.pkg.tar.xz"  
      sudo systemctl daemon-reload  
      sudo systemctl restart sonarr  
 else  
   echo "CHECKSUMS DID NOT MATCH"  
 fi  

No comments:

Post a Comment