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