The Solaris software environment provides a detailed series of run control (rc) scripts to control run level changes. Each run level has an associated rc script located in the /sbin directory:
rc0
rc1
rc2
rc3
rc5
rc6
rcS
For each rc script in the /sbin directory, there is a corresponding directory named /etc/rcn.d that contains scripts to perform various actions for that run level. For example, /etc/rc2.d contains files used to start and stop processes for run level 2.
# ls /etc/rc2.d K07dmi S70uucp S75cron S91afbinit K07snmpdx S71ldap.client S75flashprom S91ifbinit K28nfs.server S71rpc S75savecore S92volmgt README S71sysid.sys S76nscd S93cacheos.finish S01MOUNTFSYS S72autoinstall S80PRESERVE S94ncalogd S05RMTMPFILES S72inetsvc S80lp S95IIim S20sysetup S72slpd S80spc S95amiserv S21perf S73cachefs.daemon S85power S95ocfserv S30sysid.net S73nfs.client S88sendmail S99audit S40llc2 S74autofs S88utmpd S99dtlogin S47asppp S74syslog S89bdconfig S69inet S74xntpd S90wbem |
The /etc/rcn.d scripts are always run in ASCII sort order. The scripts have names of the form:
[KS][0-9][0-9]*
Files beginning with K are run to terminate (kill) a system process. Files beginning with S are run to start a system process.
Run control scripts are also located in the /etc/init.d directory. These files are linked to corresponding run control scripts in the /etc/rcn.d directories.
The actions of each run control script are summarized in Table 8-5.
One advantage of having individual scripts for each run level is that you can run scripts in the /etc/init.d directory individually to turn off functionality without changing a system's run level.
Become superuser.
Turn off functionality.
# /etc/init.d/filename stop |
Restart functionality.
# /etc/init.d/filename start |
Use the pgrep command to verify whether the service has been stopped or started.
# pgrep -f service |
Turn off NFS server functionality by typing:
# /etc/init.d/nfs.server stop # pgrep -f nfs # |
Restart the NFS services by typing:
# /etc/init.d/nfs.server start # pgrep -f nfs 141 143 245 247 # pgrep -f nfs -d, | xargs ps -fp daemon 141 1 40 Jul 31 ? 0:00 /usr/lib/nfs/statd root 143 1 80 Jul 31 ? 0:01 /usr/lib/nfs/lockd root 245 1 34 Jul 31 ? 0:00 /usr/lib/nfs/nfsd -a 16 root 247 1 80 Jul 31 ? 0:02 /usr/lib/nfs/mountd |
If you want to add a run control script to start and stop a service, copy the script into the /etc/init.d directory and create links in the rcn.d directory you want the service to start and stop.
See the README file in each /etc/rcn.d directory for more information on naming run control scripts. The procedure below describes how to add a run control script.
Become superuser.
Add the script to the /etc/init.d directory.
# cp filename /etc/init.d # chmod 0744 /etc/init.d/filename # chown root:sys /etc/init.d/filename |
Create links to the appropriate rcn.d directory.
# cd /etc/init.d # ln filename /etc/rc2.d/Snnfilename # ln filename /etc/rcn.d/Knnfilename |
Use the ls command to verify that the script has links in the specified directories.
# ls /etc/init.d/ /etc/rc2.d/ /etc/rcn.d/ |
# cp xyz /etc/init.d # cd /etc/init.d # ln xyz /etc/rc2.d/S100xyz # ln xyz /etc/rc0.d/K100xyz # ls /etc/init.d /etc/rc2.d /etc/rc0.d |
Disable a run control script by renaming it with a dot (.) at the beginning of the new file name. Files that begin with a dot are not executed. If you copy a file by adding a suffix to it, both files will be run.
Become superuser.
Rename the script by adding an underscore (_) to the beginning of the new file.
# cd /etc/rcn.d # mv filename _filename |
Verify the script has been renamed.
# ls # _filename |
The following example changes the S100datainit script name but saves the original script.
# cd /etc/rc2.d # mv S100datainit _S100datainit |