Thursday, October 4, 2012

Solaris Services

Abstract:
Services in the System VR4 world were traditionally managed through facilities such as /etc/rc scripts, /etc/initab, and /etc/inetd.conf family of facilities. There were disadvantages regarding these families, regarding configuration differences, monitoring for failures, and provisioning. Solaris 10 introduced SMF, or Solaris Service Management Facility, which is now available in most modern operating systems. This script helps to recursively display the dependent services.

Script:
The script must remain in your execution path and must have the executable bit set.
#!/bin/ksh
# script: r_svcs2.sh
# author: david halko
# license: cddl - must retain authorship note in any usage
# purpose: recursively show dependent services maximum level of 4 deep
# version: 1.0 - released using + instead of tabs for blogspot illustration
# usage: r_svcs2.sh [service]
# examples: r_svcs2.sh inetd
# r_svcs2.sh gdm2-login
#
Param="${1}"
Deep="${2}"

[ "${2}" = "++++" ] && exit # exit if too many levels deep

if [ "${1}" = "" ]; then
nawk '/^#/ !/^#/ { exit }' `whence ${0}`
else
echo "${Deep}\c"
svcs -H ${Param} 2>&1 || exit
svcs -dH ${Param} 2>&1 | nawk '{ print $3 }' | sort -u | while read Param2
do
r_svcs2.sh "${Param2}" "+${Deep}"
done
fi

Help Screen:
The help screen will come up as default if you do not supply any options.
V240/user$ r_svcs2.sh
#!/bin/ksh
# script: r_svcs2.sh
# author: david halko
# license: cddl - must retain authorship note in any usage
# purpose: recursively show dependent services maximum level of 4 deep
# version: 1.0 - released using + instead of tabs for blogspot illustration
# usage: r_svcs2.sh [service]
# examples: r_svcs2.sh inetd
# r_svcs2.sh gdm2-login
#

Example Run:
The expanded dependencies can get quite large. An arbitrary number of 4 levels deep was coded into the script to keep the script from running for hours on slow machines. A simple run is illustrated below.
V240/user$ r_svcs2.sh gdm2-login
disabled Sep_29 svc:/application/gdm2-login:default
+online Sep_29 svc:/system/filesystem/local:default
++online Sep_29 svc:/milestone/single-user:default
+++online Sep_29 svc:/milestone/devices:default
+++online Sep_29 svc:/milestone/network:default
+++online Sep_29 svc:/network/loopback:default
+++online Sep_29 svc:/system/cryptosvc:default
+++online Sep_29 svc:/system/filesystem/minimal:default
+++online Sep_29 svc:/system/identity:node
+++online Sep_29 svc:/system/installupdates:default
+++online Sep_29 svc:/system/keymap:default
+++online Sep_29 svc:/system/manifest-import:default
+++disabled Sep_29 svc:/system/metainit:default
+++online Sep_29 svc:/system/patchchk:default
+++online Sep_29 svc:/system/sysevent:default
++online Sep_29 svc:/system/filesystem/minimal:default
+++online Sep_29 svc:/system/device/local:default
+++online Sep_29 svc:/system/filesystem/usr:default
+online Sep_29 svc:/system/utmp:default
++online Sep_29 svc:/milestone/sysconfig:default
+++online Sep_29 svc:/milestone/single-user:default
+++online Sep_29 svc:/system/sysidtool:net
+++online Sep_29 svc:/system/sysidtool:system

No comments:

Post a Comment