sim_tcr
Posts: 331
Joined: Tue Nov 06, 2012 1:01 pm
Location: Bangalore
Contact: Website

[SOLVED] custom rc script not being called while shutdown.

Sun Oct 25, 2015 11:31 am

Hello,

I am trying to make an rc script to shutdown our app (splunk) while system is rebooting. Below is the content of my rc script at /etc/init.d/rcsplunk

Code: Select all

#!/bin/sh
#
# /etc/init.d/rcsplunk
# Subsystem file for "Splunk" server
#
# chkconfig: 23456 95 05
# description: Splunk server daemon
#
# processname: Splunk
# config: /etc/MySystem/mySystem.conf
# config: /etc/sysconfig/mySystem
# pidfile: /var/run/MySystem.pid

# source function library
. /etc/rc.d/init.d/functions


start() {
/apps/splunk/bin/splunk start
}

stop() {
/apps/splunk/bin/splunk stop
}

restart() {
/apps/splunk/bin/splunk restart
}

status() {
/apps/splunk/bin/splunk status
}

case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        restart)
                stop
                start
                ;;
        reload)
                reload
                ;;
        condrestart)
                if [ -f /var/lock/subsys/$prog ] ; then
                        stop
                        # avoid race
                        sleep 3
                        start
                fi
                ;;
        status)
                status $prog
                RETVAL=$?
                ;;
        *)
                echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}"
                RETVAL=1
esac
exit $RETVAL

I ran sudo chkconfig --add rcsplunk and sudo chkconfig rcsplunk on and below is the out put of chkconfig --list | grep rcsplunk

Code: Select all

rcsplunk        0:off   1:off   2:on    3:on    4:on    5:on    6:on
Now my app splunk is not being shutdown when I run sudo reboot or sudo init 6 any help is appreciated.

Note: I noticed that app is being started when system come back up. Which i don't want to.
Last edited by sim_tcr on Mon Oct 26, 2015 4:03 pm, edited 1 time in total.
http://raspisimon.no-ip.org
Raspberry Pi Model B x 2, Raspberry Pi 2 x 2, Transcend 32GB Class 10, Transcend 16GB Class 10, Transcend 8GB Class 4, Custom 12V 1.5A (stepped down to 5.5V)

sim_tcr
Posts: 331
Joined: Tue Nov 06, 2012 1:01 pm
Location: Bangalore
Contact: Website

[SOLVED] Re: custom rc script not being called while shutdow

Mon Oct 26, 2015 4:02 pm

stop singal will get initiated only if there is a file in /var/lock/subsys/<rcscriptname>
So i put a touch stalemate as part of start section.

Code: Select all

start() {
/apps/splunk/bin/splunk start
touch /var/lock/subsys/rcsplunk
}
and everything worked as expected.
http://raspisimon.no-ip.org
Raspberry Pi Model B x 2, Raspberry Pi 2 x 2, Transcend 32GB Class 10, Transcend 16GB Class 10, Transcend 8GB Class 4, Custom 12V 1.5A (stepped down to 5.5V)

Return to “General discussion”