Home | History | Annotate | Download | only in common_files
      1 #
      2 # Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
      3 # Use is subject to license terms.
      4 #
      5 # CDDL HEADER START
      6 #
      7 # The contents of this file are subject to the terms of the
      8 # Common Development and Distribution License, Version 1.0 only
      9 # (the "License").  You may not use this file except in compliance
     10 # with the License.
     11 #
     12 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     13 # or http://www.opensolaris.org/os/licensing.
     14 # See the License for the specific language governing permissions
     15 # and limitations under the License.
     16 #
     17 # When distributing Covered Code, include this CDDL HEADER in each
     18 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     19 # If applicable, add the following below this CDDL HEADER, with the
     20 # fields enclosed by brackets "[]" replaced with your own identifying
     21 # information: Portions Copyright [yyyy] [name of copyright owner]
     22 #
     23 # CDDL HEADER END
     24 #
     25 # ident	"%Z%%M%	%I%	%E% SMI"
     26 #
     27 
     28 # proc.inetd_install -- common code for inetd.conf entry addition
     29 #
     30 # inetd_init	: call before any other functions
     31 # inetd_add     : if the regular expression specified as argument 1
     32 #		  does not match any line in inetd.conf, add the lines
     33 #		  provided on stdin to the file and restart inetd.conf
     34 # inetd_undo	: call if rest of procedure script fails
     35 # inetd_fini	: call if rest of procedure script succeeds
     36 #
     37 # inetd_init and inetd_add will perform necessary clean-up and
     38 # return a non-zero exit code on failure.
     39 
     40 inetconf=${PKG_INSTALL_ROOT:-/}/etc/inet/inetd.conf
     41 inetold=/tmp/inetd.conf.$$
     42 
     43 inetd_init() {
     44 	cat $inetconf > $inetold
     45 	if [ $? -ne 0 ]; then
     46 		echo "can't create $inetold"
     47 		return 1
     48 	fi
     49 	return 0
     50 }
     51 
     52 inetd_fini() {
     53 	rm -f -- $inetold
     54 	return 0
     55 }
     56 
     57 inetd_undo() {
     58 	cat $inetold > $inetconf
     59 	inetd_fini
     60 }
     61 
     62 inetd_add() {
     63 	grep -s "$1" $inetconf > /dev/null 2>&1 || cat >> $inetconf
     64 	if [ $? -ne 0 ]; then
     65 		echo "can't edit $inetconf"
     66 		inetd_undo
     67 		return 1
     68 	fi
     69 	return 0
     70 }
     71