2009-03-29

Adding an instance to svc:/network/http on Solaris 10 10/08, Part 1

There are two versions of httpd's in Solaris 10 packages: version 1.3 and version 2.0.
# svcs '*apache*'
STATE          STIME    FMRI
legacy_run     17:06:43 lrc:/etc/rc3_d/S50apache
disabled       17:01:55 svc:/network/http:apache2


I have tried to add an version 2.2 instance to svc:/network/http.

At first, I got the service description for svc:/network/http with svccfg command. Of course you can look into the manifest /var/svc/manifest/network/http-apache2.xml.

# svccfg export svc:/network/http
<?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<service_bundle type='manifest' name='export'>
  <service name='network/http' type='service' version='0'>
    <instance name='apache2' enabled='false'>
      <dependency name='network' grouping='require_all' restart_on='error' type='service'>
        <service_fmri value='svc:/milestone/network:default'/>
      </dependency>
      <dependency name='filesystem-local' grouping='require_all' restart_on='none' type='service'>
        <service_fmri value='svc:/system/filesystem/local:default'/>
      </dependency>
      <dependency name='autofs' grouping='optional_all' restart_on='error' type='service'>
        <service_fmri value='svc:/system/filesystem/autofs:default'/>
      </dependency>
      <exec_method name='start' type='method' exec='/lib/svc/method/http-apache2 start' timeout_seconds='60'>
        <method_context/>
      </exec_method>
      <exec_method name='stop' type='method' exec='/lib/svc/method/http-apache2 stop' timeout_seconds='60'>
        <method_context/>
      </exec_method>
      <exec_method name='refresh' type='method' exec='/lib/svc/method/http-apache2 refresh' timeout_seconds='60'>
        <method_context/>
      </exec_method>
      <property_group name='httpd' type='application'>
        <stability value='Evolving'/>
        <propval name='ssl' type='boolean' value='false'/>
      </property_group>
      <property_group name='startd' type='framework'>
        <propval name='ignore_error' type='astring' value='core,signal'/>
      </property_group>
    </instance>
    <stability value='Evolving'/>
    <template>
      <common_name>
        <loctext xml:lang='C'>Apache 2 HTTP server</loctext>
      </common_name>
      <documentation>
        <manpage title='httpd' section='8' manpath='/usr/apache2/man'/>
        <doc_link name='apache.org' uri='http://httpd.apache.org'/>
      </documentation>
    </template>
  </service>
</service_bundle>
#

Referring to the apache2 instance of the output above, I made an apache22 instance like this.

# svccfg -s svc:/network/http add apache22
# svccfg -s http:apache22 addpg network dependency
# svccfg -s http:apache22 setprop network/grouping = astring: require_all
# svccfg -s http:apache22 setprop network/entities = fmri: svc:/milestone/network:default
# svccfg -s http:apache22 setprop network/restart_on = astring: error
# svccfg -s http:apache22 setprop network/type = astring: service

At this point the result of the command 

# svccfg export svc:/network/http

should have lines below:

    <instance name='apache22' enabled='false'>
      <dependency name='network' grouping='require_all' restart_on='error' type='service'>
        <service_fmri value='svc:/milestone/network:default'/>
      </dependency>
    </instance>

It is hard to input tens of command lines. So I made a command file named command.txt:

# vi command.txt
addpg filesystem-local dependency
setprop filesystem-local/grouping = astring: require_all
setprop filesystem-local/restart_on = astring: none
setprop filesystem-local/type = astring: service
setprop filesystem-local/entities = fmri: svc:/system/filesystem/local:default
addpg autofs dependency
setprop autofs/grouping = astring: optional_all
setprop autofs/restart_on = astring: error
setprop autofs/type = astring: service
setprop autofs/entities = fmri: svc:/system/filesystem/autofs:default
addpg start method
setprop start/type = astring: method
setprop start/exec = astring: "/lib/svc/method/http-apache22 start"
setprop start/timeout_seconds = count: 60
addpg stop method
setprop stop/type = astring: method
setprop stop/exec = astring: "/lib/svc/method/http-apache22 stop"
setprop stop/timeout_seconds = count: 60
addpg refresh method
setprop refresh/type = astring: method
setprop refresh/exec = astring: "/lib/svc/method/http-apache22 refresh"
setprop refresh/timeout_seconds = count: 60
addpg httpd application
addpropvalue httpd/stability astring: Evolving
addpropvalue httpd/ssl boolean: false
addpg startd framework
addpropvalue startd/ignore_error astring: core,signal

