postprocess - NCFtp.sh

Share your scripts or request scripts with specific features.
Forum rules
Please keep the forum clean - one topic per script. Questions not related to a specific script should be posted in Support forum.
picardtux
Posts: 71
Joined: 05 Sep 2012, 12:45
Contact:

postprocess - NCFtp.sh

Post by picardtux » 31 Jan 2013, 10:37

hello,

I operate on a low-power NZBGet NSA325 She has indeed enough power for a time to a cause, but also enough
with appropriate settings
NZBGet stop list after the DL DL
verifies and unpacks the download well.

that's very good, but in my case I have now download the collection on my DL NAS.

here comes back to postprocess to use FTP to move on to NSA325 to NSA310 and when successful to delete on the source NSA COLLECTION directory.

Requirement is ncftp

I have solved it...
nzbget-postprocess.conf

Code: Select all

##############################################################################
### FTP                                                                    ###
# FTP copy from NZBGet to target (yes, no).
# NOTE: REQUIRED ncftp
FTP=yes

# Set here the full path for your FTP Server.
FTPDir=/admin/download/fertig/

# Put your FTP Server or ip here.
FTPServer=nsa310

# Put your FTP Username here.
FTPUser=

# Put your FTP password here.
FTPPass=

# Set it to delete the collection (yes, no).
# NOTE: Deletes all files after successful copy with FTP
FTPRM=no
nzbget-postprocess.sh
insert before :!:

Code: Select all

# All OK, requesting cleaning up of download queue

Code: Select all

############################
### BEGIN CUSTOMIZATIONS ###
############################

# FTP copy from NZBGet to target
#
if [ "$FTP" = "yes" ]; then
        echo "[INFO] Post-Process: FTP transfer will start to $FTPServer...!"
        if (ncftpput -d /tmp/ncftpput.log -m -DD -R -u $FTPUser -p $FTPPass $FTPServer $FTPDir $NZBPP_DIRECTORY); then
        echo "[INFO] Post-Process: FTP transfer from $NZBPP_DIRECTORY to $FTPServer successful."
        fi
        if [ "$FTPRM" = "yes" ]; then
                if (rm -rf $NZBPP_DIRECTORY); then
                echo "[INFO] Post-Process: Collection $NZBPP_DIRECTORY have been deleted."
                fi
        fi
fi

##########################
### END CUSTOMIZATIONS ###
##########################
locally, I use no TLS :!:


for troubleshooting created

Code: Select all

/tmp/ncftpput.log 
Last edited by picardtux on 10 May 2013, 07:03, edited 4 times in total.

hugbug
Developer & Admin
Posts: 7514
Joined: 09 Sep 2008, 11:58
Location: Germany

Re: postprocess - ftp

Post by hugbug » 31 Jan 2013, 10:42

Thanks for sharing.

How about translating this to English? ;)

picardtux
Posts: 71
Joined: 05 Sep 2012, 12:45
Contact:

Re: postprocess - ftp

Post by picardtux » 31 Jan 2013, 10:47

Mein englisch ist *hust* schlecht.
Ich kann es nur duch einen Translater jagen :oops:

hugbug
Developer & Admin
Posts: 7514
Joined: 09 Sep 2008, 11:58
Location: Germany

Re: [GERMAN] postprocess - ftp

Post by hugbug » 31 Jan 2013, 11:04

OK, I've added [GERMAN]-prefix to the topic.

picardtux
Posts: 71
Joined: 05 Sep 2012, 12:45
Contact:

Re: postprocess - ftp

Post by picardtux » 13 Feb 2013, 07:56

Now in English ... with a translator. :oops:

lovegiver
Posts: 1
Joined: 07 Apr 2013, 21:32

Re: postprocess - ftp

Post by lovegiver » 07 Apr 2013, 21:40

Hi all,

I have just installed NZBGet on RasPi. It seems to work fine.

I tried many times to set my NAS Server as the {MAINDIR}~/download directory but NZB never wanted to work with such settings.

I wanted to know if this topic's purpose is to show a working workaround to move files on a NAS Server once the are completely downloaded ? Is FTP the only way ?

Thanx

picardtux
Posts: 71
Joined: 05 Sep 2012, 12:45
Contact:

Re: postprocess - ftp

Post by picardtux » 22 Apr 2013, 18:30

new post-processing scripts concept

Ftp.sh

Code: Select all

#!/usr/bin/sh
#
# Ftp post-processing script for NZBGet
#
# Copyright (C) 2008-2013 picard <picardhp@gmx.ch>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, US$
#
#


##############################################################################
### NZBGET POST-PROCESSING SCRIPT                                          ###

# FTP copy from NZBGet to Target.
# NOTE: This script requires NCFTP to be installed on your system.

##############################################################################
### OPTIONS                                                                ###

# Set here the full path for your FTP Server.
FTPDir=/admin/download/fertig/

# Put your FTP Server or ip here.
FTPServer=nsa310

# Put your FTP Username here.
FTPUser=myuser

# Put your FTP password here.
FTPPass=mypass

