1*4e9cfc9aSjacobs#!/bin/sh 2*4e9cfc9aSjacobs# 3*4e9cfc9aSjacobs# CDDL HEADER START 4*4e9cfc9aSjacobs# 5*4e9cfc9aSjacobs# The contents of this file are subject to the terms of the 6*4e9cfc9aSjacobs# Common Development and Distribution License (the "License"). 7*4e9cfc9aSjacobs# You may not use this file except in compliance with the License. 8*4e9cfc9aSjacobs# 9*4e9cfc9aSjacobs# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*4e9cfc9aSjacobs# or http://www.opensolaris.org/os/licensing. 11*4e9cfc9aSjacobs# See the License for the specific language governing permissions 12*4e9cfc9aSjacobs# and limitations under the License. 13*4e9cfc9aSjacobs# 14*4e9cfc9aSjacobs# When distributing Covered Code, include this CDDL HEADER in each 15*4e9cfc9aSjacobs# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*4e9cfc9aSjacobs# If applicable, add the following below this CDDL HEADER, with the 17*4e9cfc9aSjacobs# fields enclosed by brackets "[]" replaced with your own identifying 18*4e9cfc9aSjacobs# information: Portions Copyright [yyyy] [name of copyright owner] 19*4e9cfc9aSjacobs# 20*4e9cfc9aSjacobs# CDDL HEADER END 21*4e9cfc9aSjacobs# 22*4e9cfc9aSjacobs# 23*4e9cfc9aSjacobs# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 24*4e9cfc9aSjacobs# Use is subject to license terms. 25*4e9cfc9aSjacobs 26*4e9cfc9aSjacobs# 27*4e9cfc9aSjacobs# ident "%Z%%M% %I% %E% SMI" 28*4e9cfc9aSjacobs 29*4e9cfc9aSjacobs. /lib/svc/share/smf_include.sh 30*4e9cfc9aSjacobs 31*4e9cfc9aSjacobsMETHOD=${1} 32*4e9cfc9aSjacobsINSTANCE=${2} 33*4e9cfc9aSjacobs 34*4e9cfc9aSjacobsDBUS_DESTINATION="org.freedesktop.Hal" 35*4e9cfc9aSjacobsMESSAGE_PREFIX="org.freedesktop.Hal.Device.NetworkDiscovery" 36*4e9cfc9aSjacobsOBJECT_PATH="/org/freedesktop/Hal/devices/network_attached" 37*4e9cfc9aSjacobsSMF_PROPERTY_GROUP="config" 38*4e9cfc9aSjacobsHAL_PROPERTY_GROUP="network_discovery" 39*4e9cfc9aSjacobsSVCS=/usr/bin/svcs 40*4e9cfc9aSjacobs 41*4e9cfc9aSjacobsusage() { 42*4e9cfc9aSjacobs echo "Usage: $0 { start | stop | refresh } { snmp }" 43*4e9cfc9aSjacobs exit $SMF_EXIT_ERR_FATAL 44*4e9cfc9aSjacobs} 45*4e9cfc9aSjacobs 46*4e9cfc9aSjacobsexecute() { 47*4e9cfc9aSjacobs echo "$*" 48*4e9cfc9aSjacobs $* 49*4e9cfc9aSjacobs 50*4e9cfc9aSjacobs return $? 51*4e9cfc9aSjacobs} 52*4e9cfc9aSjacobs 53*4e9cfc9aSjacobsstart_snmp() { 54*4e9cfc9aSjacobs interval=`/bin/svcprop -p config/interval ${SMF_FMRI} 2>/dev/null` 55*4e9cfc9aSjacobs community=`/bin/svcprop -p config/community ${SMF_FMRI} 2>/dev/null` 56*4e9cfc9aSjacobs network=`/bin/svcprop -p config/network ${SMF_FMRI} 2>/dev/null` 57*4e9cfc9aSjacobs MESSAGE="${MESSAGE_PREFIX}.EnablePrinterScanningViaSNMP" 58*4e9cfc9aSjacobs MESSAGE="${MESSAGE} int32:${interval:-60}" 59*4e9cfc9aSjacobs MESSAGE="${MESSAGE} string:${community:-public}" 60*4e9cfc9aSjacobs MESSAGE="${MESSAGE} string:${network:-0.0.0.0}" 61*4e9cfc9aSjacobs 62*4e9cfc9aSjacobs execute /usr/bin/dbus-send --system --print-reply \ 63*4e9cfc9aSjacobs --dest=${DBUS_DESTINATION} --type=method_call ${OBJECT_PATH} \ 64*4e9cfc9aSjacobs ${MESSAGE} 65*4e9cfc9aSjacobs return $? 66*4e9cfc9aSjacobs} 67*4e9cfc9aSjacobs 68*4e9cfc9aSjacobsstop_snmp() { 69*4e9cfc9aSjacobs MESSAGE="${MESSAGE_PREFIX}.DisablePrinterScanningViaSNMP" 70*4e9cfc9aSjacobs 71*4e9cfc9aSjacobs execute /usr/bin/dbus-send --system --print-reply \ 72*4e9cfc9aSjacobs --dest=${DBUS_DESTINATION} --type=method_call ${OBJECT_PATH} \ 73*4e9cfc9aSjacobs ${MESSAGE} 74*4e9cfc9aSjacobs return $? 75*4e9cfc9aSjacobs} 76*4e9cfc9aSjacobs 77*4e9cfc9aSjacobsrefresh_snmp() { 78*4e9cfc9aSjacobs community=`/bin/svcprop -p config/community ${SMF_FMRI} 2>/dev/null` 79*4e9cfc9aSjacobs network=`/bin/svcprop -p config/network ${SMF_FMRI} 2>/dev/null` 80*4e9cfc9aSjacobs MESSAGE="${MESSAGE_PREFIX}.EnablePrinterScanningViaSNMP" 81*4e9cfc9aSjacobs MESSAGE="${MESSAGE} string:${community:-public}" 82*4e9cfc9aSjacobs MESSAGE="${MESSAGE} string:${network:-0.0.0.0}" 83*4e9cfc9aSjacobs 84*4e9cfc9aSjacobs execute /usr/bin/dbus-send --system --print-reply \ 85*4e9cfc9aSjacobs --dest=${DBUS_DESTINATION} --type=method_call ${OBJECT_PATH} \ 86*4e9cfc9aSjacobs ${MESSAGE} 87*4e9cfc9aSjacobs return $? 88*4e9cfc9aSjacobs} 89*4e9cfc9aSjacobs 90*4e9cfc9aSjacobscase "${METHOD}" in 91*4e9cfc9aSjacobs 'start') 92*4e9cfc9aSjacobs ;; 93*4e9cfc9aSjacobs 'stop') 94*4e9cfc9aSjacobs count=`$SVCS -o STATE hal 2>>/dev/null | grep -c "^online"` 95*4e9cfc9aSjacobs if [ $count -eq 0 ] ; then 96*4e9cfc9aSjacobs exit 0 # if HAL isn't running, there is nothing to do 97*4e9cfc9aSjacobs fi 98*4e9cfc9aSjacobs ;; 99*4e9cfc9aSjacobs 'refresh') 100*4e9cfc9aSjacobs ;; 101*4e9cfc9aSjacobs *) 102*4e9cfc9aSjacobs usage 103*4e9cfc9aSjacobs ;; 104*4e9cfc9aSjacobsesac 105*4e9cfc9aSjacobs 106*4e9cfc9aSjacobscase "${INSTANCE}" in 107*4e9cfc9aSjacobs 'snmp') 108*4e9cfc9aSjacobs ;; 109*4e9cfc9aSjacobs *) 110*4e9cfc9aSjacobs usage 111*4e9cfc9aSjacobs ;; 112*4e9cfc9aSjacobsesac 113*4e9cfc9aSjacobs 114*4e9cfc9aSjacobs${METHOD}_${INSTANCE} 115*4e9cfc9aSjacobsexit_code=$? 116*4e9cfc9aSjacobs 117*4e9cfc9aSjacobsexit $exit_code 118