Tuesday, June 26, 2012

rc.local on suse

Suse does not have rc.local enabled by default.

which means it is difficult to have a program automatically start up, after your system has been booted.

Suse does have a file called /etc/init.d/boot.local.

However it is not the same as rc.local
Inputting paths to files to run in the boot.local file
executes them before going to the first run level.
Which is a problem if you need your application to run after the system has completely booted.

rc.local to the rescue.

simply create your own rclocal file like so.
I use vim but you can use any file editor program like nano or gedit
vim /etc/rc.d/rclocal

then inside the file type the following (between the -----)
#! /bin/sh
## This script simulates redhat's rc.local (Add commands at the end)
# Provides: rclocal
# Required-Start: $local_fs $remote_fs $network
# X-UnitedLinux-Should-Start: $ALL
# Required-Stop:
# X-UnitedLinux-Should-Stop:
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: Simulates rc.local
# Description: Simulates redhat's rc.local: contains
# commands to execute after system has booted (all services are already
# available)
## Execute ony when service is started
case "$1" in
## commands will be executed
exit 0

#  Add your commands bellow this line

Save the file.
Make the file executable by typing the following: chmod +x rclocal
Create symlink to make it easy to find:  ln -s rclocal rc.local
Next, you need to enable the rc.local simulation in yast.
then scroll to
System > system services (Run Level)
then scroll down to
> rclocal   simulates rc.local
and enable it
 > Enable

Save your settings, and you are done.
you now have a rc.local that behaves exactly like the redhat/fedora  rc.local
You can add/remove commands to /etc/rc.d/rc.local anytime
by simply editing the rclocal file and adding your commands you wish to execute at the bottom of the file.

No comments: