solaris 10: add new svc

Tags
solaris

 
Thread Tools Search this Thread
# 1  
Old 11-16-2006
solaris 10: add new svc

Hi guys,
I want to add a new 'service' to Solaris 10. Does anyone have any documentation that tells how to do that?

I have gone through a bunch of stuff on the net that tells how to enable, disable services, find whats wrong with a service and so on. All conveniently skip mention of how to actually add a new service of your own.

I checked the files in /var/svc/manifest, and I know that they are the xmls that are used by the svcadm and its ilk, but does adding a new 'service' mean writing one of those xml files yourself?

-edit
Don't like the word service - feels too Windowsy
-/edit
# 2  
Old 11-16-2006
Yes you have to create the xml file yourself..

- Create your shell start stop script and save it in /usr/local/svc/method/myservice
- chmod 755 /usr/local/svc/method/myservice
- Create your xml file and save it in /var/svc/manifest/site/myservice.xml
- Incorporate the script into the SMF using svccfg utility
Code:
svccfg import /var/svc/manifest/site/myservice.xml

note:
replace myservice with the name of the service you are adding.

Last edited by Tornado; 11-16-2006 at 03:19 AM..
This User Gave Thanks to For This Post:
biafran (05-11-2012)
Tornado
# 3  
Old 11-16-2006
Thanks. Do you have any documentation that says what those xml tags mean? That would really help out.
# 4  
Old 11-16-2006
Quote:
Originally Posted by blowtorch
Thanks. Do you have any documentation that says what those xml tags mean? That would really help out.
Yes I do, But thats at work. I will post them up tomorrow.
This User Gave Thanks to For This Post:
jd0694 (06-28-2011)
Tornado
# 5  
Old 11-16-2006
This bit of info might be of use to you..
http://www.sun.com/bigadmin/content/...dev_intro.html

I am going through the doco I have, I will have to type a couple of pages worth inbetween doing my other work so it will take me a while to type it up for you..
This User Gave Thanks to For This Post:
biafran (05-11-2012)
Tornado
# 6  
Old 11-16-2006
The general steps required are:
o Determine the proccess for starting and stopping your service.
o Establish a name for the service, and the category this service falls into.
o Determine whether your service runs multiple instances.
o Identify any dependency relationships between this service and any other service.
o If a script is required to start and stop the process, create the script and place it in a local directory such as /usr/local/svc/method
o Create a service manifest file for your service. This file describes the service and any dependency relationships. Service manifests are pulled into the repository either by using svccfg command or at boot time.
o Incorporate the scripts into SMF using the svccfg utility.

The following displays an example.
Code:
# vi /usr/local/svc/method/newservice
#!/sbin/sh
#
# Copyright (c) 1995, 1997-1999 by Sun Microsystems, Inc.
# All rights reserved.
#
#ident  "@(#)newservice    1.14    06/11/17 SMI"

case "$1" in
'start')
	/usr/bin/newservice &
	;;

'stop')
        /usr/bin/pkill -x -u 0 newservice
	;;

*0
	echo "Usage: $0 { start | stop }"
	;;
esac
exit 0

# chmod 544 /usr/local/svc/method/newservice

# cd /var/svc/manifest/site
# vi newservice.xml
<?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        "@(#)newservice.xml 1.2     04/08/09 SMI"
-->

<service_bundle type='manifest' name='OPTnew:newservice'>

<service
    name='site/newservice'
    type='service'
    version='1'

    <single_instance/>
	<dependency
            name='usr'
            type='service'
            grouping='require_all'
            restart_on='none'>
                <service_fmri value='svc:/system/filesystem/local'/>
        </dependency>

        <dependency
            name='newservice'
            grouping='require_all'
            restart_on='none'>
            <service_fmri value='svc:/milestone/multi-user'/>
        </dependency>

        <exec_method
            type='method'
            name='start'
            exec='/lib/svc/method/newservice start'
            timeout_seconds='30' />

        <exec_method
            type='method'
            name='stop'
            exec='/lib/svc/method/newservice 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'>
                                New Service
                        </loctext>
                </common_name>
        </template>
</service>

</service_bundle>

The following describes the entries in the file:

o Standard Header.
Code:
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM
"/usr/share/lib/xml/dtd/service_bundle.dtd.1">

o Comment Section.
Code:
<!--
    Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
    Use is subject to license terms.

    pragma ident        "@(#)newservice.xml 1.2     04/08/09 SMI"
-->

o The name of the service. the type(manifest) indicates a simple service rather than a milestone, the package providing the service, and the service name.
Code:
<service_bundle type='manifest' name='OPTnew:newservice'>

o Service category, type, name and version.
Code:
<service
    name='site/newservice'
    type='service'
    version='1'

o Whether multiple instances of the service will run.
Code:
<single_instance/>

