This small guide details a number of useful commands for those who are not that familiar with Solaris 10.
To stop/start a service (similar to /etc/rc.d/init.d/service stop/start in Linux) is:
svcadm disable/enable [-t] servicename
the option -t makes the change temporary (e.g. stopping a service now, but it'll come back after a reboot). Without it the change is permanent until a new state is set. Hence if you want to disable a service only temporarily without affecting what happens at system startup, use the -t option, otherwise don't.
I have created a few example xml and method files and they can be used. For example for dCache pool startup the following XML file has to be placed in /var/svc/manifest/site/
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<!--
Copyright 2004 Sun Microsystems, Inc. All rights reserved.
Use is subject to license terms.
pragma ident "@(#)dcache-pool.xml 1.2 04/08/09 SMI"
-->
<service_bundle type='manifest' name='OPTnew:dcache-pool'>
<service
name='site/dcache-pool'
type='service'
version='1'>
<single_instance />
<dependency name='multi-user'
grouping='require_all'
restart_on='error'
type='service'>
<service_fmri value='svc:/milestone/multi-user:default'/>
</dependency>
<exec_method
type='method'
name='start'
exec='/lib/svc/method/dcache-pool start'
timeout_seconds='30' />
<exec_method
type='method'
name='stop'
exec='/lib/svc/method/dcache-pool stop'
timeout_seconds='30' />
<property_group name='startd' type='framework'>
<propval name='duration' type='astring' value='transient' />
</property_group>
<instance name='default' enabled='true' />
<stability value='Unstable' />
<template>
<common_name>
<loctext xml:lang='C'>
dCache POOL
</loctext>
</common_name>
</template>
</service>
</service_bundle>
And a respective method (which is referred to by the XML) in /lib/svc/method/
#!/sbin/sh
#
# Copyright (c) 2008 by Mario Kadastik
# All rights reserved.
#
#ident "@(#)dcache-pool
case "$1" in
'start')
cd /opt/d-cache/bin
bash dcache-pool start
;;
'stop')
cd /opt/d-cache/bin
bash dcache-pool stop
;;
*)
echo "Usage: $0 { start | stop }"
;;
esac
exit 0
once that is done you can validate and import the service:
# svccfg svc:> validate /var/svc/manifest/site/dcache-pool.xml svc:> import /var/svc/manifest/site/dcache-pool.xml svc:>
and voila the service is there in svcs:
$ svcs|grep dcache-pool online Mar_30 svc:/site/dcache-pool:default