svc-network-discovery revision 4e9cfc9a015e8ca7d41f7d018c74dc8a692305b3
0N/A#!/bin/sh
0N/A#
0N/A# CDDL HEADER START
0N/A#
0N/A# The contents of this file are subject to the terms of the
0N/A# Common Development and Distribution License (the "License").
0N/A# You may not use this file except in compliance with the License.
0N/A#
0N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
0N/A# or http://www.opensolaris.org/os/licensing.
0N/A# See the License for the specific language governing permissions
0N/A# and limitations under the License.
0N/A#
0N/A# When distributing Covered Code, include this CDDL HEADER in each
0N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
0N/A# If applicable, add the following below this CDDL HEADER, with the
0N/A# fields enclosed by brackets "[]" replaced with your own identifying
0N/A# information: Portions Copyright [yyyy] [name of copyright owner]
0N/A#
0N/A# CDDL HEADER END
0N/A#
0N/A#
0N/A# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
0N/A# Use is subject to license terms.
0N/A
0N/A#
0N/A# ident "%Z%%M% %I% %E% SMI"
0N/A
0N/A. /lib/svc/share/smf_include.sh
0N/A
0N/AMETHOD=${1}
0N/AINSTANCE=${2}
0N/A
0N/ADBUS_DESTINATION="org.freedesktop.Hal"
0N/AMESSAGE_PREFIX="org.freedesktop.Hal.Device.NetworkDiscovery"
0N/AOBJECT_PATH="/org/freedesktop/Hal/devices/network_attached"
0N/ASMF_PROPERTY_GROUP="config"
0N/AHAL_PROPERTY_GROUP="network_discovery"
0N/ASVCS=/usr/bin/svcs
0N/A
0N/Ausage() {
0N/A echo "Usage: $0 { start | stop | refresh } { snmp }"
0N/A exit $SMF_EXIT_ERR_FATAL
0N/A}
0N/A
0N/Aexecute() {
0N/A echo "$*"
0N/A $*
0N/A
0N/A return $?
0N/A}
0N/A
0N/Astart_snmp() {
0N/A interval=`/bin/svcprop -p config/interval ${SMF_FMRI} 2>/dev/null`
0N/A community=`/bin/svcprop -p config/community ${SMF_FMRI} 2>/dev/null`
0N/A network=`/bin/svcprop -p config/network ${SMF_FMRI} 2>/dev/null`
0N/A MESSAGE="${MESSAGE_PREFIX}.EnablePrinterScanningViaSNMP"
0N/A MESSAGE="${MESSAGE} int32:${interval:-60}"
0N/A MESSAGE="${MESSAGE} string:${community:-public}"
0N/A MESSAGE="${MESSAGE} string:${network:-0.0.0.0}"
0N/A
0N/A execute /usr/bin/dbus-send --system --print-reply \
0N/A --dest=${DBUS_DESTINATION} --type=method_call ${OBJECT_PATH} \
0N/A ${MESSAGE}
0N/A return $?
0N/A}
0N/A
0N/Astop_snmp() {
0N/A MESSAGE="${MESSAGE_PREFIX}.DisablePrinterScanningViaSNMP"
0N/A
0N/A execute /usr/bin/dbus-send --system --print-reply \
0N/A --dest=${DBUS_DESTINATION} --type=method_call ${OBJECT_PATH} \
0N/A ${MESSAGE}
0N/A return $?
0N/A}
0N/A
0N/Arefresh_snmp() {
0N/A community=`/bin/svcprop -p config/community ${SMF_FMRI} 2>/dev/null`
0N/A network=`/bin/svcprop -p config/network ${SMF_FMRI} 2>/dev/null`
0N/A MESSAGE="${MESSAGE_PREFIX}.EnablePrinterScanningViaSNMP"
0N/A MESSAGE="${MESSAGE} string:${community:-public}"
0N/A MESSAGE="${MESSAGE} string:${network:-0.0.0.0}"
0N/A
0N/A execute /usr/bin/dbus-send --system --print-reply \
0N/A --dest=${DBUS_DESTINATION} --type=method_call ${OBJECT_PATH} \
0N/A ${MESSAGE}
0N/A return $?
0N/A}
0N/A
0N/Acase "${METHOD}" in
0N/A 'start')
0N/A ;;
0N/A 'stop')
0N/A count=`$SVCS -o STATE hal 2>>/dev/null | grep -c "^online"`
0N/A if [ $count -eq 0 ] ; then
0N/A exit 0 # if HAL isn't running, there is nothing to do
0N/A fi
0N/A ;;
0N/A 'refresh')
0N/A ;;
0N/A *)
0N/A usage
0N/A ;;
0N/Aesac
0N/A
0N/Acase "${INSTANCE}" in
0N/A 'snmp')
0N/A ;;
0N/A *)
0N/A usage
0N/A ;;
0N/Aesac
0N/A
0N/A${METHOD}_${INSTANCE}
0N/Aexit_code=$?
0N/A
0N/Aexit $exit_code
0N/A