1 #!/usr/bin/ksh 2 # 3 # CDDL HEADER START 4 # 5 # The contents of this file are subject to the terms of the 6 # Common Development and Distribution License (the License). 7 # You may not use this file except in compliance with the License. 8 # 9 # You can obtain a copy of the license at usr/src/CDDL.txt 10 # or http://www.opensolaris.org/os/licensing. 11 # See the License for the specific language governing permissions 12 # and limitations under the License. 13 # 14 # When distributing Covered Code, include this CDDL HEADER in each 15 # file and include the License file at usr/src/CDDL.txt. 16 # If applicable, add the following below this CDDL HEADER, with the 17 # fields enclosed by brackets [] replaced with your own identifying 18 # information: Portions Copyright [yyyy] [name of copyright owner] 19 # 20 # CDDL HEADER END 21 # 22 23 # 24 # Copyright 2006 Sun Microsystems, Inc. All rights reserved. 25 # Use is subject to license terms. 26 # 27 #ident "@(#)samba_smf_register.ksh 1.6 07/06/06 SMI" 28 # 29 # DO NOT EDIT THIS FILE 30 # 31 32 create_xml_samba() 33 { 34 MYDIR=/opt/SUNWscsmb 35 MANIFEST_DIR=/var/svc/manifest/application/sczone-agents 36 37 [ ! -d "${MANIFEST_DIR}" ] && mkdir -p ${MANIFEST_DIR} 38 39 cat > ${MANIFEST_DIR}/${RS}.xml <<-EOF 40 <?xml version="1.0"?> 41 <!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1"> 42 43 <!-- 44 Copyright 2006 Sun Microsystems, Inc. All rights reserved. 45 Use is subject to license terms. 46 --> 47 48 <service_bundle type='manifest' name='${RS}'> 49 50 <service 51 name='application/sczone-agents' 52 type='service' 53 version='1'> 54 55 <instance name='${RS}' enabled='false'> 56 57 <!-- 58 Dependencies 59 --> 60 61 <dependency name='${COMPONENT}_services' 62 grouping='require_all' 63 restart_on='none' 64 type='service'> 65 <service_fmri value='svc:/milestone/multi-user-server'/> 66 <service_fmri value='svc:/network/loopback'/> 67 <service_fmri value='svc:/network/physical'/> 68 </dependency> 69 70 <dependency name='${COMPONENT}_paths' 71 grouping='require_all' 72 restart_on='none' 73 type='path'> 74 <service_fmri value='file://${BINDIR}'/> 75 <service_fmri value='file://${SBINDIR}'/> 76 <service_fmri value='file://${CFGDIR}'/> 77 </dependency> 78 79 <exec_method 80 type='method' 81 name='start' 82 exec='${MYDIR}/bin/control_samba start ${COMPONENT} ${RS}' 83 timeout_seconds='300' > 84 <method_context project='${PROJECT}' > 85 <method_credential user='${USERID}' /> 86 </method_context> 87 </exec_method> 88 89 <exec_method 90 type='method' 91 name='stop' 92 exec='${MYDIR}/bin/control_samba stop ${COMPONENT} ${RS}' 93 timeout_seconds='300' > 94 <method_context project='${PROJECT}'> 95 <method_credential user='${USERID}' /> 96 </method_context> 97 </exec_method> 98 99 <property_group name='parameters' type='general'> 100 <propval name='RESOURCE' type='astring' value='${RS}'/> 101 <propval name='RESOURCEGROUP' type='astring' value='${RG}'/> 102 <propval name='SERVICES' type='astring' value='${SERVICES}'/> 103 <propval name='BINDIR' type='astring' value='${BINDIR}'/> 104 <propval name='SBINDIR' type='astring' value='${SBINDIR}'/> 105 <propval name='CFGDIR' type='astring' value='${CFGDIR}'/> 106 <propval name='LDPATH' type='astring' value='${LDPATH}'/> 107 <propval name='SAMBA_FMUSER' type='astring' value='${FMUSER}'/> 108 <propval name='SAMBA_LOGDIR' type='astring' value='${SAMBA_LOGDIR}'/> 109 <propval name='SAMBA_FMPASS' type='astring' value='${SAMBA_FMPASS}'/> 110 <propval name='SAMBA_FMDOMAIN' type='astring' value='${SAMBA_FMDOMAIN}'/> 111 <propval name='SAMBA_FMRESOURCE' type='astring' value='scmondir'/> 112 <propval name='LHOST' type='astring' value='${LHOST}'/> 113 <propval name='PROBE_TIMEOUT' type='astring' value='${TIMEOUT}'/> 114 </property_group> 115 116 <property_group name='startd' type='framework'> 117 <propval name='ignore_error' type='astring' value='core'/> 118 </property_group> 119 120 </instance> 121 122 <stability value='Evolving' /> 123 124 <template> 125 <common_name> 126 <loctext xml:lang='C'> 127 Samba 128 </loctext> 129 </common_name> 130 </template> 131 </service> 132 133 </service_bundle> 134 135 EOF 136 } 137 138 create_xml_winbind() 139 { 140 MYDIR=/opt/SUNWscsmb 141 MANIFEST_DIR=/var/svc/manifest/application/sczone-agents 142 143 [ ! -d "${MANIFEST_DIR}" ] && mkdir -p ${MANIFEST_DIR} 144 145 cat > ${MANIFEST_DIR}/${RS}.xml <<-EOF 146 <?xml version="1.0"?> 147 <!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1"> 148 149 <!-- 150 Copyright 2006 Sun Microsystems, Inc. All rights reserved. 151 Use is subject to license terms. 152 --> 153 154 <service_bundle type='manifest' name='${RS}'> 155 156 <service 157 name='application/sczone-agents' 158 type='service' 159 version='1'> 160 161 <instance name='${RS}' enabled='false'> 162 163 <!-- 164 Dependencies 165 --> 166 167 <dependency name='${COMPONENT}_services' 168 grouping='require_all' 169 restart_on='none' 170 type='service'> 171 <service_fmri value='svc:/milestone/multi-user-server'/> 172 <service_fmri value='svc:/network/loopback'/> 173 <service_fmri value='svc:/network/physical'/> 174 </dependency> 175 176 <dependency name='${COMPONENT}_paths' 177 grouping='require_all' 178 restart_on='none' 179 type='path'> 180 <service_fmri value='file://${BINDIR}'/> 181 <service_fmri value='file://${SBINDIR}'/> 182 <service_fmri value='file://${CFGDIR}'/> 183 </dependency> 184 185 <exec_method 186 type='method' 187 name='start' 188 exec='${MYDIR}/bin/control_samba start ${COMPONENT} ${RS}' 189 timeout_seconds='300' > 190 <method_context project='${PROJECT}' > 191 <method_credential user='${USERID}' /> 192 </method_context> 193 </exec_method> 194 195 <exec_method 196 type='method' 197 name='stop' 198 exec='${MYDIR}/bin/control_samba stop ${COMPONENT} ${RS}' 199 timeout_seconds='300' > 200 <method_context project='${PROJECT}'> 201 <method_credential user='${USERID}' /> 202 </method_context> 203 </exec_method> 204 205 <property_group name='parameters' type='general'> 206 <propval name='RESOURCE' type='astring' value='${RS}'/> 207 <propval name='RESOURCEGROUP' type='astring' value='${RG}'/> 208 <propval name='SERVICES' type='astring' value='${SERVICES}'/> 209 <propval name='BINDIR' type='astring' value='${BINDIR}'/> 210 <propval name='SBINDIR' type='astring' value='${SBINDIR}'/> 211 <propval name='CFGDIR' type='astring' value='${CFGDIR}'/> 212 <propval name='SAMBA_FMUSER' type='astring' value='${FMUSER}'/> 213 <propval name='LDPATH' type='astring' value='${LDPATH}'/> 214 <propval name='WINBIND_DISCACHE' type='astring' value='${WINBIND_DISCACHE}'/> 215 <propval name='WINBIND_SINGLEMODE' type='astring' value='${WINBIND_SINGLEMODE}'/> 216 </property_group> 217 218 <property_group name='startd' type='framework'> 219 <propval name='ignore_error' type='astring' value='core'/> 220 </property_group> 221 222 </instance> 223 224 <stability value='Evolving' /> 225 226 <template> 227 <common_name> 228 <loctext xml:lang='C'> 229 Samba 230 </loctext> 231 </common_name> 232 </template> 233 </service> 234 235 </service_bundle> 236 237 EOF 238 } 239 240 . ${1} 241 COMPONENT=${2} 242 USERID=root 243 244 if [ "${COMPONENT}" = "winbind" ] 245 then 246 # If amending WINBIND_DISCACHE or WINBIND_SINGLEMODE, check samba_register 247 # Note, samba_register has WINBIND_DISCACHE="-N" 248 # and samba_smf_register has WINBIND_DISCACHE="-n" 249 250 WINBIND_DISCACHE=`/usr/bin/echo ${WINBIND_DISCACHE} | /usr/bin/tr -s '[:lower:]' '[:upper:]'` 251 WINBIND_SINGLEMODE=`/usr/bin/echo ${WINBIND_SINGLEMODE} | /usr/bin/tr -s '[:lower:]' '[:upper:]'` 252 253 if [ "${WINBIND_DISCACHE}" = "TRUE" ] 254 then 255 WINBIND_DISCACHE="-n" 256 else 257 WINBIND_DISCACHE="" 258 fi 259 260 if [ "${WINBIND_SINGLEMODE}" = "TRUE" ] 261 then 262 WINBIND_SINGLEMODE="-Y" 263 else 264 WINBIND_SINGLEMODE="" 265 fi 266 fi 267 268 SERVICES=`/usr/bin/echo ${SERVICES} | /usr/bin/tr -d " " | /usr/bin/tr "," "_"` 269 270 create_xml_${COMPONENT} 271 272 /usr/bin/printf "${MANIFEST_DIR}/${RS}.xml successfully created\n" 273 274 if /usr/sbin/svccfg validate ${MANIFEST_DIR}/${RS}.xml; then 275 /usr/bin/printf "${MANIFEST_DIR}/${RS}.xml successfully validated\n" 276 else 277 /usr/bin/printf "${MANIFEST_DIR}/${RS}.xml validation failed\n" 278 exit 1 279 fi 280 281 if /usr/sbin/svccfg import ${MANIFEST_DIR}/${RS}.xml; then 282 /usr/bin/printf "${MANIFEST_DIR}/${RS}.xml successfully imported\n" 283 else 284 /usr/bin/printf "${MANIFEST_DIR}/${RS}.xml import failed\n" 285 exit 1 286 fi 287 288 exit 0 289