I'm trying to write a file to start and stop a python script. Here's what I've written.
Problem is when I try to run this I get.
Mainly I'm confused about the run_rc_command. This is su-ing to the user, and running a command. For some reason that command is the sh shell and passing the location of my script. It's odd that there is no call to python in there, though I set the command_interpreter variable. I would have thought it would attempt to call the script as a python script, rather than a sh script?.
Of course the file exists and I've chmod+x it.
Anyone have some pointers?
Code:
#!/bin/sh
#
# PROVIDE: sabnzbd
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# sabnzbd_enable (bool): Set to NO by default.
# Set it to YES to enable it.
# sabnzbd_user: The user account sabnzbd daemon runs as what
# you want it to be. It uses '_sabnzbd' user by
# default. Do not sets it as empty or it will run
# as root.
# sabnzbd_dir: Directory where sabnzbd lives.
# Default: /usr/local/sabnzbd
# sabnzbd_pid: The name of the pidfile to create.
# Default is sabnzbd.pid in /var/run/sabnzbd/.
. /etc/rc.subr
name="sabnzbd"
rcvar=${name}_enable
load_rc_config ${name}
: ${sabnzbd_enable:="NO"}
: ${sabnzbd_user:="_sabnzbd"}
: ${sabnzbd_dir:="/usr/local/sabnzbd"}
: ${sabnzbd_pid:="/var/run/sabnzbd/sabnzbd.pid"}
: ${sabnzbd_conf_dir="${sabnzbd_dir}"}
command=${sabnzbd_dir}/SABnzbd.py
command_interpreter="/usr/bin/python"
command_args="-d -f ${sabnzbd_conf_dir}/sabnzbd.ini"
pidfile=${sabnzbd_pid}
run_rc_command "$1"
Problem is when I try to run this I get.
Code:
./sabnzbd.freenas: DEBUG: pid file (/var/run/sabnzbd/sabnzbd.pid): not readable.
./sabnzbd.freenas: DEBUG: checkyesno: sabnzbd_enable is set to YES.
Starting sabnzbd.
./sabnzbd.freenas: DEBUG: run_rc_command: doit: su -m sabnzbd -c 'sh -c "/mnt/Television/Applications/SABnzbd-0.6.10/SABnzbd.py -d -f /mnt/Television/Applications/sabconfig/sabnzbd.ini"'
/mnt/Television/Applications/SABnzbd-0.6.10/SABnzbd.py: not found
./sabnzbd.freenas: WARNING: failed to start sabnzbd
Mainly I'm confused about the run_rc_command. This is su-ing to the user, and running a command. For some reason that command is the sh shell and passing the location of my script. It's odd that there is no call to python in there, though I set the command_interpreter variable. I would have thought it would attempt to call the script as a python script, rather than a sh script?.
Of course the file exists and I've chmod+x it.
Code:
ll /mnt/Television/Applications/SABnzbd-0.6.10/SABnzbd.py
-rwxr-xr-x 1 sabnzbd sabnzbd 60254 Oct 17 18:37 /mnt/Television/Applications/SABnzbd-0.6.10/SABnzbd.py*
Anyone have some pointers?