Opensolaris : SMF and Squid

Decided to create a SMF manifest for squid so that it autostarts on boot.

Command to start squid : /usr/squid/sbin/squid 

Command to stop squid : /usr/squid/sbin/squid -k shutdown 

This site has a good starter on SMF creation : http://blogs.sun.com/observatory/entry/mouting_windows_shares_at_startup

I’ve taken a copy of the /var/svc/manifest/network/smb/server.xml file for my squid manifest and placed it at /var/svc/manifest/network/squid/squid.xml

Import the XML using this command; 

svccfg import /var/svc/manifest/network/squid/squid.xml 

Update: i’ve stopped this work as i missed the fact that squid already comes with a SMF manifest! :)  No idea how i missed that one. You can enable via ; 

svcadm enable svc:/network/http:squid

This is the manifest for the above service; 

<?xml version=”1.0″?>

<!–

CDDL HEADER START

 

The contents of this file are subject to the terms of the

Common Development and Distribution License (the “License”).

You may not use this file except in compliance with the License.

 

You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

or http://www.opensolaris.org/os/licensing.

See the License for the specific language governing permissions

and limitations under the License.

 

When distributing Covered Code, include this CDDL HEADER in each

file and include the License file at usr/src/OPENSOLARIS.LICENSE.

If applicable, add the following below this CDDL HEADER, with the

fields enclosed by brackets “[]” replaced with your own identifying

information: Portions Copyright [yyyy] [name of copyright owner]

 

CDDL HEADER END

–>

 

<!DOCTYPE service_bundle SYSTEM “/usr/share/lib/xml/dtd/service_bundle.dtd.1”>

<!–

    Copyright 2007 Sun Microsystems, Inc.  All rights reserved.

    Use is subject to license terms.

 

    ident “@(#)http-squid.xml 1.2 08/01/16 SMI”

–>

 

<service_bundle type=’manifest’ name=’SUNWsquidr:squid’>

 

<service

name=’network/http’

type=’service’

version=’1′>

 

<!–

 Because we may have multiple instances of network/http

 provided by different implementations, we keep dependencies

 and methods within the instance.

–>

 

<instance name=’squid’ enabled=’false’>

<!–

 Wait for network interfaces to be initialized.

–>

<dependency name=’network’

   grouping=’require_all’

   restart_on=’error’

   type=’service’>

   <service_fmri value=’svc:/milestone/network:default’/>

</dependency>

 

<!–

 Wait for all local filesystems to be mounted.

–>

<dependency name=’filesystem-local’

   grouping=’require_all’

   restart_on=’none’

   type=’service’>

   <service_fmri

value=’svc:/system/filesystem/local:default’/>

</dependency>

 

<!–

 Wait for automounting to be available, as we may be

 serving data from home directories or other remote

 filesystems.

–>

<dependency name=’autofs’

   grouping=’optional_all’

   restart_on=’error’

   type=’service’>

   <service_fmri

value=’svc:/system/filesystem/autofs:default’/>

</dependency>

 

<exec_method

type=’method’

name=’start’

exec=’/lib/svc/method/http-squid start’

timeout_seconds=’60’ />

 

<exec_method

type=’method’

name=’stop’

exec=’/lib/svc/method/http-squid stop’

timeout_seconds=’60’ />

 

<property_group name=’startd’ type=’framework’>

<!– sub-process core dumps shouldn’t restart

session –>

<propval name=’ignore_error’ type=’astring’

value=’core,signal’ />

</property_group>

 

        <template>

            <common_name>

                <loctext xml:lang=’C’>

                    Squid WebCache

                </loctext>

            </common_name>

            <documentation>

                <manpage title=’squid’ section=’8′

                    manpath=’/usr/squid/man’ />

                <doc_link name=’squid-cache.org’

                    uri=’http://www.squid-cache.org’ />

            </documentation>

        </template>

</instance>

 

        <stability value=’Evolving’ />

</service>

 

</service_bundle>

 

 

Leave a Reply

Your email address will not be published.