and executed.

# svccfg -s apache22 -f command.txt

Now the result of "svccfg export http" is

# svccfg export http
<?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<service_bundle type='manifest' name='export'>
  <service name='network/http' type='service' version='0'>
    <instance name='apache2' enabled='false'>
      <dependency name='network' grouping='require_all' restart_on='error' type='service'>
        <service_fmri value='svc:/milestone/network:default'/>
      </dependency>
      <dependency name='filesystem-local' grouping='require_all' restart_on='none' type='service'>
        <service_fmri value='svc:/system/filesystem/local:default'/>
      </dependency>
      <dependency name='autofs' grouping='optional_all' restart_on='error' type='service'>
        <service_fmri value='svc:/system/filesystem/autofs:default'/>
      </dependency>
      <exec_method name='start' type='method' exec='/lib/svc/method/http-apache2 start' timeout_seconds='60'>
        <method_context/>
      </exec_method>
      <exec_method name='stop' type='method' exec='/lib/svc/method/http-apache2 stop' timeout_seconds='60'>
        <method_context/>
      </exec_method>
      <exec_method name='refresh' type='method' exec='/lib/svc/method/http-apache2 refresh' timeout_seconds='60'>
        <method_context/>
      </exec_method>
      <property_group name='httpd' type='application'>
        <stability value='Evolving'/>
        <propval name='ssl' type='boolean' value='false'/>
      </property_group>
      <property_group name='startd' type='framework'>
        <propval name='ignore_error' type='astring' value='core,signal'/>
      </property_group>
    </instance>
    <instance name='apache22' enabled='false'>
      <dependency name='network' grouping='require_all' restart_on='error' type='service'>
        <service_fmri value='svc:/milestone/network:default'/>
      </dependency>
      <dependency name='filesystem-local' grouping='require_all' restart_on='none' type='service'>
        <service_fmri value='svc:/system/filesystem/local:default'/>
      </dependency>
      <dependency name='autofs' grouping='optional_all' restart_on='error' type='service'>
        <service_fmri value='svc:/system/filesystem/autofs:default'/>
      </dependency>
      <exec_method name='start' type='method' exec='/lib/svc/method/http-apache22 start' timeout_seconds='60'>
        <method_context/>
      </exec_method>
      <exec_method name='stop' type='method' exec='/lib/svc/method/http-apache22 stop' timeout_seconds='60'>
        <method_context/>
      </exec_method>
      <exec_method name='refresh' type='method' exec='/lib/svc/method/http-apache22 refresh' timeout_seconds='60'>
        <method_context/>
      </exec_method>
      <property_group name='httpd' type='application'>
        <stability value='Evolving'/>
        <propval name='ssl' type='boolean' value='false'/>
      </property_group>
      <property_group name='startd' type='framework'>
        <propval name='ignore_error' type='astring' value='core,signal'/>
      </property_group>
    </instance>
    <stability value='Evolving'/>
    <template>
      <common_name>
        <loctext xml:lang='C'>Apache 2 HTTP server</loctext>
      </common_name>
      <documentation>
        <manpage title='httpd' section='8' manpath='/usr/apache2/man'/>
        <doc_link name='apache.org' uri='http://httpd.apache.org'/>
      </documentation>
    </template>
  </service>
</service_bundle>
#



No comments:

Post a Comment