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  

Thursday, November 20, 2014

VirtualBox virtual serial port Windows Guest to linux host.


1.) Select "Enable Serial Port"
2.) Port mode: Host Pipe
3.) Create Pipe Checked.
4.) Port/File Path: /tmp/vboxCOM'

Now the port shows up windows.

My version of netcat allows connecting to sockets.

extra/gnu-netcat 0.7.1-5 [installed]



nc -U /tmp/vboxCOM
test
testback


To test sending data over the socket with bash:

function sendData()
{
    nc -U /tmp/vboxCOM <<< $(echo -en "\x1B$*\xD")
}
echo "Sending ST"
sendData "ST"

With python
#!/usr/bin/env python
import socket
import os, os.path
import time 
socketLocation = '/tmp/vboxCOM' 

print("Connecting...")
s = socket.socket(socket.AF_UNIX)
s.settimeout(1) # 1 second timeout, after all it should be instant because its local
s.connect(socketLocation)

def sendMessage(message):
    '''
    Sends a message to a socket.
    '''

    s.send(str.encode(message))
 
 
print("Sending a test message")
sendMessage("test\n")