How to run script at startup

I have a fresh openSuSE 11.1 install and I’m trying to figure out how to run something at startup. It’s a simple script that launches a program called vray.

I tried putting it in /etc/init.d and also tried it in /etc/init.d/rc5.d but it does not run when the machine reboots.

I know that you can turn it off & on using YaST, but I don’t see it showing up in there.

Any help would be great.
Thanks!

Ok, nevermind. I guess adding it to /etc/init.d did actually work.:wink:

Hi
Use the template in /etc/init.d/skeleton and modify that to your
requirements.


Cheers Malcolm °¿° (Linux Counter #276890)
SUSE Linux Enterprise Desktop 11 (x86_64) Kernel 2.6.27.39-0.3-default
up 1 day 23:19, 2 users, load average: 0.06, 0.13, 0.15
GPU GeForce 8600 GTS Silent - CUDA Driver Version: 190.18

Thanks for the help! Can you tell me where in that file I should be looking??

Hi
The information to create the rc softlinks (runlevels) is in the
section INIT INFO. So if certain services need to be running before
your applications starts they need to be detailed in this section
“Required-Start” likewise when shutting down “Required-Stop”. See the
man page for insserv for more details.

If you only want to start/stop/restart, just add your paths to the
script in the relevant sections and just delete the rest.


Cheers Malcolm °¿° (Linux Counter #276890)
SUSE Linux Enterprise Desktop 11 (x86_64) Kernel 2.6.27.39-0.3-default
up 2 days 7:48, 2 users, load average: 0.01, 0.07, 0.09
GPU GeForce 8600 GTS Silent - CUDA Driver Version: 190.18

I’ve been having trouble with this myself. I don’t want a full init script that I can start and stop, just a simple program as well. Do you just have a bash script in there and it runs?

don’t edit the /etc/init.d/skeleton you want to copy that so

cp /etc/init.d/skeleton /etc/init.d/startprog

if my understanding is correct.

Hi
Are you wanting the script to start your application on startup, or
when you log into the system and/or desktop.

What is the script?


Cheers Malcolm °¿° (Linux Counter #276890)
SUSE Linux Enterprise Desktop 11 (x86_64) Kernel 2.6.27.39-0.3-default
up 2 days 14:23, 3 users, load average: 0.13, 0.15, 0.10
GPU GeForce 8600 GTS Silent - CUDA Driver Version: 190.18

well the one right now is to change the way dhcpd works

/usr/sbin/dhcpd eth0 -p 1067

so something real simple, but later I’ll be making something with IP Tables

so these will need to launch at start up

On 12/29/2009 11:46 AM, sailorcire wrote:
>
> malcolmlewis;2095210 Wrote:
>> Hi
>> Are you wanting the script to start your application on startup, or
>> when you log into the system and/or desktop.
>>
>> What is the script?
>>
>> –
>> Cheers Malcolm °¿° (Linux Counter #276890)
>> SUSE Linux Enterprise Desktop 11 (x86_64) Kernel 2.6.27.39-0.3-default
>> up 2 days 14:23, 3 users, load average: 0.13, 0.15, 0.10
>> GPU GeForce 8600 GTS Silent - CUDA Driver Version: 190.18
> well the one right now is to change the way dhcpd works
>
> /usr/sbin/dhcpd eth0 -p 1067
>
> so something real simple, but later I’ll be making something with IP
> Tables
>
> so these will need to launch at start up

When you start at level X, the scripts in /etc/init.d/rcX.d/S* are executed in
alphabetic order. Characteristically, the entries in this directory are links to
a script in /etc/init.d. To implement a local script from level 5, I would copy
your dhcpd call above to /etc/init.d/local making sure it is executable by root.
To finish the setup, do the following


sudo ln -s /etc/init.d/local /etc/init.d/rc5.d/S99local

As you add new commands, just add them tp /etc/init.d/local.

Ok, so I’ve got the following in /etc/init.d/local


#!/bin/bash

/usr/sbin/dhcpd eth0 -p 1067

I’ve chmoded that to make it executable

I’ve also made a soft link to /etc/init.d/rc3.d/S99local

now when I reboot, and log back in and do a check on it…it still isn’t running it.

I’m checking it using both


ps -PA | grep dhcpd

and


rcdhcpd status

however, when i start it manually and then check it works.

any ideas?

#!/bin/bash

### BEGIN INIT INFO
# Provides:		**vray**
# Required-Start:	$local_fs $network $remote_fs
# Required-Stop:	$null
# Default-Start:	2 3 5
# Default-Stop:		0 1 6
# Short-Description:	**your description**
# Description:		**your description**
### END INIT INFO

# Path to executable
**VRAY=**

test -x "$VRAY" || exit 5


# Include status script
. /etc/rc.status
rc_reset

case "$1" in
	start)
	echo -n "Starting service vray"
	**your startup code here**
	rc_status -v
	;;
	stop)
	echo -n "Shutting down service vray"
	killproc -TERM $VRAY
	rc_status -v
	;;
	try-restart|condrestart)
	# Restart only if program is running
	$0 status
	if  $? = 0 ]; then
		$0 restart
	else
		rc_reset
	fi
	rc_status
	;;
	restart)
	$0 stop
	$0 start
	rc_status
	;;
	reload|force-reload)
	echo -n "Reloading service vray"
	killproc -HUP $VRAY
	rc_status -v
	;;
	status)
	echo -n "Checking status of service vray"
	checkproc $VRAY
	rc_status -v
	;;
	*)
	echo "Usage: $0 {start|stop|restart|try-restart|condrestart|reload|force-reload|status}"
	exit 1
	;;
esac 
rc_exit

Adjust/change everything in bold. Make sure the scrip has the same name as in the # Provides

Copy it to /etc/init.d and on console as root do the following:

chkconfig -a scriptname
service scriptname start

(where ‘scriptname’ is the real name of the script)