glftpd - post processing "site rescan"

Come up with a useful post-processing script? Share it here!
Post Reply
markiejw
Newbie
Newbie
Posts: 5
Joined: March 10th, 2010, 9:23 pm

glftpd - post processing "site rescan"

Post by markiejw »

Hello...

I've been browsing these forums for a long time now and usually have found what I needed but this time I am lost...

I am hoping to put together a post processing script that will automatically run the "site rescan" on the release after its completed assuming it has an sfv in the dir.

If I missed it in another thread I apologize, and if anyone can help me... Thank you!
Mills
Newbie
Newbie
Posts: 11
Joined: August 19th, 2009, 7:02 pm

Re: glftpd - post processing "site rescan"

Post by Mills »

Just pseudo-code off the top of my head but:

#!/bin/bash

cd $1
for sfv in *.sfv; do
  if [-f $sfv ]; then
    /path/to/site/rescan/binary (whatever params it takes)
  fi
done
--

Hopefully that helps -- I'm no bash guru. It will run twice if there are two sfvs though, so you probably want to incorporate something that'll make subdirs and move stuff accordingly. I use the lftp mirror functionality to just upload the files locally via FTP and let the zipscript do its thing. Much cleaner that way :).
markiejw
Newbie
Newbie
Posts: 5
Joined: March 10th, 2010, 9:23 pm

Re: glftpd - post processing "site rescan"

Post by markiejw »

Thanks for the reply Mills. I am getting it to work, just have a couple problems with the variables, but I'll figure it out.

Thanks again though.

How does the lftp work? Is there a post-processing script for it?
Last edited by markiejw on March 11th, 2010, 3:12 pm, edited 1 time in total.
markiejw
Newbie
Newbie
Posts: 5
Joined: March 10th, 2010, 9:23 pm

Re: glftpd - post processing "site rescan"

Post by markiejw »

Okay so I was having problems so I broke it down...

When I run this, everything is good...

#!/bin/bash
cd /
./glftpd/bin/rescan --chroot=/glftpd --dir=/glftpd/site/XVID/The.Release.Dir/ --normal

That will work as the post-processing script, of course only for that release.

I've tried to bring in the variables but I just can't figure it out...

#!/bin/bash
./glftpd/bin/rescan --chroot=/glftpd --dir=\"$1\" --normal

I've tried $1, ($1), $3, ($3), \"$3\", and I can't get it to go.

I think a problem might be because of the chroot. When I pull the $1 I get, /glftpd/site/XVID/The.Release/, which isn't good because the chroot=/glftpd has to be included. The rescan will not execute without the chroot. so it ends up being,  chroot=/glfptd dir=/glftpd/site...., but I need it to be chroot=/glftpd dir=/site/... but using the variable.
Mills
Newbie
Newbie
Posts: 11
Joined: August 19th, 2009, 7:02 pm

Re: glftpd - post processing "site rescan"

Post by Mills »

you can cut characters off of the beginning or end with 'cut' -- $dir = `echo $1 | cut --characters 6` or something similar.

lftp will upload the directory as though a FTP user were doing so, thus bypassing the need to run rescan manually. Check the man page.
markiejw
Newbie
Newbie
Posts: 5
Joined: March 10th, 2010, 9:23 pm

Re: glftpd - post processing "site rescan"

Post by markiejw »

okay so I got everything working, except the variables...

Code: Select all

#!/bin/bash
lftp -e "cd $1 ; site rescan --normal ; exit" -u user,pass localhost -p 21
and I tried this...

Code: Select all

#!/bin/bash
cd $1
lftp -e "site rescan --normal ; exit" -u user,pass localhost -p 21
The $1 isn't working... so I'm not sure how I should put that in there... if I put the actual path it works perfect.
Last edited by markiejw on March 11th, 2010, 11:42 pm, edited 1 time in total.
Mills
Newbie
Newbie
Posts: 11
Joined: August 19th, 2009, 7:02 pm

Re: glftpd - post processing "site rescan"

Post by Mills »

Ah I wasn't even thinking of using it to execute the ftp command, I use mirror to connect and upload (from hdd to hdd). But your way should work. $1 will have the full file path, you need the ftp path which will be without /glftpd/site, so $dir = `echo $1 | cut --characters 13-` ? Something like that, no *nix system to test on at the moment.
markiejw
Newbie
Newbie
Posts: 5
Joined: March 10th, 2010, 9:23 pm

Re: glftpd - post processing "site rescan"

Post by markiejw »

Mills wrote: Ah I wasn't even thinking of using it to execute the ftp command, I use mirror to connect and upload (from hdd to hdd). But your way should work. $1 will have the full file path, you need the ftp path which will be without /glftpd/site, so $dir = `echo $1 | cut --characters 13-` ? Something like that, no *nix system to test on at the moment.
hrmmm... Can't seem to get the cut to work. I found the man for it and it goes... cut -c1-c12, which would cut character 1 through 12. I think the quotes are messing something up...

I tried...

Code: Select all

#!/bin/bash
cd "$1" | cut -c1-12
lftp -e "site rescan --normal ; exit" -u user,pass localhost -p 21
and also tried...

Code: Select all

#!/bin/bash
lftp -e "cd '$1 | cut -c1-12 | site rescan --normal ; exit" -u user,pass localhost -p 21
I think the problem is using the cut in the variable. In the top example it seems to not pull the cut, and in the bottom one I think it's having problems because the cd cut is inside the " " which is messing up the variable.
Mills
Newbie
Newbie
Posts: 11
Joined: August 19th, 2009, 7:02 pm

Re: glftpd - post processing "site rescan"

Post by Mills »

Like I said, set a new variable first and use that: dir=`echo $1 | cut --characters 13-` then use $dir
Last edited by Mills on March 12th, 2010, 6:03 pm, edited 1 time in total.
Post Reply