# Set it to delete the collection after copy (yes, no).
FTPRM=yes

### NZBGET POST-PROCESSING SCRIPT                                          ###
##############################################################################

# NZBGet passes following arguments to postprocess-programm as environment
# variables:
#  NZBPP_DIRECTORY    - path to destination dir for downloaded files;
#  NZBPP_NZBNAME      - user-friendly name of processed nzb-file as it is displ$
#                       by the program. The file path and extension are removed.
#                       If download was renamed, this parameter reflects the ne$
#  NZBPP_NZBFILENAME  - name of processed nzb-file. It includes file extension $
#                       may include full path;
#  NZBPP_CATEGORY     - category assigned to nzb-file (can be empty string);
#  NZBPP_PARSTATUS    - result of par-check:
#                       0 = not checked: par-check is disabled or nzb-file does
#                           not contain any par-files;
#                       1 = checked and failed to repair;
#                       2 = checked and successfully repaired;
#                       3 = checked and can be repaired but repair is disabled.
#  NZBPP_UNPACKSTATUS - result of unpack:
#                       0 = unpack is disabled or was skipped due to nzb-file
#                           properties or due to errors during par-check;
#                       1 = unpack failed;
#                       2 = unpack successful.


# Exit codes
POSTPROCESS_PARCHECK=92
POSTPROCESS_SUCCESS=93
POSTPROCESS_ERROR=94
POSTPROCESS_NONE=95

# Check if the script is called from nzbget 11.0 or later
if [ "$NZBOP_SCRIPTDIR" = "" ]; then
        echo "*** NZBGet post-processing script ***"
        echo "This script is supposed to be called from nzbget (11.0 or later)."
        exit $POSTPROCESS_ERROR
fi

echo "[DETAIL] Script successfully started"

cd "$NZBPP_DIRECTORY"

# Check nzbget.conf options
BadConfig=0

# All checks done, now doing the ftp job

echo "[INFO] transfer will start to $FTPServer...!"
        if (ncftpput -d /tmp/ncftpput.log -m -R -u $FTPUser -p $FTPPass $FTPServer $FTPDir $NZBPP_DIRECTORY); then
        echo "[INFO] transfer from $NZBPP_DIRECTORY to $FTPServer successful."
        fi
        if [ "$FTPRM" = "yes" ]; then
                if (rm -rf $NZBPP_DIRECTORY); then
                echo "[INFO] Collection $NZBPP_DIRECTORY have been deleted."
                fi
        fi

echo "[DETAIL] Script successfully end"

# All OK
exit $POSTPROCESS_SUCCESS

divinatum
Posts: 1
Joined: 29 Apr 2013, 23:45

Re: postprocess - Ftp.sh

Post by divinatum » 29 Apr 2013, 23:53

I modified this script to do SCP instead, and added a little extra protection in the delete function to only delete on successful completion.

config

Code: Select all

##############################################################################
### SCP                                                                    ###
# SCP copy from NZBGet to target (yes, no).
SCP=yes

# Set path to remote location.
SCPPath=Downloads/foo/bar/.

# Put your SSH Server or ip here.
SCPHost=nas

# Put your SSH Config File path here.
SCPConfig=/home/me/.ssh/config

# Set it to delete the collection (yes, no).
# NOTE: Deletes all files after successful copy with SCP
SCPRM=yes
postprocess script

Code: Select all

if [ "$SCP" = "yes" ]; then
	echo "[INFO] Post-Process: SCP transfer will start to $SCPHost...!"
	scp -F "$SCPConfig" -r "$NZBPP_DIRECTORY" $SCPHost:$SCPPath
	if [ "$?" -eq "0" ]; then
		echo "[INFO] Post-Process: SCP transfer from $NZBPP_DIRECTORY to $SCPHost successful."
		if [ "$SCPRM" = "yes" ]; then
			if (rm -rf "$NZBPP_DIRECTORY"); then
				echo "[INFO] Post-Process: Collection $NZBPP_DIRECTORY have been deleted."
			fi
		fi
	else
		echo "[ERROR] Post-Process: SCP to $SCPHost failed!"
		exit $POSTPROCESS_ERROR
	fi
fi
You'll also probably want to make a ssh key with no passphrase, and use a ssh config file to access the key.

Code: Select all

Host nas
  HostName 10.0.0.70
  User me
  IdentityFile /home/me/.ssh/id_rsa

picardtux
Posts: 71
Joined: 05 Sep 2012, 12:45
Contact:

Re: postprocess - NCFtp.sh

Post by picardtux » 01 May 2013, 09:12

@ divinatum
added a little extra protection in the delete function to only delete on successful completion
thx :P
Last edited by picardtux on 10 May 2013, 07:02, edited 1 time in total.

picardtux
Posts: 71
Joined: 05 Sep 2012, 12:45
Contact:

Re: postprocess - Ftp.sh

Post by picardtux » 10 May 2013, 07:01

next post...
Last edited by picardtux on 10 May 2013, 20:06, edited 1 time in total.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests