blob: 548b49acc0f9e19a5bc05b2eca5b13d9dc381ebc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
|
#!/bin/sh
#
# 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
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E% SMI"
DT_CHANGED=0
LOG_FMRI=svc:/system/system-log
CMSD_FMRI=svc:/network/rpc/cde-calendar-manager
BIND_FMRI=svc:/network/rpc/bind
XSERVER_FMRI=svc:/application/x11/x11-server
SENDMAIL_FMRI=svc:/network/smtp:sendmail
PRINTSERVER_FMRI=svc:/application/print/server
RFC1179_FMRI=svc:/application/print/rfc1179
IPPLISTENER_FMRI=svc:/application/print/ipp-listener
TTDB_FMRI=svc:/network/rpc/cde-ttdbserver
DTLOGIN_FMRI=svc:/application/graphical-login/cde-login
WEBCONSOLE_FMRI=svc:/system/webconsole
SMCWBEM_FMRI=svc:/application/management/wbem
usage()
{
prog=`basename $0`
echo "$prog: usage: $prog [ open | limited ]" >&2
exit 2
}
#
# set_property fmri group property value
#
# sets the specified property in the specified property-group, creating
# the group and or property if necessary.
#
set_property()
{
fmri=$1
group=$2
prop=$3
val=$4
if svcprop -qp $group $fmri; then :; else
if svccfg -s $fmri addpg $group application; then :; else
echo "Failed to create property group \"$group\" \c"
echo "for $fmri."
exit 1
fi
fi
if svccfg -s $fmri setprop $group/$prop = boolean: $val; then :; else
echo "Failed to set property $group/$prop for $fmri"
exit 1
fi
}
set_system_log()
{
svcprop -q $LOG_FMRI || return
if [ "$1" = "local" ]; then
val=false
else
val=true
fi
set_property $LOG_FMRI config log_from_remote $val
svcadm refresh $LOG_FMRI
}
set_cmsd()
{
svcprop -q $CMSD_FMRI:default || return
if [ "$1" = "local" ]; then
proto="ticlts"
else
proto="udp"
fi
inetadm -m $CMSD_FMRI:default proto=$proto
svcadm refresh $CMSD_FMRI:default
}
set_rpcbind()
{
svcprop -q $BIND_FMRI || return
if [ "$1" = "local" ]; then
val=true
else
val=false
fi
set_property $BIND_FMRI config local_only $val
svcadm refresh $BIND_FMRI
}
set_xserver() {
svcprop -q $XSERVER_FMRI || return
if [ "$1" = "local" ]; then
val=false
else
val=true
fi
set_property $XSERVER_FMRI options tcp_listen $val
# don't need refresh since x11-server is not an actual service
}
set_sendmail()
{
svcprop -q $SENDMAIL_FMRI || return
if [ "$1" = "local" ]; then
val=true
else
val=false
fi
set_property $SENDMAIL_FMRI config local_only $val
svcadm refresh $SENDMAIL_FMRI
}
set_ttdbserver()
{
svcprop -q $TTDB_FMRI:tcp || return
if [ "$1" = "local" ]; then
val=ticotsord
else
val=tcp
fi
inetadm -m $TTDB_FMRI:tcp proto="$val"
svcadm refresh $TTDB_FMRI:tcp
}
set_dtlogin()
{
svcprop -q $DTLOGIN_FMRI || return
eval args=`svcprop -p dtlogin/args $DTLOGIN_FMRI`
if echo $args | egrep -s udpPort
then
old_port=`echo $args |
sed 's/.*-udpPort [ ]*\([0-9][0-9]*\).*/\1/'`
new_args=`echo $args |
sed 's/\(.*\)-udpPort [0-9][0-9]*\(.*\)/\1\2/'`
else
old_port=-1
new_args=$args
fi
if [ "$1" = "local" ]; then
args="$new_args -udpPort 0"
DT_CHANGED=1
else
# remove '-udpPort 0' argument. Leave intact if port != 0.
if [ $old_port -eq 0 ]; then
args="$new_args"
DT_CHANGED=1
fi
fi
svccfg -s $DTLOGIN_FMRI setprop dtlogin/args = "\"$args\""
svcadm refresh $DTLOGIN_FMRI
}
set_webconsole() {
svcprop -q $WEBCONSOLE_FMRI:console || return
if [ "$1" = "local" ]; then
val=false
else
val=true
fi
set_property $WEBCONSOLE_FMRI options tcp_listen $val
svcadm refresh $WEBCONSOLE_FMRI
}
set_smcwbem() {
svcprop -q $SMCWBEM_FMRI:default || return
if [ "$1" = "local" ]; then
val=false
else
val=true
fi
set_property $SMCWBEM_FMRI options tcp_listen $val
svcadm refresh $SMCWBEM_FMRI
}
if [ $# -ne 1 ]; then
usage
fi
case $1 in
"open")
profile=generic_open.xml
keyword="open"
;;
"limited")
profile=generic_limited_net.xml
keyword="local"
;;
*)
usage
;;
esac
if [ ! -f /var/svc/profile/$profile ]; then
echo "/var/svc/profile/$profile nonexistent. Exiting."
exit 1
fi
#
# set services
#
set_system_log $keyword
set_cmsd $keyword
set_rpcbind $keyword
set_xserver $keyword
set_sendmail $keyword
set_ttdbserver $keyword
set_dtlogin $keyword
set_webconsole $keyword
set_smcwbem $keyword
#
# put the new profile into place, and apply it
#
ln -sf ./$profile /var/svc/profile/generic.xml
svccfg apply /var/svc/profile/generic.xml
if [ $profile = "generic_open.xml" ]
then
# generic_open may not start inetd services on upgraded systems
svccfg apply /var/svc/profile/inetd_generic.xml
# disable rfc1179 and ipp-listener services if server is disabled
if [ "`svcprop -p restarter/state $PRINTSERVER_FMRI:default`" = \
"disabled" ]
then
# need restart since refresh won't pick up new command-line
echo "print/server not enabled: disabling print/rfc1779"
svcadm disable $RFC1179_FMRI:default
echo "print/server not enabled: disabling print/ipp-listener"
svcadm disable $IPPLISTENER_FMRI:default
fi
fi
#
# Make the services aware of the new property values
#
if [ "`svcprop -p restarter/state $LOG_FMRI:default`" = "online" ]
then
# need restart since refresh won't reread properties
echo "restarting syslogd"
svcadm restart $LOG_FMRI:default
fi
if [ "`svcprop -p restarter/state $SENDMAIL_FMRI`" = "online" ]
then
# need restart since refresh won't pick up new command-line
echo "restarting sendmail"
svcadm restart $SENDMAIL_FMRI
fi
if [ "`svcprop -p restarter/state $SMCWBEM_FMRI:default`" = "online" ]
then
# need restart since refresh won't pick up new command-line
echo "restarting wbem"
svcadm restart $SMCWBEM_FMRI:default
fi
if [ $DT_CHANGED -eq 1 ]; then
if [ "`svcprop -p restarter/state $DTLOGIN_FMRI:default`" = "online" ]
then
r="y"
if tty -s ; then
printf \
"dtlogin needs to be restarted. Restart now? [Y] "
read r
fi
if [ "$r" = "" -o "$r" = "y" -o "$r" = "Y" ]; then
# Make sure we survive killing dtlogin...
trap "" 15
svcadm restart $DTLOGIN_FMRI
echo "restarting dtlogin"
else
printf "dtlogin not restarted. "
printf "Restart it to put it in ${keyword}-mode.\n"
fi
fi
fi
|