xref: /illumos-gate/usr/src/cmd/initpkg/rc1.sh (revision bbf21555)
17c478bd9Sstevel@tonic-gate#!/sbin/sh
27c478bd9Sstevel@tonic-gate#
37c478bd9Sstevel@tonic-gate# CDDL HEADER START
47c478bd9Sstevel@tonic-gate#
57c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the
67c478bd9Sstevel@tonic-gate# Common Development and Distribution License, Version 1.0 only
77c478bd9Sstevel@tonic-gate# (the "License").  You may not use this file except in compliance
87c478bd9Sstevel@tonic-gate# with the License.
97c478bd9Sstevel@tonic-gate#
107c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
117c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
127c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
137c478bd9Sstevel@tonic-gate# and limitations under the License.
147c478bd9Sstevel@tonic-gate#
157c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
167c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
177c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
187c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
197c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
207c478bd9Sstevel@tonic-gate#
217c478bd9Sstevel@tonic-gate# CDDL HEADER END
227c478bd9Sstevel@tonic-gate#
237c478bd9Sstevel@tonic-gate#
247c478bd9Sstevel@tonic-gate# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T.
257c478bd9Sstevel@tonic-gate# All rights reserved.
267c478bd9Sstevel@tonic-gate#
277c478bd9Sstevel@tonic-gate#
287c478bd9Sstevel@tonic-gate# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
297c478bd9Sstevel@tonic-gate# Use is subject to license terms.
307c478bd9Sstevel@tonic-gate#
317c478bd9Sstevel@tonic-gate
327c478bd9Sstevel@tonic-gate# "Run Commands" executed when the system is changing to init state 1
337c478bd9Sstevel@tonic-gate
347c478bd9Sstevel@tonic-gateif [ -z "$SMF_RESTARTER" ]; then
35*bbf21555SRichard Lowe	echo "Cannot be run outside smf(7)"
367c478bd9Sstevel@tonic-gate	exit 1
377c478bd9Sstevel@tonic-gatefi
387c478bd9Sstevel@tonic-gate
397c478bd9Sstevel@tonic-gate. /lib/svc/share/smf_include.sh
407c478bd9Sstevel@tonic-gate
417c478bd9Sstevel@tonic-gatePATH=/usr/sbin:/usr/bin
427c478bd9Sstevel@tonic-gate
437c478bd9Sstevel@tonic-gateaction=$1
447c478bd9Sstevel@tonic-gate
457c478bd9Sstevel@tonic-gate# Export boot parameters to rc scripts
467c478bd9Sstevel@tonic-gate
477c478bd9Sstevel@tonic-gateset -- `/usr/bin/who -r`
487c478bd9Sstevel@tonic-gate
497c478bd9Sstevel@tonic-gate_INIT_RUN_LEVEL="$7"	# Current run-level
507c478bd9Sstevel@tonic-gate_INIT_RUN_NPREV="$8"	# Number of times previously at current run-level
517c478bd9Sstevel@tonic-gate_INIT_PREV_LEVEL="$9"	# Previous run-level
527c478bd9Sstevel@tonic-gate
537c478bd9Sstevel@tonic-gateset -- `/usr/bin/uname -a`
547c478bd9Sstevel@tonic-gate
557c478bd9Sstevel@tonic-gate_INIT_UTS_SYSNAME="$1"  # Operating system name (uname -s)
567c478bd9Sstevel@tonic-gate_INIT_UTS_NODENAME="$2" # Node name (uname -n)
577c478bd9Sstevel@tonic-gate_INIT_UTS_RELEASE="$3"  # Operating system release (uname -r)
587c478bd9Sstevel@tonic-gate_INIT_UTS_VERSION="$4"  # Operating system version (uname -v)
597c478bd9Sstevel@tonic-gate_INIT_UTS_MACHINE="$5"  # Machine class (uname -m)
607c478bd9Sstevel@tonic-gate_INIT_UTS_ISA="$6"      # Instruction set architecture (uname -p)
617c478bd9Sstevel@tonic-gate_INIT_UTS_PLATFORM="$7" # Platform string (uname -i)
627c478bd9Sstevel@tonic-gate
637c478bd9Sstevel@tonic-gateexport _INIT_RUN_LEVEL _INIT_RUN_NPREV _INIT_PREV_LEVEL \
647c478bd9Sstevel@tonic-gate    _INIT_UTS_SYSNAME _INIT_UTS_NODENAME _INIT_UTS_RELEASE _INIT_UTS_VERSION \
657c478bd9Sstevel@tonic-gate    _INIT_UTS_MACHINE _INIT_UTS_ISA _INIT_UTS_PLATFORM
667c478bd9Sstevel@tonic-gate
677c478bd9Sstevel@tonic-gate. /lib/svc/share/fs_include.sh
687c478bd9Sstevel@tonic-gate
697c478bd9Sstevel@tonic-gatecase $action in
707c478bd9Sstevel@tonic-gate	stop)
717c478bd9Sstevel@tonic-gate		>/etc/nologin
727c478bd9Sstevel@tonic-gate
737c478bd9Sstevel@tonic-gate		# All remote filesystem services must be explicitly disabled
747c478bd9Sstevel@tonic-gate		# at init run level 1, and at the single-user milestone.
757c478bd9Sstevel@tonic-gate
767c478bd9Sstevel@tonic-gate		if [ -d /etc/rc1.d ]; then
777c478bd9Sstevel@tonic-gate			for f in /etc/rc1.d/K*; do
787c478bd9Sstevel@tonic-gate				if [ ! -s $f ]; then
797c478bd9Sstevel@tonic-gate					continue;
807c478bd9Sstevel@tonic-gate				fi
817c478bd9Sstevel@tonic-gate
827c478bd9Sstevel@tonic-gate				case $f in
837c478bd9Sstevel@tonic-gate					*.sh)	/lib/svc/bin/lsvcrun -s $f stop
847c478bd9Sstevel@tonic-gate						;;
857c478bd9Sstevel@tonic-gate					*)	/lib/svc/bin/lsvcrun $f stop ;;
867c478bd9Sstevel@tonic-gate				esac
877c478bd9Sstevel@tonic-gate			done
887c478bd9Sstevel@tonic-gate		fi
897c478bd9Sstevel@tonic-gate
907c478bd9Sstevel@tonic-gate		;;
917c478bd9Sstevel@tonic-gate
927c478bd9Sstevel@tonic-gate	start)
937c478bd9Sstevel@tonic-gate		if [ -d /etc/rc1.d ]; then
947c478bd9Sstevel@tonic-gate			for f in /etc/rc1.d/S*; do
957c478bd9Sstevel@tonic-gate				if [ ! -s $f ]; then
967c478bd9Sstevel@tonic-gate					continue;
977c478bd9Sstevel@tonic-gate				fi
987c478bd9Sstevel@tonic-gate
997c478bd9Sstevel@tonic-gate				case $f in
1007c478bd9Sstevel@tonic-gate					*.sh)	/lib/svc/bin/lsvcrun -s $f start
1017c478bd9Sstevel@tonic-gate						;;
1027c478bd9Sstevel@tonic-gate					*)	/lib/svc/bin/lsvcrun $f start ;;
1037c478bd9Sstevel@tonic-gate				esac
1047c478bd9Sstevel@tonic-gate			done
1057c478bd9Sstevel@tonic-gate		fi
1067c478bd9Sstevel@tonic-gate
1077c478bd9Sstevel@tonic-gate		;;
1087c478bd9Sstevel@tonic-gate
1097c478bd9Sstevel@tonic-gate	*)
1107c478bd9Sstevel@tonic-gate		echo "Usage: $0 { start | stop }"
1117c478bd9Sstevel@tonic-gate		exit $SMF_EXIT_ERR_CONFIG
1127c478bd9Sstevel@tonic-gate		;;
1137c478bd9Sstevel@tonic-gateesac
1147c478bd9Sstevel@tonic-gate
1157c478bd9Sstevel@tonic-gateexit $SMF_EXIT_OK
116