Can Anyone help with script? OMV 2.2

    • OMV 2.x
    • Resolved
    • Can Anyone help with script? OMV 2.2

      Currently I have couchpotato and sabnzbd working well on my system. Headphones and sickbeard don't work but I want to sort out the two working first.
      The only thing remaining is a script that will move the completed files fro the download folder to the drive I have set aside specifically for media.
      This was just beyond my understanding: Transmission - Script to move completed downloads to directories, or how to create script? and what confused me was do I have to find the id all the time - one by one? Thing is I want to move them after they have finished so I want to write the script and run it as a scheduled job which I kind of assumed is a cron job in the backend.
      I saw this script on the internet but the developer did not put a description or guide. Just dropped it for the guy and I suppose both understood what they were doing but it is way too complicated for my level.

      Display Spoiler

      cd "$FOLDER_PATH"

      ####################
      # Movie Processing #
      ####################

      if [ $CATEGORY_NAME = "movies" ]
      then
      # Where do you want to put the movies that this script processes?
      MOVIE_DESTINATION_DIRECTORY=" /media/6f1b1b52-a404-4bb7-a249-382b25b75801/Movies/"

      MOVIE_NAME=`echo $FOLDER_NAME | sed 's/ (.*)//g'`
      echo "Movie Name: $MOVIE_NAME" >> /home/USERNAME/.sabnzbd/logs/sab_proc.log

      if [ `find . -size +629145600c -regex '.*/.*\.avi' | wc -l` -eq 2 ]
      then
      FILEZ[1]="$FOLDER_PATH`find . -size +629145600c -regex '.*/.*\.avi' | sort | sed -n '1p' | sed 's/^\.//'`"
      FILEZ[2]="$FOLDER_PATH`find . -size +629145600c -regex '.*/.*\.avi' | sort | sed -n '2p' | sed 's/^\.//'`"
      echo "Joining Files..." >> /home/USERNAME/.sabnzbd/logs/sab_proc.log
      mencoder -forceidx -ovc copy -oac copy -o "$FOLDER_PATH/$MOVIE_NAME".avi "${FILEZ[1]}" "${FILEZ[2]}"
      #Get the path for the avi
      FILEZ[1]="$FOLDER_PATH`find . -size +629145600c -regex '.*/.*\.avi' | sed 's/^\.//'`"
      echo "Making Folder..." >> /home/USERNAME/.sabnzbd/logs/sab_proc.log
      #Make Folder for the avi
      mkdir "$MOVIE_DESTINATION_DIRECTORY/$MOVIE_NAME"
      echo "Moving Files..." >> /home/USERNAME/.sabnzbd/logs/sab_proc.log
      #Move the avi to the folder
      mv "$FOLDER_PATH/$MOVIE_NAME.avi" "$MOVIE_DESTINATION_DIRECTORY/$MOVIE_NAME/$MOVIE_NAME.avi"
      #If there's an nfo, move that into the folder as well
      if [ `find . -regex '.*/.*\.nfo' | wc -l` -gt 0 ]
      then
      FILEZ[2]="$FOLDER_PATH`find . -regex '.*/.*\.nfo' | sed 's/^\.//'`"
      mv "${FILEZ[2]}" "$MOVIE_DESTINATION_DIRECTORY/$MOVIE_NAME/$MOVIE_NAME.nfo"
      chmod 777 -R "${MOVIE_DESTINATION_DIRECTORY}"/"${MOVIE_NAME}"
      fi
      rm -r "$FOLDER_PATH"
      echo "Removing Folder: $FOLDER_NAME..." >> /home/USERNAME/.sabnzbd/logs/sab_proc.log
      else
      if [ `find . -size +629145600c -regex '.*/.*\.avi' | wc -l` -eq 1 ]
      then
      #Get the path for the avi
      FILEZ[1]="$FOLDER_PATH`find . -size +629145600c -regex '.*/.*\.avi' | sed 's/^\.//'`"
      echo "Making Folder..." >> /home/USERNAME/.sabnzbd/logs/sab_proc.log
      #Make Folder for the avi
      mkdir "$MOVIE_DESTINATION_DIRECTORY/$MOVIE_NAME"
      echo "Moving Files..." >> /home/USERNAME/.sabnzbd/logs/sab_proc.log
      #Move the avi to the folder
      mv "${FILEZ[1]}" "$MOVIE_DESTINATION_DIRECTORY/$MOVIE_NAME/$MOVIE_NAME.avi"
      #If there's an nfo, move that into the folder as well
      if [ `find . -regex '.*/.*\.nfo' | wc -l` -gt 0 ]
      then
      FILEZ[2]="$FOLDER_PATH`find . -regex '.*/.*\.nfo' | sed 's/^\.//'`"
      mv "${FILEZ[2]}" "$MOVIE_DESTINATION_DIRECTORY/$MOVIE_NAME/$MOVIE_NAME.nfo"
      chmod 777 -R "${MOVIE_DESTINATION_DIRECTORY}"/"${MOVIE_NAME}"
      fi
      rm -r "$FOLDER_PATH"
      echo "Removing Folder: $FOLDER_NAME..." >> /home/USERNAME/.sabnzbd/logs/sab_proc.log
      else
      echo "Couldn't copy(too many files or no files?)" >> /home/USERNAME/.sabnzbd/logs/sab_proc.log
      fi
      fi
      fi

      #################
      # TV Processing #
      #################

      if [ $CATEGORY_NAME = "TV" ]
      then

      echo "Beginning TV Processing..." >> /home/USERNAME/.sabnzbd/logs/sab_proc.log

      ##Where is your root TV directory? This script will create folders in it, i.e. ROOT_TV/Seinfeld/Season 8/...
      TV_DESTINATION_DIRECTORY=" /media/6f1b1b52-a404-4bb7-a249-382b25b75801/TV Shows"

      if [ `echo $FOLDER_NAME | awk -F " - " '{print NF}'` -ne 3 ]
      then
      echo "Folder name incorrect, quitting..." >> /home/USERNAME/.sabnzbd/logs/sab_proc.log
      exit 0
      fi
      OPT_NAME=`echo $FOLDER_NAME | sed 's/ (.*)//g'`

      SHOW_NAME=`echo $OPT_NAME | awk -F " - " '{print $1}'`


      echo "Show Name: $SHOW_NAME" >> /home/USERNAME/.sabnzbd/logs/sab_proc.log
      SEASON_NUMBER=`echo $OPT_NAME | awk -F " - " '{print $2}' | awk -F "x" '{print $1}'`
      echo "Season Number: $SEASON_NUMBER" >> /home/USERNAME/.sabnzbd/logs/sab_proc.log
      EPISODE_NUMBER=`echo $OPT_NAME | awk -F " - " '{print $2}' | awk -F "x" '{print $2}'`

      if [ `find . -size +73400320c -regex '.*/.*\.avi' | wc -l` -eq 1 ]
      then
      FILEZ[1]="$FOLDER_PATH`find . -size +73400320c -regex '.*/.*\.avi' | sed 's/^\.//'`"
      echo "One file found, making directories..." >> /home/USERNAME/.sabnzbd/logs/sab_proc.log
      mkdir "$TV_DESTINATION_DIRECTORY/$SHOW_NAME"
      mkdir "$TV_DESTINATION_DIRECTORY/$SHOW_NAME/Season $SEASON_NUMBER"
      echo "Moving File..." >> /home/USERNAME/.sabnzbd/logs/sab_proc.log
      mv "${FILEZ[1]}" "$TV_DESTINATION_DIRECTORY/$SHOW_NAME/Season $SEASON_NUMBER/$OPT_NAME.avi"
      echo "Removing Folder..." >> /home/USERNAME/.sabnzbd/logs/sab_proc.log
      chmod 777 -R "${TV_DESTINATION_DIRECTORY}"/"${SHOW_NAME}"
      rm -r "$FOLDER_PATH"
      else
      echo "Couldn't copy(too many files or no files?)" >> /home/USERNAME/.sabnzbd/logs/sab_proc.log
      fi
      echo "Done!" >> /home/USERNAME/.sabnzbd/logs/sab_proc.log
      fi


      If someone can help me customise it, I will be grateful.
      My sabnzbd folders are as follows:
      Temporary Download Folder:

      Source Code

      1. /media/6f1b1b52-a404-4bb7-a249-382b25b75801/Downloads_nzb

      Completed Download Folder:

      Source Code

      1. /media/6f1b1b52-a404-4bb7-a249-382b25b75801/Movies

      Watched Folder:

      Source Code

      1. /media/0fdb085d-2371-4cc6-86f1-0f98e7e3721a/BitTorrents/watch

      My permissions is 777 so pretty much anybody can write into it so there shouldn't be any permissions issues.
      Please can anybody help with using above script or sharing their script with instructions.
      The TV processing part was ok for me to customise but the movie section just threw me.
      Coding just floors me if it is too complex.
      Can anyone assist?
      Thanks
      I have donated. have you?
      OMV 2.2 running on HP Gen 8 G1610T server, 16GB RAM + Xeon E3-1220
    • It would seem that there aren't many (if any) people trying what you are doing. I don't use any of those so I can't help. Try different things in a VM. Running a scheduled task (cron) isn't difficult to figure out.
      omv 4.1.12 arrakis | 64 bit | 4.15 proxmox kernel | omvextrasorg 4.1.11
      omv-extras.org plugins source code and issue tracker - github

      Please read this before posting a question and this and this for docker questions.
      Please don't PM for support... Too many PMs!
    • Have a look at this : nzbtomedia - [url]https://github.com/clinton-hall/nzbToMedia

      This script can trigger on demand postprocessing (only when the downloading is done) to couchpotato, sickbeard...but its actually the program (couchpotato, or sickbeard) that performs the "moving" part.

      Without this script, you could already set couchpotato to watch your "complete" folder every X minutes, and move everything to the folder designated to store your media files (as said with Sonarr by @blindguys)[/url]
    • Thanks Guys.
      The reason I needed the script was because CP and Sabnzbd were not moving the files as they should. As I have got OMV in a state where it actually works without something breaking, I was reluctant to do anything that might injure that state of affairs. From various write ups, CP should move the folders - it does not.
      I am trying to install the Sonarr plugin and after updating Mono Testing repo and successfully saving it, I try to update the plugins and I get this error message:
      ​Failed to execute command 'export LANG=C; apt-get update 2>&1': Ign file: Release.gpg Ign file: Release Ign file: Translation-en Hit packages.openmediavault.org stoneburner Release.gpg Hit packages.omv-extras.org stoneburner-backports Release.gpg Hit dh2k.omv-extras.org virtualbox-wheezy-mirror Release.gpg Hit ppa.launchpad.net precise Release.gpg Ign shell.ninthgate.se squeeze Release.gpg Hit download.mono-project.com wheezy Release.gpg Hit security.debian.org wheezy/updates Release.gpg Hit ftp.uk.debian.org wheezy Release.gpg Hit dh2k.omv-extras.org plex-wheezy-mirror Release.gpg Hit packages.omv-extras.org stoneburner Release.gpg Hit ftp.debian.org wheezy-backports Release.gpg Hit ppa.launchpad.net precise Release Ign shell.ninthgate.se squeeze Release Hit packages.openmediavault.org stoneburner Release Hit download.mono-project.com wheezy Release Hit ftp.uk.debian.org wheezy-updates Release.gpg Ign dh2k.omv-extras.org stoneburner-miller Release.gpg Hit security.debian.org wheezy/updates Release Hit packages.omv-extras.org stoneburner-vb Release.gpg Hit ftp.debian.org wheezy-backports Release Hit ppa.launchpad.net precise/main amd64 Packages Hit download.mono-project.com wheezy/main amd64 Packages Hit ftp.uk.debian.org wheezy Release Ign dh2k.omv-extras.org stoneburner-vpn Release.gpg Hit security.debian.org wheezy/updates/main Sources Hit packages.openmediavault.org stoneburner/main amd64 Packages Hit packages.omv-extras.org stoneburner-plex Release.gpg Hit ftp.debian.org wheezy-backports/main amd64 Packages/DiffIndex Hit ftp.uk.debian.org wheezy-updates Release Hit security.debian.org wheezy/updates/contrib Sources Hit packages.omv-extras.org stoneburner-mono Release.gpg Hit dh2k.omv-extras.org virtualbox-wheezy-mirror Release Hit ppa.launchpad.net precise/main Translation-en Hit packages.openmediavault.org stoneburner/partner amd64 Packages Hit ftp.uk.debian.org wheezy/main Sources Hit security.debian.org wheezy/updates/non-free Sources Hit dh2k.omv-extras.org plex-wheezy-mirror Release Hit packages.omv-extras.org stoneburner-mono-testing Release.gpg Hit ftp.debian.org wheezy-backports/contrib amd64 Packages/DiffIndex Hit ftp.uk.debian.org wheezy/main amd64 Packages Hit security.debian.org wheezy/updates/main amd64 Packages Hit dh2k.omv-extras.org stoneburner-miller Release Hit packages.omv-extras.org stoneburner-backports Release Hit ftp.debian.org wheezy-backports/non-free amd64 Packages/DiffIndex Ign download.mono-project.com wheezy/main Translation-en Hit ftp.uk.debian.org wheezy/main Translation-en Hit security.debian.org wheezy/updates/contrib amd64 Packages Hit dh2k.omv-extras.org stoneburner-vpn


      Even if I run apt-get update in CLI, I still don't get Sonarr. What am I doing wrong now?
      Please!
      I have donated. have you?
      OMV 2.2 running on HP Gen 8 G1610T server, 16GB RAM + Xeon E3-1220
    • Of course it does not help that the original issue I was contemplating posting was the automatic bridge my system was forming unasked:
      root@omv:~# ifconfig
      eth0 Link encap:Ethernet HWaddr b0:5a:da:87:d5:84
      inet addr:192.168.0.39 Bcast:192.168.0.255 Mask:255.255.255.0
      UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
      RX packets:2082978 errors:0 dropped:0 overruns:0 frame:0
      TX packets:2625 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000
      RX bytes:2060255975 (1.9 GiB) TX bytes:787696 (769.2 KiB)
      Interrupt:16

      lo Link encap:Local Loopback
      inet addr:127.0.0.1 Mask:255.0.0.0
      inet6 addr: ::1/128 Scope:Host
      UP LOOPBACK RUNNING MTU:65536 Metric:1
      RX packets:84329 errors:0 dropped:0 overruns:0 frame:0
      TX packets:84329 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0
      RX bytes:55917585 (53.3 MiB) TX bytes:55917585 (53.3 MiB)

      wlan0 Link encap:Ethernet HWaddr 00:87:40:7f:00:85
      inet addr:192.168.0.39 Bcast:192.168.0.255 Mask:255.255.255.0
      UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
      RX packets:61874 errors:0 dropped:0 overruns:0 frame:0
      TX packets:1756282 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000
      RX bytes:36026113 (34.3 MiB) TX bytes:1564584172 (1.4 GiB)

      How can wlan0 and eth0 have the ip address?
      My router was told to do this:
      OMV - Wireless 00:87:40:7f:00:85 192.168.0.38 Reserved
      OMV-Eth0 b0:5a:da:87:d5:84 192.168.0.39 Reserved
      OMV-eth1 b0:5a:da:87:d5:85 192.168.0.40 Reserved

      So how it is managing to give two interfaces the same ip address I have no idea.
      The router is a Netgear Virgin Broadband router.
      I have donated. have you?
      OMV 2.2 running on HP Gen 8 G1610T server, 16GB RAM + Xeon E3-1220
    • I will mark this thread as solved because I have managed to install Sonarr and it is a better package than Sickbeard.
      Immediately I installed it, it started downloading stuff whilst Sickbeard just sat there for weeks looking pretty but doing nothing.
      I will start another thread with the problem of having the same ip address for wlan0 and eth0
      Cheers
      I have donated. have you?
      OMV 2.2 running on HP Gen 8 G1610T server, 16GB RAM + Xeon E3-1220