2

I have centos 6.4 machine. I created my own script using /etc/init.d/ . Below is the snippet which I took from the net and tried it. The problem now I notice which loading my os when this is loaded it start to work and it can't move to load all the whole os any more. What can I do as I can't access the system now.

#!/bin/bash
# chkconfig: 2345 95 05
# myapp daemon
# description: myapp daemon
# processname: myapp

DAEMON_PATH="/usr/local/bin/"
DAEMON=myap1.c
#DAEMONOPTS="-my opts"
NAME=myap1.c
DESC="my packet capture"

PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

case "$1" in
start)
    printf "%-50s" "Starting $NAME..."
    insmod /usr/local/pfring/kernel/pf_ring.ko
    /usr/local/bin/myap1.c
    #cd $DAEMON_PATH
    #PID=`$DAEMON > /dev/null 2>&1 & echo $!`
    #echo "Saving PID" $PID " to " $PIDFILE
    #    if [ -z $PID ]; then
    #        printf "%s\n" "Fail"
    #    else
    #        echo $PID > $PIDFILE
    #        printf "%s\n" "Ok"
    #    fi
;;
status)
        printf "%-50s" "Checking $NAME..."
        if [ -f $PIDFILE ]; then
            PID=`cat $PIDFILE`
            if [ -z "`ps axf | grep ${PID} | grep -v grep`" ]; then
                printf "%s\n" "Process dead but pidfile exists"
            else
                echo "Running"
            fi
        else
            printf "%s\n" "Service not running"
        fi
;;
stop)
        printf "%-50s" "Stopping $NAME"
            PID=`cat $PIDFILE`
            cd $DAEMON_PATH
        if [ -f $PIDFILE ]; then
            kill -HUP $PID
            printf "%s\n" "Ok"
            rm -f $PIDFILE
        else
            printf "%s\n" "pidfile not found"
        fi
;;
restart)
    $0 stop
    $0 start 
;;
*)
        echo "Usage: $0 {status|start|stop|restart}"
        exit 1
esac

1 Answer 1

2

According to this line

# chkconfig: 2345 95 05

in your script, you should be able to boot the system into single user mode and then to disable automatic startup of the script (script is enabled in runlevels 2345 by default).

How to boot it in single user mode?

  1. At the GRUB splash screen at boot time, press any key to enter the GRUB interactive menu.
  2. Select "Red Hat Enterprise Linux" with the version of the kernel that you wish to boot and type a to append the line.
  3. Go to the end of the line and type single as a separate word (press the Spacebar and then type single). Press Enter to exit edit mode.
3
  • @dsumky ok I dont get you here you mean to select the version and also type? Is it type a or press a will do ?
    – biz14
    Commented Aug 14, 2013 at 10:09
  • yep, agree, it's a bit misleading, better said, press "a" as "append" to switch to edit/append mode
    – dsmsk80
    Commented Aug 14, 2013 at 11:58
  • @dsumky thank you it works but I got problem why does suddenly my script is causing problem any idea how to diagnose this ?
    – biz14
    Commented Aug 15, 2013 at 9:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .