Add shell script to startup in CentOS

Shockey

2[H]4U
Joined
Nov 24, 2008
Messages
2,204
Hello everyone

I'm trying to get SabNZB to run at startup.



Added it to /etc/init.d/ folder location.

able to use 'service SABNzB to start and stop SabNZB.


Permissions are as follow
-rwxr-xr-x. 1 root root 495 Jan 18 17:22 /etc/init.d/SABNzB

Run level configuration.
chkconfig --list SABNzB
SABNzB 0:eek:ff 1:eek:ff 2:eek:ff 3:eek:n 4:eek:ff 5:eek:n 6:eek:ff

Script being called

#!/bin/sh
#chkconfig: 2345 99 10
#description: NZB download service


case "$1" in
start)
echo "Starting SABnzbd."
/usr/bin/sudo -u scriptexe -H /usr/local/SABnzbd-0.5.0/SABnzbd.py -d -f /home/scriptexe/.sabnzbd/sabnzbd.ini
;;
stop)
echo "Shutting down SABnzbd."
/usr/bin/wget -q --delete-after "http://192.168.10.70:8080/sabnzbd/api?mode=shutdown&ma_username=USER&ma_password=PASSWORD&apikey=SUPER SECRET API KEY"
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
esac

exit 0

I've looked around and it appears everything should be working correctly with this setup but it does not start up.

Anyone have any ideas as to what i need to change to get it to run at start up?
 
Joined
Sep 16, 2002
Messages
634
Whats the system's default run level at bootup (check /etc/inittab)?

Your script will only startup if run level is 3, which is the default IIRC, but its good to check.
 

TCM

Gawd
Joined
Nov 10, 2011
Messages
641
/usr/bin/sudo -u scriptexe -H /usr/local/SABnzbd-0.5.0/SABnzbd.py -d -f /home/scriptexe/.sabnzbd/sabnzbd.ini

Does this line work when you manually run it?
 

Shockey

2[H]4U
Joined
Nov 24, 2008
Messages
2,204
/usr/bin/sudo -u scriptexe -H /usr/local/SABnzbd-0.5.0/SABnzbd.py -d -f /home/scriptexe/.sabnzbd/sabnzbd.ini

Does this line work when you manually run it?

Yup.

Welcome to CentOS
Starting udev: [ OK ]
Setting hostname Web_Server.noobcorp.loc: [ OK ]
Setting up Logical Volume Management: 2 logical volume(s) in volume group "vg_webserver" now active
[ OK ]
Checking filesystems
_CentOS-6.3-x86_: clean, 175102/2978400 files, 1599598/11945984 blocks
/dev/sda1: clean, 48/128016 files, 81289/512000 blocks
[ OK ]
Remounting root filesystem in read-write mode: [ OK ]
Mounting local filesystems: [ OK ]
Enabling local filesystem quotas: [ OK ]
Enabling /etc/fstab swaps: [ OK ]
Entering non-interactive startup
Calling the system activity data collector (sadc):
Starting monitoring for VG vg_webserver: 2 logical volume(s) in volume group "vg_webserver" monitored
[ OK ]
iptables: Applying firewall rules: [ OK ]
iptables: Loading additional modules: nf_conntrack_netbios_[ OK ]
Starting auditd: [ OK ]
Starting portreserve: [ OK ]
Starting system logger: [ OK ]
Starting irqbalance: [ OK ]
Starting rpcbind: [ OK ]
Starting kdump: [ OK ]
Starting lldpad: [ OK ]
Starting FCoE initiator service: [ OK ]

Starting system message bus: [ OK ]
Setting network parameters... [ OK ]
Starting NetworkManager daemon: [ OK ]
Starting Avahi daemon... [ OK ]
Starting NFS statd: [ OK ]
Initializing OpenCT smart card terminals: [ OK ]

Starting RPC idmapd: [ OK ]
Starting cups: [ OK ]
Mounting other filesystems: [ OK ]
Starting acpi daemon: [ OK ]
Starting HAL daemon: [ OK ]
Retrigger failed udev events [ OK ]
Starting PC/SC smart card daemon (pcscd): [ OK ]
Loading autofs4: [ OK ]
Starting automount: [ OK ]
Starting sshd: [ OK ]
Starting mysqld: [ OK ]
Starting abrt daemon: [ OK ]
Starting httpd: [ OK ]
Starting crond: [ OK ]
Starting atd: [ OK ]
Starting certmonger: [ OK ]
Starting SABnzbd.
sudo: sorry, you must have a tty to run sudo

last line seem fishy. what tty referring too?
 

devman

2[H]4U
Joined
Dec 3, 2005
Messages
2,400
Yup.



last line seem fishy. what tty referring too?

That is your problem. You can't use sudo from an non-interactive shell, and you don't need it anyway because you are already root. Use su instead.
 
Top