1 0 stevel #!/sbin/sh 2 0 stevel # 3 0 stevel # CDDL HEADER START 4 0 stevel # 5 0 stevel # The contents of this file are subject to the terms of the 6 2589 hshaw # Common Development and Distribution License (the "License"). 7 2589 hshaw # You may not use this file except in compliance with the License. 8 0 stevel # 9 0 stevel # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 0 stevel # or http://www.opensolaris.org/os/licensing. 11 0 stevel # See the License for the specific language governing permissions 12 0 stevel # and limitations under the License. 13 0 stevel # 14 0 stevel # When distributing Covered Code, include this CDDL HEADER in each 15 0 stevel # file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 0 stevel # If applicable, add the following below this CDDL HEADER, with the 17 0 stevel # fields enclosed by brackets "[]" replaced with your own identifying 18 0 stevel # information: Portions Copyright [yyyy] [name of copyright owner] 19 0 stevel # 20 0 stevel # CDDL HEADER END 21 0 stevel # 22 0 stevel # 23 8823 Truong # Copyright 2009 Sun Microsystems, Inc. All rights reserved. 24 0 stevel # Use is subject to license terms. 25 0 stevel # 26 0 stevel # 27 0 stevel 28 0 stevel . /lib/svc/share/smf_include.sh 29 8823 Truong . /lib/svc/share/ipf_include.sh 30 0 stevel 31 2589 hshaw # SERVICE = parent service name 32 3125 jacobs SERVICE=`echo $SMF_FMRI | /usr/bin/cut -f1,2 -d":"` 33 0 stevel 34 0 stevel case "$1" in 35 0 stevel 'start') 36 0 stevel 37 0 stevel isopts=`/usr/sbin/svccfg <<-EOF 38 2589 hshaw select $SMF_FMRI 39 0 stevel listpg cmd_opts 40 0 stevel 41 0 stevel EOF` 42 0 stevel 43 0 stevel if [ "$isopts" ] ; then 44 0 stevel 45 0 stevel #called by /usr/lib/lpsched; use cmd_opts properties only 46 0 stevel 47 2589 hshaw num_notifiers=`/bin/svcprop -p cmd_opts/num_notifiers $SMF_FMRI` 48 0 stevel 49 0 stevel if [ "$num_notifiers" != "" ] ; then 50 0 stevel OPTS="$OPTS -n $num_notifiers" 51 0 stevel fi 52 0 stevel 53 2589 hshaw num_filters=`/bin/svcprop -p cmd_opts/num_filters $SMF_FMRI` 54 0 stevel 55 0 stevel if [ "$num_filters" != "" ] ; then 56 0 stevel OPTS="$OPTS -f $num_filters" 57 0 stevel fi 58 0 stevel 59 2589 hshaw fd_limit=`/bin/svcprop -p cmd_opts/fd_limit $SMF_FMRI` 60 0 stevel 61 0 stevel if [ "$fd_limit" != "" ] ; then 62 0 stevel OPTS="$OPTS -p $fd_limit" 63 0 stevel fi 64 0 stevel 65 2589 hshaw reserved_fds=`/bin/svcprop -p cmd_opts/reserved_fds $SMF_FMRI` 66 0 stevel 67 0 stevel if [ "$reserved_fds" != "" ] ; then 68 0 stevel OPTS="$OPTS -r $reserved_fds" 69 0 stevel fi 70 0 stevel 71 0 stevel # clear out cmd_opts property group 72 0 stevel 73 0 stevel svccfg <<-EOF 74 2589 hshaw select $SMF_FMRI 75 0 stevel delpg cmd_opts 76 0 stevel 77 0 stevel EOF 78 0 stevel 79 0 stevel else 80 0 stevel 81 0 stevel # We are here through enable; use lpsched properties 82 0 stevel # Check for saved properties 83 0 stevel 84 2589 hshaw num_notifiers=`/bin/svcprop -p lpsched/num_notifiers $SERVICE` 85 0 stevel if [ "$num_notifiers" != "" ] && [ "$num_notifiers" != "0" ] ; then 86 0 stevel OPTS="$OPTS -n $num_notifiers" 87 0 stevel fi 88 0 stevel 89 2589 hshaw num_filters=`/bin/svcprop -p lpsched/num_filters $SERVICE` 90 0 stevel if [ "$num_filters" != "" ] && [ "$num_filters" != "0" ] ; then 91 0 stevel OPTS="$OPTS -f $num_filters" 92 0 stevel fi 93 0 stevel 94 2589 hshaw fd_limit=`/bin/svcprop -p lpsched/fd_limit $SERVICE` 95 0 stevel if [ "$fd_limit" != "" ] && [ "$fd_limit" != "0" ]; then 96 0 stevel OPTS="$OPTS -p $fd_limit" 97 0 stevel fi 98 0 stevel 99 2589 hshaw reserved_fds=`/bin/svcprop -p lpsched/reserved_fds $SERVICE` 100 0 stevel if [ "$reserved_fds" != "" ] && [ "$reserved_fds" != "0" ] ; then 101 0 stevel OPTS="$OPTS -r $reserved_fds" 102 0 stevel fi 103 0 stevel fi 104 0 stevel 105 0 stevel # set temporary or permanent properties from OPTS 106 0 stevel 107 0 stevel [ -f /usr/lib/lp/local/lpsched ] || exit $SMF_EXIT_ERR_CONFIG 108 0 stevel 109 0 stevel /usr/lib/lp/local/lpsched ${OPTS} 110 0 stevel 111 0 stevel ;; 112 0 stevel 113 0 stevel 'stop') 114 0 stevel [ -f /usr/lib/lp/local/lpshut ] || exit $SMF_EXIT_ERR_CONFIG 115 0 stevel 116 0 stevel /usr/lib/lp/local/lpshut 117 0 stevel ;; 118 0 stevel 119 8823 Truong 'ipfilter') 120 8823 Truong FMRI=$2 121 8823 Truong IPP_FMRI="svc:/application/print/ipp-listener:default" 122 8823 Truong RFC1179_FMRI="svc:/application/print/rfc1179:default" 123 8823 Truong IPP_CONF=/etc/apache/httpd-standalone-ipp.conf 124 8823 Truong ip="any" 125 8823 Truong 126 8823 Truong policy=`get_policy $FMRI` 127 8823 Truong 128 8823 Truong file=`fmri_to_file $RFC1179_FMRI $IPF_SUFFIX` 129 8823 Truong echo "# $RFC1179_FMRI" >$file 130 8823 Truong service_is_enabled ${RFC1179_FMRI} 131 8823 Truong if [ $? -eq 0 ]; then 132 8823 Truong rfc_name=`svcprop -p inetd/name ${RFC1179_FMRI} 2>/dev/null` 133 8823 Truong rfc_proto=`svcprop -p inetd/proto ${RFC1179_FMRI} 2>/dev/null | \ 134 8823 Truong sed 's/6/ /'` 135 8823 Truong rfc_port=`$SERVINFO -p -t -s $rfc_name` 136 8823 Truong generate_rules $FMRI $policy $rfc_proto $ip $rfc_port $file 137 8823 Truong fi 138 8823 Truong 139 8823 Truong file=`fmri_to_file $IPP_FMRI $IPF_SUFFIX` 140 8823 Truong echo "# $IPP_FMRI" >$file 141 8823 Truong service_is_enabled ${IPP_FMRI} 142 8823 Truong if [ $? -eq 0 ]; then 143 8823 Truong # 144 8823 Truong # If Listen directives are used, it's possibie to listen on 145 8823 Truong # more than one ports. Process the Port directives only when Listen 146 8823 Truong # directives don't exist. 147 8823 Truong # 148 8823 Truong ipp_ports=`grep '^[ \t]*[^# ]*Listen' ${IPP_CONF} | awk '{print $2}'` 149 8823 Truong 150 8823 Truong if [ -z "$ipp_ports" ]; then 151 8823 Truong ipp_ports=`grep '^[ \t]*[^# ]*Port' ${IPP_CONF} | \ 152 8823 Truong awk '{print $2}' | tail -1` 153 8823 Truong fi 154 8823 Truong 155 8823 Truong for port in $ipp_ports; do 156 8823 Truong generate_rules $FMRI $policy "tcp" $ip $port $file 157 8823 Truong done 158 8823 Truong fi 159 8823 Truong 160 8823 Truong ;; 161 8823 Truong 162 0 stevel *) 163 0 stevel echo "Usage: $0 { start | stop }" 164 0 stevel exit 1 165 0 stevel ;; 166 0 stevel esac 167 0 stevel exit $SMF_EXIT_OK 168