o the service model to use. The entry shows that the service will be started by svc.startd. transient services are started once and not restarted.
Code:
<property_group name='startd' type='framework'>
                <propval name='duration' type='astring' value='transient' />
        </property_group>

o How the service is started and stopped.
Code:
        <exec_method
            type='method'
            name='start'
            exec='/lib/svc/method/newservice start'
            timeout_seconds='30' />

        <exec_method
            type='method'
            name='stop'
            exec='/lib/svc/method/newservice stop'
            timeout_seconds='30' />

o Define any dependencies for this service. The first entry states that the newservice requires the filesystem/local service.
Code:
	<dependency
            name='usr'
            type='service'
            grouping='require_all'
            restart_on='none'>
                <service_fmri value='svc:/system/filesystem/local'/>
        </dependency>

o The second entry makes sure that your service is associated with the multi-user milestone and that the multi-user milestone requires this service.
Code:
        <dependency
            name='newservice'
            grouping='require_all'
            restart_on='none'>
            <service_fmri value='svc:/milestone/multi-user'/>
        </dependency>

o Creating the instance.
Code:
        <instance name='default' enabled='true' />

        <stability value='Unstable' />

o Creating information to describe the service.
Code:
        <template>
                <common_name>
                        <loctext xml:lang='C'>
                                New Service
                        </loctext>
                </common_name>
        </template>

The new service (newservice) now needs to be imported into SMF.
This is done by running the svccfg utility:
Code:
# svccfg import /var/svc/manifest/site/newservice.xml

After the service has been imported into the SMF it should be visable using the svcs command.
Code:
# svcs newservice
STATE		STIME	FMRI
online		8:57:35	svc:/site/newservice:default
#

It should also be possible to manipulate the service using svcadm.
Code:
# svcadm -v disable site/newservice
site/newservice disabled.
# svcs newservice
STATE		STIME	FMRI
disabled	9:07:15	svc:/site/newservice:default
# svcadm -v enable site/newservice
site/newservice enabled.
# svcs newservice
STATE		STIME	FMRI
online		9:17:01	svc:/site/newservice:default
#

Finally, you can observe that the multiuser milestone requires the newservice in order to complete its requirements.
Code:
# svcs -d milestone/multi-user:default
STATE		STIME	FMRI
disabled	8:43:16 svc:/platform/sun4u/sf880drd:default
online		8:43:16 svc:/milestone/name-services:default
online		8:43:33 svc:/system/rmtmpfiles:default
online		8:43:42 svc:/network/rpc/bind:default
online		8:43:46 svc:/milestone/single-user:default
online		8:43:46 svc:/system/utmp:default
online		8:43:47 svc:/system/system-log:default
online		8:43:49 svc:/system/filesystem/local:default
online		8:44:01 svc:/system/mdmonitor:default
online		9:17:01 svc:/site/newservice:default
#

These 4 Users Gave Thanks to For This Post:
biafran (05-11-2012) bluescreen (04-04-2011) kreno (04-08-2011) olam (11-04-2011)
Tornado
# 7  
Old 11-16-2006
Hey! Thanks a ton mate!

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
How to add new Solaris client IP into Solaris 10 DNS server? snchaudhari2 Solaris 5 11-26-2018 01:32 PM
Change the ID of a SVC Node gull04 AIX 2 02-16-2017 01:35 PM
How to add Solaris text console to Solaris grub2 menu? shamsat Solaris 1 02-04-2015 10:52 AM
Solaris ftp connects out svc disabled. RedWizard75 Solaris 5 11-05-2014 01:20 PM
Svc:/network/http:apache2 error Junaid Subhani Solaris 1 11-13-2013 05:09 PM
Svc messages flooding the system logs every second DNT Solaris 7 11-27-2012 07:29 AM
dependency require_all/none svc:/network/physical (maintenance) getrue Solaris 8 02-25-2012 05:21 PM
svc:/network/physical:default: Method "/lib/svc/method/net-physical" failed with exit status 96. [ n andersonedouard Solaris 2 06-14-2011 04:43 AM
svc:/system/filesystem/local is always in maintenance status EAGL€ Solaris 4 06-04-2010 10:12 AM
svc Errors on OS startup adelsin Solaris 5 03-12-2010 10:34 AM
Invalid configuration for instance svc:/application/x11/xvnc-inetd:default, placing i durgaprasadr13 Solaris 2 05-11-2009 08:12 AM
SDD for SVC on HP-UX and LINUX kdossjojo Filesystems, Disks and Memory 1 04-11-2009 07:49 PM
smf fails to mount svc:/system/filesystem/usr:default knl.sundeep Solaris 6 03-25-2009 09:39 AM
Sol_9 => Sol_10/08 Upgrade svc startup issue. ShawnLua UNIX for Dummies Questions & Answers 0 12-11-2008 01:54 AM
how do you login as sms-svc on a system controller vinix Solaris 1 02-04-2008 06:41 AM