1. Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Need Help with Linux Startup Script

Discussion in 'Programming & Webmastering' started by ct5098, Mar 13, 2010.

  1. ct5098 New Member

    Joined:
    Aug 3, 2009
    Messages:
    13 (0.01/day)
    Thanks Received:
    0
    Hi, I'm new to Linux and bash scripting, and I could use a little help in figuring this problem out.
    I have an Ubuntu server that I host a Ventrilo server on. When I start my server, I would like for the Ventrilo server to start automatically. I have a user, ventrilo, which runs the Ventrilo server. I've placed the following code in a file named "ventrilo" in /etc/init.d and I've run "chmod +x ventrilo". However, if I attempt to run the command "/etc/init.d/ventrilo start" the console states "ventrilo: command not found". The code below is the "ventrilo" script, but I'm 90% certain that my problem doesn't lie completely with the script. I'm not sure where to go from here though, and any assistance would be wonderful. Thanks.

    ****EDIT****Never mind, I was able to get it working by removing the quotations around $1
    Code:
    #!/bin/bash
    VENT_DIR=/var/ventrilo
    VENT_EXE=$VENT_DIR/ventrilo_srv
    USER=ventrilo
    case "$1" in
            start)
                    if [ -e $VENT_DIR/ventrilo_srv.pid ]
                            then echo Ventrilo is already started
                            exit
                    fi
                    echo -n Starting Ventrilo:
                    su  $USER -c "$VENT_EXE -f$VENT_EXE -d"
                    if [ -e $VENT_DIR/ventrilo_srv.pid ]
                            then echo done
                    else
                            echo failed
                    fi
            ;;
            stop)
                    echo -n Stopping ventrilo:
    		if [ -e $VENT_DIR/ventrilo_srv.pid ]
    			then echo -n
    		else
    			echo Venrilo is not started!
    			exit
    		fi
                    kill `cat $VENT_DIR/ventrilo_srv.pid`
    		sleep .5s
                    if [ -e $VENT_DIR/ventrilo_srv.pid ]
                            then echo failed
                    else
                            echo done
                    fi
            ;;
            restart)
                    $0 stop
                    $0 start
            ;;
            *)
                    echo Usage: start stop restart
            ;;
    esac
    exit
    
     
    Last edited: Mar 14, 2010

Currently Active Users Viewing This Thread: 1 (0 members and 1 guest)

Share This Page