Home | History | Annotate | Download | only in lpsched
      1 #!/sbin/sh
      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/OPENSOLARIS.LICENSE
     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/OPENSOLARIS.LICENSE.
     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 # Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
     24 # Use is subject to license terms.
     25 #
     26 #
     27 
     28 . /lib/svc/share/smf_include.sh
     29 . /lib/svc/share/ipf_include.sh
     30 
     31 # SERVICE = parent service name
     32 SERVICE=`echo $SMF_FMRI | /usr/bin/cut -f1,2 -d":"`
     33 
     34 case "$1" in
     35 'start')
     36 
     37 isopts=`/usr/sbin/svccfg <<-EOF
     38 	select $SMF_FMRI
     39 	listpg cmd_opts
     40 
     41 	EOF`
     42 
     43 if [ "$isopts" ] ; then
     44 
     45 #called by /usr/lib/lpsched; use cmd_opts properties only
     46 
     47 	num_notifiers=`/bin/svcprop -p cmd_opts/num_notifiers $SMF_FMRI`
     48 
     49 	if [ "$num_notifiers" != "" ] ; then
     50 		OPTS="$OPTS -n $num_notifiers" 
     51 	fi
     52 
     53 	num_filters=`/bin/svcprop -p cmd_opts/num_filters $SMF_FMRI`
     54 
     55 	if [ "$num_filters" != "" ]  ; then
     56 		OPTS="$OPTS -f $num_filters"
     57 	fi
     58 
     59 	fd_limit=`/bin/svcprop -p cmd_opts/fd_limit $SMF_FMRI`
     60 
     61 	if [ "$fd_limit" != "" ]  ; then
     62 		OPTS="$OPTS -p $fd_limit"
     63 	fi
     64 
     65 	reserved_fds=`/bin/svcprop -p cmd_opts/reserved_fds $SMF_FMRI`
     66 
     67 	if [ "$reserved_fds" != "" ] ; then
     68 		OPTS="$OPTS -r $reserved_fds"
     69 	fi
     70 
     71 # clear out cmd_opts property group
     72 
     73 	svccfg <<-EOF
     74 	select $SMF_FMRI
     75 	delpg cmd_opts
     76 
     77 	EOF
     78 
     79 else
     80 
     81 # We are here through enable; use lpsched properties
     82 # Check for saved properties
     83 
     84 	num_notifiers=`/bin/svcprop -p lpsched/num_notifiers $SERVICE`
     85 	if [ "$num_notifiers" != "" ] && [ "$num_notifiers" != "0" ] ; then
     86 		OPTS="$OPTS -n $num_notifiers"
     87 	fi
     88 
     89 	num_filters=`/bin/svcprop -p lpsched/num_filters $SERVICE`
     90 	if [ "$num_filters" != "" ] && [ "$num_filters" != "0" ] ; then
     91 		OPTS="$OPTS -f $num_filters"
     92 	fi
     93 
     94 	fd_limit=`/bin/svcprop -p lpsched/fd_limit $SERVICE`
     95 	if [ "$fd_limit" != "" ]  && [ "$fd_limit" != "0" ]; then
     96 		OPTS="$OPTS -p $fd_limit"
     97 	fi
     98 
     99 	reserved_fds=`/bin/svcprop -p lpsched/reserved_fds $SERVICE`
    100 	if [ "$reserved_fds" != "" ] && [ "$reserved_fds" != "0" ] ; then
    101 		OPTS="$OPTS -r $reserved_fds"
    102 	fi
    103 fi
    104 
    105 # set temporary or permanent properties from OPTS
    106 
    107 	[ -f /usr/lib/lp/local/lpsched ] || exit $SMF_EXIT_ERR_CONFIG
    108 
    109 	/usr/lib/lp/local/lpsched ${OPTS}
    110 
    111 	;;
    112 
    113 'stop')
    114 	[ -f /usr/lib/lp/local/lpshut ] || exit $SMF_EXIT_ERR_CONFIG
    115 
    116 	/usr/lib/lp/local/lpshut
    117 	;;
    118 
    119 'ipfilter')
    120 	FMRI=$2
    121 	IPP_FMRI="svc:/application/print/ipp-listener:default"
    122 	RFC1179_FMRI="svc:/application/print/rfc1179:default"
    123 	IPP_CONF=/etc/apache/httpd-standalone-ipp.conf
    124 	ip="any"
    125 
    126 	policy=`get_policy $FMRI`
    127 
    128 	file=`fmri_to_file $RFC1179_FMRI $IPF_SUFFIX`
    129 	echo "# $RFC1179_FMRI" >$file
    130         service_is_enabled ${RFC1179_FMRI}
    131         if [ $? -eq 0 ]; then
    132 		rfc_name=`svcprop -p inetd/name ${RFC1179_FMRI} 2>/dev/null`
    133 		rfc_proto=`svcprop -p inetd/proto ${RFC1179_FMRI} 2>/dev/null | \
    134 		    sed 's/6/ /'`
    135 		rfc_port=`$SERVINFO -p -t -s $rfc_name`
    136 		generate_rules $FMRI $policy $rfc_proto $ip $rfc_port $file
    137         fi
    138 
    139 	file=`fmri_to_file $IPP_FMRI $IPF_SUFFIX`
    140 	echo "# $IPP_FMRI" >$file
    141         service_is_enabled ${IPP_FMRI}
    142         if [ $? -eq 0 ]; then
    143 		#
    144 		# If Listen directives are used, it's possibie to listen on 
    145 		# more than one ports. Process the Port directives only when Listen
    146 		# directives don't exist.
    147 		#
    148 		ipp_ports=`grep '^[ \t]*[^# ]*Listen' ${IPP_CONF} | awk '{print $2}'`
    149 
    150 		if [ -z "$ipp_ports" ]; then
    151 			ipp_ports=`grep '^[ \t]*[^# ]*Port' ${IPP_CONF} | \
    152 			    awk '{print $2}' | tail -1`
    153 		fi
    154 
    155 		for port in $ipp_ports; do
    156 			generate_rules $FMRI $policy "tcp" $ip $port $file
    157 		done
    158 	fi
    159 
    160 	;;
    161 
    162 *)
    163 	echo "Usage: $0 { start | stop }"
    164 	exit 1
    165 	;;
    166 esac
    167 exit $SMF_EXIT_OK
    168