Using Ubuntu Server 10.04.4 LTS and sabnzbd 0.7.4RC2.
Did some further testing with a script with some debug output and you were right - the problem is not setting variables, but setting an empty variable:
Code: Select all
#!/bin/bash
name="$1"
category="$3"
size=$6
minsize=50000000
time="$(date +%Y.%m.%d@%H:%M:%S)"
if [ $category = tv ] && [ $size -le $minsize ]; then
accept=0
echo $time REJECTED $name >> /tmp/pre-queue.log
else
accept=1
fi
echo $accept
#debugging
echo name $name > /tmp/bla.log
echo category $category >> /tmp/bla.log
echo size $size >> /tmp/bla.log
echo minsize $minsize >> /tmp/bla.log
echo time $time >> /tmp/bla.log
echo accept $accept >> /tmp/bla.log
exit
Content of bla.log when a 10MB testfile is added to the TV category:
Code: Select all
name 10MB-3.bin
category tv
size 10835744
minsize 50000000
time 2012.10.03@07:49:41
accept 0
Content of bla.log when a 10MB testfile is added to the default (empty) category:
Code: Select all
name 10MB-3.bin
category
size 10835744
minsize 50000000
time 2012.10.03@07:50:18
accept 1
So when run by sabnzbd, the output of the script is as expected in both cases, even with the empty variable. What's unexpected is sabnzbd's behavior - because both times the NZB is
not added to the queue.
Code: Select all
2012-10-03 07:50:17,980::INFO::[newsunpack:1445] Running pre-queue script ['/home/sabnzbd/scripts/pre-queue.sh', '10MB-3.bin', '', '', '', '-100', '10835744', 'alt.binaries.test', '', '', '', '']
2012-10-03 07:50:18,022::INFO::[newsunpack:1465] Pre-Q refuses 10MB-3.bin
When adding the testfile to any other category than default or testing for an empty category variable and setting a pseudo one, sabnzbd behaves as expected.
So you were definitely right. But why is sab behaving this way, even though the script produces the desired output (1 instead of 0)?