Centralising unraid for xbmc/kodi and seedboxs


Recommended Posts

Hey guys just upgraded to new unraid v6 and just getting my head around docker>plugins and i think i finished ironing out some creases with Sabnzbd, Sonar and Couchpotato

Last thing to do is find best way to centralise my xmbc which i have yet to upgrade to kodi. I wanted to do it on v5 but couldn't get my head around it so now need to know how everyone else doing it with introduction of dockers.

 

Also I see a lot of torrent integration  I'm just wondering is there away to make it work with seed boxes as they are not on unraid there program or work around to download and pull through seed box instead unraid?

Link to comment

Sounds like you are on your way... The main purpose of centralizing Kodi is if you have more than one htpc in your home. If you do, then centralization only requires you to update one library, and all your htpcs will be synchronized. If you start watching a movie on one, you can pick up where you left off on another.

 

To make this happen, Google "Kodi Centralized Database" and you will find guides on their wiki. You need to install the MariaDB docker and this is your MySQL server.

 

Good luck.

Link to comment

Seedboxes are servers you rent for the purpose of torrents. If you want to torrent in your unRAID, you will need to use the Deluge, Transmission, or rTorrent dockers... But this has nothing to do with centralizing Kodi.

 

Also torrenting is an alternative method of media acquisition than the Sab/NZB route. You can do both, but for getting 'current' stuff, it is easier IMHO to go the NZB route. For older past-released stuff, torrents are better.... But I think this discussion may be heading in a direction that is not unRAID related.

Link to comment

I know what torrenting is just wondering if there was away to integrate seedbox with unraid. I was wondering there away to use deluge/transmisson/rtorrent to download on to seedbox then pull it back onto unraid? Thing is probably easier getting harder to find and anime through torrents then nzb

 

I manage to setup database with emby after googling now just need to get latest kodi and plugin should be all nice

Link to comment

I've got no experience with seedboxes, but would rsync be the way forward here or even FTP to connect and sync content between your seedbox & Unraid box?

 

Hi N.

 

After a quick test in websync - which is as far as my rsync experience goes-- showed me that I could not connect to a seedbox I joined with SFTP... I can only connect to it using FTP (Filezilla). I did not see an FTP option in Websync... Reality is that I have not used the seedbox in a VERY long time nor have I used it in any type of workflow. When torrenting, I use rTorrent docker, which I guess its not a great thing if my ISP gets nosy.

Link to comment

I highly modified a script from torrent-invites for using LFTP and a seedboxes.cc account for my torrent downloads.  You'll need LFTP installed on your base unraid install, as well as sshfs-fuse.  The original script as supplied would just mirror folders in a specific destination directory on the seedbox with LFTP, but wouldn't download single files (IE:  A download without a parent directory), didn't do sftp, and also wasn't multi-segemented.  Subsequent releases on that site added database function, but it was windows-specific so that had to be modified to work with linux/unraid.  I also added the capability of it determining whether a download is a directory (and use mirror), or a file (and use get) so that it will handle either without problems.  After the files are downloaded, I also call a unrarall script that extracts the rar files, and removes the extras (nfo's, samples, and the parent rars), and leaves the files in such a way that Sonarr and couchpotato can work with them.

 

The Script:

 

#!/bin/sh
login="username"
pass="password"
host="server.hostname"
sshfshome="/path/to/home/for/sshfs"
sshfsmnt="/path/to/local/seedbox/mount"
sqldir="/folder/for/sqlitedb/" # would suggest you put the script and the sqlite file in the same folder for simplicity, but this allows you to separate the files
sql="dir.db" #name of the sqlite file
table="rememberedFiles"  #name of the sqlite table
field="filename" # name of the sqlite field
for i in 1 2 3 # Each of these are for a specific folder on my seedbox, which I use for specific folders determined by the torrent Labels set up in Deluge.  If you need more, add the numbers here, and copy one of the sections below, making changes are you need.
do
if [ $i -eq 1 ]
    then
        remote_dir="/example/torrents/finished/Downloads/Comics/"   # this is the absolute path on my seedbox's ftp client
        remotedir="/mnt/seedboxe/Comics/"                       # this is the local path where I have the seedbox mounted with sshfs below, required for database to work correctly
        local_dir="/mnt/user/Downloads/Deluge/Downloads/Comics/"    # this is the local path where I actually download my files to
        
    elif [ $i -eq 2 ]
    then
        remote_dir="/example/torrents/finished/Downloads/Movies/"
        remotedir="/mnt/seedbox/Movies/"
        local_dir="/mnt/user/Downloads/Deluge/Downloads/Movies/"
     else
        remote_dir="/example/torrents/finished/Downloads/TV/"
        remotedir="/mnt/seedbox/TV/"
        local_dir="/mnt/user/Downloads/Deluge/Downloads/TV/"
fi
if [ -d $remotedir ]
    then tick=$remotedir
    else
        #umount $sshfsmnt
        echo $pass | sshfs $login@$host:$sshfshome $sshfsmnt -o workaround=rename -o password_stdin
fi
cd $remotedir
Progs=( * ) # creates an array of your directories
for show in "${Progs[@]%*/}"; do  #creates single variables from the array
    cd $sqldir
    exists=$( sqlite3 $sql "select count(*) from $table where $field=\"${show}\"" )
    if (( exists > 0 )); then  # these two lines test if your directory is already in the sqlite database
    tick=$show
    #        echo "Show already downloaded $show"
    else
        trap "rm -f /tmp/synctorrent.lock" SIGINT SIGTERM
    if [ -e /tmp/synctorrent.lock ]
    then
        echo "Already Running"
        exit
    else
        touch /tmp/synctorrent.lock
        if [ -d "$remotedir/${show}" ]  # I needed 2 seperate lftp lines, one for mirroring full directories, and one to handle single files since some uploaders don't use directories
        then
           echo "$remote_dir/${show}/ is directory"  # This is there for debugging the testing to see if it's determining if you are downloading a file or mirroring a directory, can be safely commented out
lftp -p 22 -u $login,$pass sftp://$host << EOF  #this is an SFTP script - hopefully secure
set mirror:use-pget-n 7
mirror -c -P5 --log=/var/log/synctorrentssl.log "$remote_dir/${show}/" "$local_dir/${show}/"
quit
EOF
        else
            echo "$remote_dir/${show} is file"   # For Debugging, can be commented out as well
lftp -p 22 -u $login,$pass sftp://$host << EOF  #this is an SFTP script - hopefully secure
get "$remote_dir/${show}" -o "$local_dir/${show}"
quit
EOF
        fi
    fi
sqlite3 $sql "insert into rememberedFiles (filename) values ('${show}');"  # once the script completes, the variable is added to the database, ensuring that you can't download it again using the script
rm -f /tmp/synctorrent.lock
trap - SIGINT SIGTERM
fi
done
done
umount $sshfsmnt
#Below this line I've added the unrarall script to test md5's (if available), extract, and clean up the samples, nfo's, etc.
/boot/custom/unrarall --clean=all /mnt/user/Downloads/Deluge/Downloads/TV
/boot/custom/unrarall --clean=all /mnt/user/Downloads/Deluge/Downloads/Movies
exit 0

 

My notes from the thread on the other site:

 

I've heavily modded this script to work my my seedbox host (seedboxes.cc). I use Deluge as my downloader, and have labels set up to automatically sort my downloads into folders for whatever type downloads they are (Movies, Music, TV, Porn, etc). You need the sshfs client installed to use it on a linux-based system (no clue on windows or mac, I coded this specifically for my unraid linux system).

 

The line that executes the sshfs command MAY need the variables changed to the actual values needed, I had some issues with it on an earlier version. This will mirror any directories in the Label directories, and also pull down any single files if they aren't in directories (the originaly supplied script wouldn't handle single files in the root directories at all). I've also modded it to use sftp in place of regular ftp, and it keeps a database of previously downloaded files, and won't re-download them if they've already been pulled.

 

Hopefully someone can use this, I've tried to comment where I thought it was necessary.

 

This is the unrarall script I'm running: https://github.com/arfoll/unrarall

 

Original script here: http://www.torrent-invites.com/showt...=1#post2083528 (Thanks to the original author)

You'll need to use his directions to set the environment up, but the above script code to get it to function. I'd still like to add some errorlevel checking on the actual lftp downloads, as this script accepts the download even if it cancelled out, and won't re-download it due to it being in the sqlite database. If I ever get around to doing that, I'll make the changes above..

 

Aside from the script above, you'll need cksfv, p7zip, unrar, lftp and sshfs-fuse.

 

These are the versions (and links) to the packages I used.  This is all done on the base unraid install, not in a docker.  I placed all these files in the addons directory that unraid installs automatically on boot.

 

cksfv  (http://slackonly.com/pub/packages/14.1-x86_64/misc/cksfv/cksfv-1.3.14-x86_64-1_slack.txz)

p7zip  (http://taper.alienbase.nl/mirrors/people/alien/slackbuilds/p7zip/pkg64/13.37/p7zip-9.20.1-x86_64-1alien.tgz)

unrar  (http://taper.alienbase.nl/mirrors/people/alien/slackbuilds/unrar/pkg64/14.0/unrar-4.2.4-x86_64-1alien.tgz)

lftp    (http://ftp.slackware.com/pub/slackware/slackware64-14.1/slackware64/n/lftp-4.4.9-x86_64-1.txz)

sshfs-fuse (http://taper.alienbase.nl/mirrors/people/alien/slackbuilds/sshfs-fuse/pkg64/14.0/sshfs-fuse-2.5-x86_64-1alien.tgz)

 

Since for torrents I use the blackhole directories in most of my autodownloaders, I also have a script that sends them up hourly (I'm getting ready to make changes to my scheduling to do the watchdir every 5 minutes, and download the resultant torrents every 15-30 minutes), and pulls down the torrents every day at 5am (unless I fire it off manually, which is usually what happens, lol).

 

If you have any questions, feel free to ask, but if it's about another seedbox host other than seedboxes.cc, not sure how much help I can be.  I've gotten excellent speeds with them (I've had some torrents approach 70-80M/s on a download to the box using a gremlin box from them, and rates down to me average around 7.5M/s on my cable internet connection (60Mbps), which can completely saturate my connection. 

 

Watchdir sync script:

 

#!/bin/bash
login="username"
pass="password"
host="hostname"
remote_dir="/remote/torrent/watch/directory/"
local_dir="/local/watchdir/repository/"

trap "rm -f /tmp/syncwatch.lock" SIGINT SIGTERM
if [ -e /tmp/syncwatch.lock ]
then
  echo "Syncwatch is running already."
  exit 1
else
  touch /tmp/syncwatch.lock
  lftp -p 22 -u $login,$pass sftp://$host << EOF
  set mirror:use-pget-n 5
  mirror -R --Remove-source-files --log=/var/log/syncwatch.log $local_dir $remote_dir
  quit
EOF
  rm -f /tmp/syncwatch.lock
  trap - SIGINT SIGTERM
  exit 0
fi

 

I should also mention that I'm using Deluge on the seedboxes account.  I also have my watchdir set up with subfolders under each (tv, movies, tv-sonarr, music, books, comics, etc), and have Deluge set up to search each of those directories seperately for new torrent files, and tag the download with a label for the type of download they are.  I use the Deluge autoadd plugin to create the labels based on the directory the torrent is uploaded into, then use the label's move feature to move the completed files into a specific directory in the finished directory on the seedbox.  You could always have all torrents dumped into one big finished directory, but I'd advise against it, as you'll have sonarr trying to process movies and music, headphones tagging the directory as unprocessed, and other oddities.  If they are segregated into their own directories on the server and downloaded into those folders on your unraid box, each application can be mapped to it's own download folder and you'll be happier with the results.

 

*EDIT*  I just realized you don't necessarily need to add those files to unraid's addon install folder if you're using the Nerdtools plugin, with the exception of the cksfv program, as they are included in that plugin.

 

*2nd EDIT*  Forgot to put the DB initialization info here:

 

sqlite3 dir.db  #creates the database and loads the sqlite prompt
sqlite> create table zero (episode varchar(10)); #don't forget to put a ; at the end of the line or the command will not execute
sqlite3> .quit  #takes you back to the linux prompt

Link to comment

I have my kodi DB and thumbnails cetralizen on unRAID.

 

Whats the problem?

 

i have created the user accounts on mariadb, and set up a share for thumbnails. then edit advancedsettings.xml under userdata folder. Kodi will create the DB at startup

 

heres a sample of the file (im using openelec)

<advancedsettings>

<pathsubstitution>
  <substitute>
    <from>special://masterprofile/Thumbnails/</from>
    <to>smb://192.168.1.XXX/thumbnails</to>
  </substitute>
</pathsubstitution>

<videodatabase>
  <type>mysql</type>
  <host>192.168.1.XXX</host>
  <name>kvideos</name>
  <port>3306</port>
  <user>xbmc</user>
  <pass>xbmc</pass>
</videodatabase>

<musicdatabase>
  <type>mysql</type>
  <host>192.168.1.101</host>
  <name>kmusic</name>
  <port>3306</port>
  <user>xbmc</user>
  <pass>xbmc</pass>
</musicdatabase>

</advancedsettings>

Link to comment

I highly modified a script from torrent-invites for using LFTP and a seedboxes.cc account for my torrent downloads.  You'll need LFTP installed on your base unraid install, as well as sshfs-fuse. 

 

Heffe thank you for sharing this.... it will take me a while to absorb and understand what you are doing but I AM going to try it. I just signed up for PulsedMedia and it is horrible. They disable AutoTools so its basically useless in terms of automating anything with CP, Sonarr, etc.

 

 

Link to comment

I have my kodi DB and thumbnails cetralizen on unRAID.

 

Whats the problem?

 

i have created the user accounts on mariadb, and set up a share for thumbnails. then edit advancedsettings.xml under userdata folder. Kodi will create the DB at startup

 

heres a sample of the file (im using openelec)

<advancedsettings>

<pathsubstitution>
  <substitute>
    <from>special://masterprofile/Thumbnails/</from>
    <to>smb://192.168.1.XXX/thumbnails</to>
  </substitute>
</pathsubstitution>

<videodatabase>
  <type>mysql</type>
  <host>192.168.1.XXX</host>
  <name>kvideos</name>
  <port>3306</port>
  <user>xbmc</user>
  <pass>xbmc</pass>
</videodatabase>

<musicdatabase>
  <type>mysql</type>
  <host>192.168.1.101</host>
  <name>kmusic</name>
  <port>3306</port>
  <user>xbmc</user>
  <pass>xbmc</pass>
</musicdatabase>

</advancedsettings>

 

Why this?

  <name>kvideos</name>

 

Mine says...

<advancedsettings>

  
  <samba>
    <clienttimeout>18</clienttimeout>
  </samba>
  
  <network>
    <disableipv6>true</disableipv6>
  </network>
  
    <videodatabase>
        <type>mysql</type>
        <host>192.168.0.201</host>
         <port>3306</port>     
        <user>kodi</user>
        <pass>kodi</pass>
    </videodatabase> 

    <musicdatabase>
        <type>mysql</type>
        <host>192.168.0.201</host>
        <port>3306</port>       
        <user>kodi</user>
        <pass>kodi</pass>
    </musicdatabase>

<videolibrary>
  <hideallitems>true</hideallitems>
  <recentlyaddeditems>105</recentlyaddeditems>
  <importwatchedstate>true</importwatchedstate>
  <importresumepoint>true</importresumepoint>
  <dateadded>2</dateadded>
</videolibrary>
  
<splash>false</splash>

</advancedsettings>

 

Link to comment

I highly modified a script from torrent-invites for using LFTP and a seedboxes.cc account for my torrent downloads.  You'll need LFTP installed on your base unraid install, as well as sshfs-fuse. 

 

Heffe thank you for sharing this.... it will take me a while to absorb and understand what you are doing but I AM going to try it. I just signed up for PulsedMedia and it is horrible. They disable AutoTools so its basically useless in terms of automating anything with CP, Sonarr, etc.

 

It took me about 4 weeks from when I found the original script, to where I had it working as I needed it to.  There were also others in the thread who gave help with the database and all, I just adapted it to my Unraid box' configuration.

 

Basically, you need to set a point on your Unraid box (most likely cache drive) where you can use the sshfs to mount your seedboxes finished downloaded directory so that the routine in the script can parse it for files/directories, which it then downloads one by one, marking them in the database once finished as downloaded so that it doesn't attempt to redownload.  The original script as supplied would happily download the same stuff over and over when it was executed, IF the original downloaded files on your unraid box had been moved or deleted.  The database addition solved that.  I then had to add some logic in there to determine whether the parsed download is a file, or a directory, as lftp is called with the mirror-type download in the original script, which won't work with single files not in directories.

 

If you need any help trying to figure out my spaghetti code, just ask, lol.

 

Link to comment

 

 

Why this?

  <name>kvideos</name>

 

 

When i went from xbmc to beta kodi, i wanted to use a new db, so its not impprtant.

 

Hi Jowe... I am not sure if you are asking a question or have an issue with your setup. I was simply confused by your line that said.. "what's the problem?" Is the system working for you, or do you need help?  :)

Link to comment

It took me about 4 weeks from when I found the original script, to where I had it working as I needed it to.  There were also others in the thread who gave help with the database and all, I just adapted it to my Unraid box' configuration.

 

Basically, you need to set a point on your Unraid box (most likely cache drive) where you can use the sshfs to mount your seedboxes finished downloaded directory so that the routine in the script can parse it for files/directories, which it then downloads one by one, marking them in the database once finished as downloaded so that it doesn't attempt to redownload.  The original script as supplied would happily download the same stuff over and over when it was executed, IF the original downloaded files on your unraid box had been moved or deleted.  The database addition solved that.  I then had to add some logic in there to determine whether the parsed download is a file, or a directory, as lftp is called with the mirror-type download in the original script, which won't work with single files not in directories.

 

If you need any help trying to figure out my spaghetti code, just ask, lol.

 

Thanks again Heffe... Just out of curiosity... do you use nzbs in your methodology, or do you rely solely on bt?

 

The thing keeping me from embracing torrents w/ Sickrage or CP (with or without a seedbox) is the copying of the files to the folders that SR or CP monitor. I have had instances where these guys post process the files in the monitored folders before they are done copying. When doing NZBs, the files are rar'd, and the unpacking in Sab or NZBGet puts it in an _UNPACKING folder that gets renamed when done. The _UNPACKING folder gets ignored by SR or CP post processing.

 

Thanks again,

 

H.

Link to comment

Subsequent releases on that site added database function, but it was windows-specific so that had to be modified to work with linux/unraid.  I also added the capability of it determining whether a download is a directory (and use mirror), or a file (and use get) so that it will handle either without problems.  After the files are downloaded, I also call a unrarall script that extracts the rar files, and removes the extras (nfo's, samples, and the parent rars), and leaves the files in such a way that Sonarr and couchpotato can work with them.

 

Quick question (hopefully)

 

I see it mentions in the script the use of sqlitedb... What do I need to install to unRAID to make that work? Do I need to create the database table(s)?

 

Thanks,

 

H.

Link to comment

Subsequent releases on that site added database function, but it was windows-specific so that had to be modified to work with linux/unraid.  I also added the capability of it determining whether a download is a directory (and use mirror), or a file (and use get) so that it will handle either without problems.  After the files are downloaded, I also call a unrarall script that extracts the rar files, and removes the extras (nfo's, samples, and the parent rars), and leaves the files in such a way that Sonarr and couchpotato can work with them.

 

Quick question (hopefully)

 

I see it mentions in the script the use of sqlitedb... What do I need to install to unRAID to make that work? Do I need to create the database table(s)?

 

Thanks,

 

H.

 

sqlite is a supertiny sqlserver that has the entire db in a single file, that script will make it self where\when ever it needs it.

 

(Also thanks for your icon suggestions.)

Link to comment

I use both here, whichever Sonarr find the first copy on is where it pulls from.  The script I have set up unrar's the shows in the TV section at the end, and I've not had an issue with Sonarr picking them up before they are finished extracting.  It seems like most stuff I really want fast tends to hit my private BT trackers before they hit usenet (I'm usually watching Walking Dead from BT before it's even up on nzb's).  I just have to fire off the torrent syncing script by hand in those instances, otherwise they only get pulled once a day (for most shows that's fine, but some stuff I want faster).

 

 

Thanks again Heffe... Just out of curiosity... do you use nzbs in your methodology, or do you rely solely on bt?

 

The thing keeping me from embracing torrents w/ Sickrage or CP (with or without a seedbox) is the copying of the files to the folders that SR or CP monitor. I have had instances where these guys post process the files in the monitored folders before they are done copying. When doing NZBs, the files are rar'd, and the unpacking in Sab or NZBGet puts it in an _UNPACKING folder that gets renamed when done. The _UNPACKING folder gets ignored by SR or CP post processing.

 

Thanks again,

 

H.

Link to comment

I believe that sqlite is pre-installed on the system, didn't catch this earlier. 

 

You need to run this code to create and initialize the database:

 

sqlite3 dir.db  #creates the database and loads the sqlite prompt
sqlite> create table zero (episode varchar(10)); #don't forget to put a ; at the end of the line or the command will not execute
sqlite3> .quit  #takes you back to the linux prompt

 

 

 

Subsequent releases on that site added database function, but it was windows-specific so that had to be modified to work with linux/unraid.  I also added the capability of it determining whether a download is a directory (and use mirror), or a file (and use get) so that it will handle either without problems.  After the files are downloaded, I also call a unrarall script that extracts the rar files, and removes the extras (nfo's, samples, and the parent rars), and leaves the files in such a way that Sonarr and couchpotato can work with them.

 

Quick question (hopefully)

 

I see it mentions in the script the use of sqlitedb... What do I need to install to unRAID to make that work? Do I need to create the database table(s)?

 

Thanks,

 

H.

Link to comment
  • 6 months later...

If you're running this script, and upgrade to 6.20, and the latest NerdPack for the required dependencies, your scripts will most likely quit working.  You need to add a set: variable to one of the scripts (I did it in the watchfolder script).  The newer NerdPack contains v4.6.5 of lftp, which apparently either changes how it creates it's key, or creates a new key (not sure which), but you'll get errors and your downloads and uploads will just stop.

 

Change the line that reads:

 

set mirror:use-pget-n 5

 

to read:

 

set mirror:use-pget-n 5 sftp:auto-confirm true

 

And execute it at least once with that added variable, it'll update your new SSL key that lftp is using on the server-side, and allow the scripts to continue to work.  You can either remove it after you've run it once, or leave it in and it'll update the key any time it changes on your end.  If you're running an older version of lftp, that variable doesn't exist, and it'll pop an error, but still download/upload (at least on my system).

Link to comment
  • 1 month later...

If you're running this script, and upgrade to 6.20, and the latest NerdPack for the required dependencies, your scripts will most likely quit working.  You need to add a set: variable to one of the scripts (I did it in the watchfolder script).  The newer NerdPack contains v4.6.5 of lftp, which apparently either changes how it creates it's key, or creates a new key (not sure which), but you'll get errors and your downloads and uploads will just stop.

 

Change the line that reads:

 

set mirror:use-pget-n 5

 

to read:

 

set mirror:use-pget-n 5 sftp:auto-confirm true

 

And execute it at least once with that added variable, it'll update your new SSL key that lftp is using on the server-side, and allow the scripts to continue to work.  You can either remove it after you've run it once, or leave it in and it'll update the key any time it changes on your end.  If you're running an older version of lftp, that variable doesn't exist, and it'll pop an error, but still download/upload (at least on my system).

 

Working on trying to add this myself. Worked through most of the errors and now I am getting this:

 

root@Tower:/boot/config/plugins/syncwatch# synctorrents.sh.new                  
umount: /mnt/user/seedbox/Downloads/: not mounted

 

Here is the full code I am trying to run.

 

#!/bin/sh
login="mylogin"
pass="mypass"
host="myserver"
sshfshome="/mnt/user/seedbox/"
sshfsmnt="/mnt/user/seedbox/Downloads/"
sqldir="/boot/config/plugins/syncwatch/" # would suggest you put the script and the sqlite file in the same folder for simplicity, but this allows you to separate the files
sql="dir.db" #name of the sqlite file
table="rememberedFiles"  #name of the sqlite table
field="filename" # name of the sqlite field
for i in 1 2 3 # Each of these are for a specific folder on my seedbox, which I use for specific folders determined by the torrent Labels set up in Deluge.  If you need more, add the numbers here, and copy one of the sections below, making changes are you need.
do
if [ $i -eq 1 ]
    then
        remote_dir="/Comics/"   # this is the absolute path on my seedbox's ftp client
        remotedir="/mnt/user/seedbox/Downloads/Comics/"                       # this is the local path where I have the seedbox mounted with sshfs below, required for database to work correctly
        local_dir="/mnt/user/Files/Downloads/Comics/"    # this is the local path where I actually download my files to
        
    elif [ $i -eq 2 ]
    then
        remote_dir="/Movies/"
        remotedir="/mnt/user/seedbox/Downloads/Movies/"
        local_dir="/mnt/user/Files/Downloads/Movies/" 
     else
        remote_dir="/TV/"
        remotedir="/mnt/user/seedbox/Downloads/TV/"
        local_dir="/mnt/user/Files/Downloads/TV/" 
fi
if [ -d $remotedir ]
    then tick=$remotedir
    else
        #umount $sshfsmnt
        echo $pass | sshfs $login@$host:$sshfshome $sshfsmnt -o workaround=rename -o password_stdin
fi
cd $remotedir
Progs=( * ) # creates an array of your directories
for show in "${Progs[@]%*/}"; do  #creates single variables from the array
    cd $sqldir
    exists=$( sqlite3 $sql "select count(*) from $table where $field=\"${show}\"" )
    if (( exists > 0 )); then  # these two lines test if your directory is already in the sqlite database
    tick=$show
    #        echo "Show already downloaded $show"
    else
        trap "rm -f /tmp/synctorrent.lock" SIGINT SIGTERM
    if [ -e /tmp/synctorrent.lock ]
    then
        echo "Already Running"
        exit
    else
        touch /tmp/synctorrent.lock
        if [ -d "$remotedir/${show}" ]  # I needed 2 seperate lftp lines, one for mirroring full directories, and one to handle single files since some uploaders don't use directories
        then
           echo "$remote_dir/${show}/ is directory"  # This is there for debugging the testing to see if it's determining if you are downloading a file or mirroring a directory, can be safely commented out
lftp -p 22 -u $login,$pass sftp://$host << EOF  #this is an SFTP script - hopefully secure
set mirror:use-pget-n 5 sftp:auto-confirm true
mirror -c -P5 --log=/var/log/synctorrentssl.log "$remote_dir/${show}/" "$local_dir/${show}/"
quit
EOF
        else
            echo "$remote_dir/${show} is file"   # For Debugging, can be commented out as well
lftp -p 22 -u $login,$pass sftp://$host << EOF  #this is an SFTP script - hopefully secure
get "$remote_dir/${show}" -o "$local_dir/${show}"
quit
EOF
        fi
    fi
sqlite3 $sql "insert into rememberedFiles (filename) values ('${show}');"  # once the script completes, the variable is added to the database, ensuring that you can't download it again using the script
rm -f /tmp/synctorrent.lock
trap - SIGINT SIGTERM
fi
done
done
umount $sshfsmnt
#Below this line I've added the unrarall script to test md5's (if available), extract, and clean up the samples, nfo's, etc.
#/boot/custom/unrarall --clean=all /mnt/user/Downloads/Deluge/Downloads/TV
#/boot/custom/unrarall --clean=all /mnt/user/Downloads/Deluge/Downloads/Movies
exit 0

 

What am I missing? Am I doing something wrong with the sshfshome / mnt locations? I added all the plugins you said were required with Nerdpack.

Link to comment

Do you have the SSHFS module loaded?  That's usually what happens when I don't have it loaded, or for whatever reason my SSHFS isn't connected to the seedbox.  I'm using seedboxes.cc as my host, I know it works with them, not sure about other hosts.

 

You could try to mount the SSHFS connection to the seedbox manually to see if it's connecting correctly.

 

Link to comment

Do you have the SSHFS module loaded?  That's usually what happens when I don't have it loaded, or for whatever reason my SSHFS isn't connected to the seedbox.  I'm using seedboxes.cc as my host, I know it works with them, not sure about other hosts.

 

You could try to mount the SSHFS connection to the seedbox manually to see if it's connecting correctly.

 

Got it working. Was two things it seemed - 1) needed to manually SSH to the seedbox once and accept the cert 2) was getting another error and added -o nonempty at the end of the sshfsmnt line

 

Two questions

 

1) If I run this as a chron job, how do I view what is downloading currently?

2) If a file gets interrupted / I close out the SSH window running the script manually - it stops the download and adds it to the database, so it gets skipped after? How do I keep it running?

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.