Page 1 of 1

Par2 not found when using Sudo command

Posted: October 2nd, 2011, 2:44 pm
by tmiski
I've install sabnzbd+, unrar, and par2 using the optware pkg installer on my WD My Book Live. It all works great as long as I run sabnzbd as root. I tried using sudo to run sabnzb+ under the account usenet (that I created). But sab can't find the Par2 files. I checked my path and permissions and I don't see any issues.

This is how I start and stop sabnzbd+

Code: Select all

#!/bin/sh
NAME="/etc/init.d/sabnzbd"
case "$1" in
start)
  echo "Starting SABnzbd."
  sudo -u usenet /opt/bin/python2.5 /opt/share/SABnzbd/SABnzbd.py -f /opt/share/SABnzbd/sabnzbd.ini -d
;;
stop)
  echo "Shutting down SABnzbd. "
  /usr/bin/wget -q "http://0.0.0.0:8080/sabnzbd/api?mode=shutdown&apikey=KEY_REMOVED"
;;
restart)
    "$NAME" stop
    "$NAME" start
;;
*)
  echo "Usage: $0 {start|stop|restart}"
  exit 1
esac
exit 0

When I su to the usenet account I can find and run par2 just fine. Not sure what the problem is. The par files are not writeable but that should be ok.

Code: Select all

MyBookLive# su usenet

usenet@MyBookLive# echo $PATH
/opt/bin:/opt/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

usenet@MyBookLive# which par2
/opt/bin/par2

usenet@MyBookLive# ls -la /opt/bin/par*
-rwxr-xr-x 1 root root 219068 Nov 30  2010 /opt/bin/par2
lrwxrwxrwx 1 root root      4 Oct  2 11:35 /opt/bin/par2create -> par2
lrwxrwxrwx 1 root root      4 Oct  2 11:35 /opt/bin/par2repair -> par2
lrwxrwxrwx 1 root root      4 Oct  2 11:35 /opt/bin/par2verify -> par2

usenet@MyBookLive# ls -la /opt/lib/libpar*
lrwxrwxrwx 1 root root     16 Oct  2 11:30 /opt/lib/libpar2.so -> libpar2.so.0.0.1
lrwxrwxrwx 1 root root     16 Oct  2 11:30 /opt/lib/libpar2.so.0 -> libpar2.so.0.0.1
-rwxr-xr-x 1 root root 293328 Nov 30  2010 /opt/lib/libpar2.so.0.0.1

Re: Par2 not found when using Sudo command

Posted: October 2nd, 2011, 4:18 pm
by sander
So ... what is the problem related to SABnzbd?

Re: Par2 not found when using Sudo command

Posted: October 2nd, 2011, 5:51 pm
by tmiski
When the download is complete it fails. I believe it's related to not being able to find par2. That's the only difference that I've found so far.

Re: Par2 not found when using Sudo command

Posted: October 3rd, 2011, 9:18 am
by jcfp
tmiski wrote:usenet@MyBookLive# echo $PATH
/opt/bin:/opt/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

usenet@MyBookLive# which par2
/opt/bin/par2
You are blindly assuming the same PATH (with all that /opt and /usr/local stuff) gets set when running init scripts, which is highly unlikely.

Re: Par2 not found when using Sudo command

Posted: October 3rd, 2011, 12:22 pm
by tmiski
You're right about that. I was hoping someone could show me the light on how/where to set the path.