• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.
  • The forums have been upgraded with support for dark mode. By default it will follow the setting on your system/browser. You may override it by scrolling to the end of the page and clicking the gears icon.

Need Help with Linux Startup Script

ct5098

New Member
Joined
Aug 3, 2009
Messages
13 (0.00/day)
Processor AMD Phenom II 955 BE @ 3.4 GHz
Motherboard MSI K9N2G Neo
Cooling Xigmatek heatsink
Memory 2 x 2GB DDR2 @ 800 MHz
Video Card(s) Sapphire 2GB Radeon HD 6950
Storage 1TB Western Digital Black Edition
Display(s) Auria 25" LCD
Case NZXT tower
Audio Device(s) N/A
Power Supply 550 Watt
Software Windows 7 Home Premium 64-bit
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:
Back
Top