# # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # Hammerhead: SysV-init / SMF run-level scripts removed. # init(8) is now /sbin/zyginit; /sbin/rc[0-3S], /etc/inittab, /etc/init.d/, # /etc/rc[0-3S].d/, and the sysetup/uucp init scripts are gone — zyginit # services own boot orchestration. What remains here is the boot-time # filesystem and swap plumbing that zyginit's services invoke: # mountall, umountall, swapadd, shutdown, plus the static configs # (vfstab, nscd.conf, crypt.conf) and /etc/dfs/dfstab. SHFILES= dfstab vfstab CPFILES= mountall shutdown swapadd umountall ALL= $(SHFILES) $(CPFILES) CLOBBERFILES= $(ALL) include ../Makefile.cmd ETCDFSD= $(ROOTETC)/dfs SBINF= mountall shutdown swapadd umountall USRSBINF= mountall umountall ETCTABS= vfstab nscd.conf security/crypt.conf DFSTAB= dfstab SBINETC= mountall shutdown swapadd umountall USRSBINETC= FILEMODE= 0744 ROOTSBINF= $(SBINF:%=$(ROOTSBIN)/%) ROOTUSRSBINF= $(USRSBINF:%=$(ROOTUSRSBIN)/%) ROOTETCTABS= $(ETCTABS:%=$(ROOTETC)/%) ROOTDFSTAB= $(DFSTAB:%=$(ETCDFSD)/%) SYMSBINF= $(SBINETC:%=$(ROOTETC)/%) SYMUSRSBINF= $(USRSBINETC:%=$(ROOTETC)/%) $(ROOTETC)/vfstab : FILEMODE = 0644 $(ROOTETC)/nscd.conf : FILEMODE = 0644 $(ROOTETC)/security/crypt.conf : FILEMODE = 0644 $(ROOTDFSTAB) : FILEMODE = 0644 $(ROOTSBIN)/mountall : FILEMODE = 0555 $(ROOTUSRSBIN)/mountall : FILEMODE = 0555 $(ROOTSBIN)/umountall : FILEMODE = 0555 $(ROOTUSRSBIN)/umountall : FILEMODE = 0555 $(ROOTSBIN)/shutdown : FILEMODE = 0755 $(ETCDFSD)/% : % $(INS.file) .KEEP_STATE: all: $(ALL) $(SYMSBINF): $(RM) $@; $(SYMLINK) ../sbin/$(@F) $@ $(SYMUSRSBINF): $(RM) $@; $(SYMLINK) ../usr/sbin/$(@F) $@ $(SHFILES): sh $@.sh $(ROOT) install: $(ALL) ins_all # Hammerhead: /sbin/shutdown → ../../sbin/shutdown compat symlink ROOTUSRSBIN_SHUTDOWN = $(ROOTUSRSBIN)/shutdown $(ROOTUSRSBIN_SHUTDOWN): $(RM) $@; $(SYMLINK) ../../sbin/shutdown $@ ins_all : $(ROOTSBINF) $(ROOTUSRSBINF) $(ROOTETCTABS) \ $(ROOTDFSTAB) $(SYMSBINF) $(SYMUSRSBINF) $(ROOTUSRSBIN_SHUTDOWN) FRC: clean lint: include ../Makefile.targ #!/sbin/sh # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T # All Rights Reserved # # Copyright 2006 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # case "$MACH" in "u3b2"|"sparc"|"i386"|"ppc" ) echo " # Do not modify this file directly. # Use the sharemgr(8) command for all share management # This file is reconstructed and only maintained for backward # compatibility. Configuration lines could be lost. # # share [-F fstype] [ -o options] [-d \"\"] [resource] # .e.g, # share -F nfs -o rw=engineering -d \"home dirs\" /export/home2 " >dfstab ;; * ) echo "Unknown architecture." exit 1 ;; esac #!/sbin/sh # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License, Version 1.0 only # (the "License"). You may not use this file except in compliance # with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # Copyright 2015 Nexenta Systems, Inc. All rights reserved. # # Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T # All Rights Reserved # usage () { if [ -n "$1" ]; then echo "mountall: $1" 1>&2 fi echo "Usage:\nmountall [-F FSType] [-l|-r|-g] [file_system_table]" 1>&2 exit 2 } PATH=/bin:/sbin:/usr/bin:/usr/sbin TYPES=all FSTAB=/etc/vfstab err=0 # Clear these in case they were already set in our environment. FSType= GFLAG= RFLAG= LFLAG= SFLAG= RemoteFSTypes= # checkmessage "fsck_device | mount_point" # # Simple auxilary routine to the shell function checkfs. Prints out # instructions for a manual file system check before entering the shell. # checkmessage() { echo "" > /dev/console if [ "$1" != "" ] ; then echo "WARNING - Unable to repair one or more \c" > /dev/console echo "of the following filesystem(s):" > /dev/console echo "\t$1" > /dev/console else echo "WARNING - Unable to repair one or more filesystems." \ > /dev/console fi echo "Run fsck manually (fsck filesystem...)." > /dev/console echo "" > /dev/console } # # checkfs raw_device fstype mountpoint # # Check the file system specified. The return codes from fsck have the # following meanings. # 0 - file system is unmounted and okay # 32 - file system is unmounted and needs checking (fsck -m only) # 33 - file system is already mounted # 34 - cannot stat device # 36 - uncorrectable errors detected - terminate normally (4.1 code 8) # 37 - a signal was caught during processing (4.1 exit 12) # 39 - uncorrectable errors detected - terminate rightaway (4.1 code 8) # 40 - for root, same as 0 (used by rcS to remount root) # checkfs() { /sbin/fsck -F $2 -m $1 >/dev/null 2>&1 if [ $? -ne 0 ] then # Determine fsck options by file system type case "$2" in ufs) foptions="-o p" ;; *) foptions="-y" ;; esac echo "The "$3" file system ("$1") is being checked." /sbin/fsck -F $2 ${foptions} $1 case $? in 0|40) # file system OK ;; *) # couldn't fix the file system echo "/sbin/fsck failed with exit code "$?"." checkmessage "$1" ;; esac fi } # # Used to save an entry that we will want to mount either in # a command file or as a mount point list. # # saveentry fstype options special mountp # saveentry() { if [ "$ALTM" ]; then echo "/sbin/mount -F $1 $2 $3 $4" >> $ALTM else mntlist="$mntlist $4" fi } # Do the passed mount options include "global"? isglobal() { case ",${1}," in *,global,*) return 0 ;; esac return 1 } # Is the passed fstype a "remote" one? # Essentially: /bin/grep "^$1" /etc/dfs/fstypes isremote() { for t in $RemoteFSTypes do [ "$t" = "$1" ] && return 0 done return 1 } # Get list of remote FS types (just once) RemoteFSTypes=`while read t junk; do echo $t; done < /etc/dfs/fstypes` # # Process command line args # while getopts ?grlsF: c do case $c in g) GFLAG="g";; r) RFLAG="r";; l) LFLAG="l";; s) SFLAG="s";; F) FSType="$OPTARG"; if [ "$TYPES" = "one" ] then echo "mountall: more than one FSType specified" exit 2 fi TYPES="one"; case $FSType in ?????????*) echo "mountall: FSType $FSType exceeds 8 characters" exit 2 esac ;; \?) usage "";; esac done shift `/bin/expr $OPTIND - 1` # get past the processed args if [ $# -gt 1 ]; then usage "multiple arguments not supported" fi # get file system table name and make sure file exists if [ $# = 1 ]; then case $1 in "-") FSTAB="" ;; *) FSTAB=$1 ;; esac fi # # if an alternate vfstab file is used or serial mode is specified, then # use a mount command file # if [ $# = 1 -o "$SFLAG" ]; then ALTM=/var/tmp/mount$$ rm -f $ALTM fi if [ "$FSTAB" != "" -a ! -s "$FSTAB" ] then echo "mountall: file system table ($FSTAB) not found" exit 1 fi # # Check for incompatible args # if [ "$GFLAG" = "g" -a "$RFLAG$LFLAG" != "" -o \ "$RFLAG" = "r" -a "$GFLAG$LFLAG" != "" -o \ "$LFLAG" = "l" -a "$RFLAG$GFLAG" != "" ] then usage "options -g, -r and -l are mutually exclusive" fi if [ "$LFLAG" = "l" -a -n "$FSType" ]; then # remote FSType not allowed isremote "$FSType" && usage "option -l and FSType are incompatible" fi if [ "$RFLAG" = "r" -a -n "$FSType" ]; then # remote FSType required isremote "$FSType" || usage "option -r and FSType are incompatible" fi # file-system-table format: # # column 1: special- block special device or resource name # column 2: fsckdev- char special device for fsck # column 3: mountp- mount point # column 4: fstype- File system type # column 5: fsckpass- number if to be checked automatically # column 6: automnt- yes/no for automatic mount # column 7: mntopts- -o specific mount options # White-space separates columns. # Lines beginning with \"#\" are comments. Empty lines are ignored. # a '-' in any field is a no-op. # # Read FSTAB, fsck'ing appropriate filesystems: # exec < $FSTAB while read special fsckdev mountp fstype fsckpass automnt mntopts do case $special in '#'* | '') # Ignore comments, empty lines continue ;; '-') # Ignore no-action lines continue esac if [ "$automnt" != "yes" ]; then continue fi if [ "$FSType" -a "$FSType" != "$fstype" ]; then # ignore different fstypes continue fi # The -g option is not in the man page, but according to # PSARC/1998/255 it's used by Sun Cluster (via contract) to # mount disk-based filesystems with the "global" option. # Also, the -l option now skips those "global" mounts. # # Note: options -g -l -r are mutually exclusive # if [ -n "$GFLAG" ]; then # Mount "local" filesystems that have # the "global" option in mntopts. isremote "$fstype" && continue isglobal "$mntopts" || continue fi if [ -n "$LFLAG" ]; then # Mount "local" filesystems, excluding # those marked "global". isremote "$fstype" && continue isglobal "$mntopts" && continue fi if [ -n "$RFLAG" ]; then # Mount "remote" filesystems. isremote "$fstype" || continue fi if [ "$fstype" = "-" ]; then echo "mountall: FSType of $special cannot be identified" 1>&2 continue fi if [ "$ALTM" -a "$mntopts" != "-" ]; then OPTIONS="-o $mntopts" # Use mount options if any else OPTIONS="" fi # # Ignore entries already mounted # /bin/grep " $mountp " /etc/mnttab >/dev/null 2>&1 && continue # # Can't fsck if no fsckdev is specified # if [ "$fsckdev" = "-" ]; then saveentry $fstype "$OPTIONS" $special $mountp continue fi # # For fsck purposes, we make a distinction between file systems # that have a /usr/lib/fs//fsckall script and those # that don't. For those that do, just keep a list of them # and pass the list to the fsckall script for that file # file system type. # if [ -x /usr/lib/fs/$fstype/fsckall ]; then # # add fstype to the list of fstypes for which # fsckall should be called, if it's not already # in the list. # found=no if [ "$fsckall_fstypes" != "" ] ; then for fst in $fsckall_fstypes; do if [ "$fst" = "$fstype" ] ; then found=yes break fi done fi if [ $found = no ] ; then fsckall_fstypes="$fsckall_fstypes ${fstype}" fi # # add the device to the name of devices to be passed # to the fsckall program for this file system type # cmd="${fstype}_fscklist=\"\$${fstype}_fscklist $fsckdev\"" eval $cmd saveentry $fstype "$OPTIONS" $special $mountp continue fi # # fsck everything else: # # fsck -m simply returns true if the filesystem is suitable for # mounting. # /sbin/fsck -m -F $fstype $fsckdev >/dev/null 2>&1 case $? in 0|40) saveentry $fstype "$OPTIONS" $special $mountp continue ;; 32) checkfs $fsckdev $fstype $mountp saveentry $fstype "$OPTIONS" $special $mountp continue ;; 33) # already mounted echo "$special already mounted" ;; 34) # bogus special device echo "Cannot stat $fsckdev - ignoring" err=1 ;; *) # uncorrectable errors echo "$fsckdev uncorrectable error" err=1 ;; esac done # # Call the fsckall programs # for fst in $fsckall_fstypes do cmd="/usr/lib/fs/$fst/fsckall \$${fst}_fscklist" eval $cmd case $? in 0) # file systems OK ;; *) # couldn't fix some of the filesystems echo "fsckall failed with exit code "$?"." checkmessage ;; esac done if [ "$ALTM" ]; then if [ ! -f "$ALTM" ]; then exit fi /sbin/sh $ALTM # run the saved mount commands /bin/rm -f $ALTM exit fi if [ -n "$FSType" ]; then /sbin/mount -a -F $FSType exit fi # Some remote filesystems (e.g. autofs) shouldn't be mounted # with mountall, so the list here is explicit (not from /etc/dfs/fstypes) if [ "$RFLAG" ]; then /sbin/mount -a -F nfs /sbin/mount -a -F smbfs exit fi if [ "$LFLAG" -o "$GFLAG" -o $err != 0 ]; then [ -z "$mntlist" ] || /sbin/mount -a $mntlist exit fi # else mount them all /sbin/mount -a # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright 2006 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # #ident "%Z%%M% %I% %E% SMI" # # # Currently supported cache names: # audit_user, auth_attr, bootparams, ethers # exec_attr, group, hosts, ipnodes, netmasks # networks, passwd, printers, prof_attr, project # protocols, rpc, services, tnrhdb, tnrhtp, user_attr # # logfile /var/adm/nscd.log enable-cache hosts yes debug-level 0 positive-time-to-live audit_user 3600 negative-time-to-live audit_user 5 keep-hot-count audit_user 20 check-files audit_user yes positive-time-to-live auth_attr 3600 negative-time-to-live auth_attr 5 keep-hot-count auth_attr 20 check-files auth_attr yes positive-time-to-live bootparams 3600 negative-time-to-live bootparams 5 keep-hot-count bootparams 20 check-files bootparams yes positive-time-to-live ethers 3600 negative-time-to-live ethers 5 keep-hot-count ethers 20 check-files ethers yes positive-time-to-live exec_attr 3600 negative-time-to-live exec_attr 300 keep-hot-count exec_attr 20 check-files exec_attr yes positive-time-to-live group 3600 negative-time-to-live group 5 keep-hot-count group 20 check-files group yes positive-time-to-live hosts 3600 negative-time-to-live hosts 5 keep-hot-count hosts 20 check-files hosts yes positive-time-to-live ipnodes 3600 negative-time-to-live ipnodes 5 keep-hot-count ipnodes 20 check-files ipnodes yes positive-time-to-live netmasks 3600 negative-time-to-live netmasks 5 keep-hot-count netmasks 20 check-files netmasks yes positive-time-to-live networks 3600 negative-time-to-live networks 5 keep-hot-count networks 20 check-files networks yes positive-time-to-live passwd 600 negative-time-to-live passwd 5 keep-hot-count passwd 20 check-files passwd yes positive-time-to-live printers 3600 negative-time-to-live printers 5 keep-hot-count printers 20 check-files printers yes positive-time-to-live prof_attr 3600 negative-time-to-live prof_attr 5 keep-hot-count prof_attr 20 check-files prof_attr yes positive-time-to-live project 3600 negative-time-to-live project 5 keep-hot-count project 20 check-files project yes positive-time-to-live protocols 3600 negative-time-to-live protocols 5 keep-hot-count protocols 20 check-files protocols yes positive-time-to-live rpc 3600 negative-time-to-live rpc 5 keep-hot-count rpc 20 check-files rpc yes positive-time-to-live services 3600 negative-time-to-live services 5 keep-hot-count services 20 check-files services yes positive-time-to-live tnrhdb 3600 negative-time-to-live tnrhdb 5 keep-hot-count tnrhdb 20 check-files tnrhdb yes positive-time-to-live tnrhtp 3600 negative-time-to-live tnrhtp 5 keep-hot-count tnrhtp 20 check-files tnrhtp yes positive-time-to-live user_attr 3600 negative-time-to-live user_attr 5 keep-hot-count user_attr 20 check-files user_attr yes # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # The algorithm name __unix__ is reserved. 1 crypt_bsdmd5.so.1 2a crypt_bsdbf.so.1 2b crypt_bsdbf.so.1 md5 crypt_sunmd5.so.1 5 crypt_sha256.so.1 6 crypt_sha512.so.1 #!/sbin/sh # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T # All Rights Reserved # # Copyright 2017, OmniTI Computer Consulting, Inc. All rights reserved. # # Sequence performed to change the init state of a machine. Only allows # transitions to states 0,1,5,6,s,S (i.e.: down or administrative states). # This procedure checks to see if you are permitted and allows an # interactive shutdown. The actual change of state, killing of # processes and such are performed by the new init state, say 0, # and its /sbin/rc0. usage() { echo "Usage: $0 [ -y ] [ -g ] [ -i ] [ message ]" exit 1 } notify() { /usr/sbin/wall -a <<-! $* ! # We used to do rwall here if showmounts had any output, but # rwall is a potential security hole, and it could block this, so # we don't bother with it anymore. } nologin=/etc/nologin # Set the PATH so that to guarentee behavior of shell built in commands # (such as echo). PATH=/bin:/sbin:/usr/bin:/usr/sbin # Initial sanity checks: # Make sure /usr is mounted # Check the user id (only root can run shutdown) if [ ! -d /usr/bin ] then echo "$0: /usr is not mounted. Mount /usr or use init to shutdown." exit 1 fi if [ -x /bin/id ] then eval `/bin/id | /bin/sed 's/[^a-z0-9=].*//'` if [ "${uid:=0}" -ne 0 ] then echo "$0: Only root can run $0" exit 2 fi else echo "$0: can't check user id." exit 2 fi # Get options (defaults immediately below): grace=60 askconfirmation=yes initstate=s while getopts g:i:y? c do case $c in g) case $OPTARG in *[!0-9]* ) echo "$0: -g requires a numeric option" usage ;; [0-9]* ) grace=$OPTARG ;; esac ;; i) case $OPTARG in [Ss0156]) initstate=$OPTARG ;; [234abcqQ]) echo "$0: Initstate $OPTARG is not for system shutdown" exit 1 ;; *) echo "$0: $OPTARG is not a valid initstate" usage ;; esac ;; y) askconfirmation= ;; \?) usage ;; esac done shift $(($OPTIND - 1)) echo '\nShutdown started. \c' /bin/date echo NODENAME=`uname -n` cd / trap "rm $nologin >/dev/null 2>&1 ;exit 1" 1 2 15 # If other users are on the system (and any grace period is given), warn them. for i in 7200 3600 1800 1200 600 300 120 60 30 10; do if [ ${grace} -gt $i ] then hours=$((${grace} / 3600)) minutes=$((${grace} % 3600 / 60)) seconds=$((${grace} % 60)) time="" if [ ${hours} -gt 1 ] then time="${hours} hours " elif [ ${hours} -eq 1 ] then time="1 hour " fi if [ ${minutes} -gt 1 ] then time="${time}${minutes} minutes " elif [ ${minutes} -eq 1 ] then time="${time}1 minute " fi if [ ${hours} -eq 0 -a ${seconds} -gt 0 ] then if [ ${seconds} -eq 1 ] then time="${time}${seconds} second" else time="${time}${seconds} seconds" fi fi (notify \ "The system ${NODENAME} will be shut down in ${time} $*") rm $nologin >/dev/null 2>&1 cat > $nologin <<-! NO LOGINS: System going down in ${time} $* ! /bin/sleep $((${grace} - $i)) grace=$i fi done # Confirm that we really want to shutdown. if [ ${askconfirmation} ] then echo "Do you want to continue? (y or n): \c" read b if [ "$b" != "y" ] then notify "False Alarm: The system ${NODENAME} will not be brought down." echo 'Shutdown aborted.' rm $nologin >/dev/null 2>&1 exit 1 fi fi # Final shutdown message, and sleep away the final 10 seconds (or less). (notify \ "THE SYSTEM ${NODENAME} IS BEING SHUT DOWN NOW ! ! ! Log off now or risk your files being damaged $*") if [ ${grace} -gt 0 ] then /bin/sleep ${grace} fi # Go to the requested initstate. echo "Changing to init state $initstate - please wait" # We might be racing with a system that's still booting. # Before starting init, check to see if smf(7) is running. The easiest way # to do this is to check for the existence of the repository service door. i=0 # Try three times, sleeping one second each time... while [ ! -e /etc/svc/volatile/repository_door -a $i -lt 3 ]; do sleep 1 i=$(($i + 1)) done if [ ! -e /etc/svc/volatile/repository_door ]; then notify "Could not find repository door, init-state change may fail!" fi /sbin/init ${initstate} #!/sbin/sh # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License, Version 1.0 only # (the "License"). You may not use this file except in compliance # with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright 2005 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T # All rights reserved. # # #ident "%Z%%M% %I% %E% SMI" # Set noinuse checking during boot. We want to disable device in use checking # so that normal swap use, such as specified in /etc/vfstab, will not cause # swap devices to fail to be configured during boot. NOINUSE_CHECK=1; export NOINUSE_CHECK PATH=/bin:/sbin:/usr/bin:/usr/sbin; export PATH USAGE="Usage: swapadd [-12] [file_system_table]" VFSTAB=/etc/vfstab # Default file system table PASS=2 # Default to checking for existing swap # # Check to see if there is an entry in the fstab for a specified file and # mount it. This allows swap files (e.g. nfs files) to be mounted before # being added for swap. # checkmount() { while read rspecial rfsckdev rmountp rfstype rfsckpass rautomnt rmntopts do # # Ignore comments, empty lines, and no-action lines # case "$rspecial" in '#'* | '' | '-') continue ;; esac if [ "x$rmountp" = "x$1" ]; then # # If mount options are '-', default to 'rw' # [ "x$rmntopts" = x- ] && rmntopts=rw if /sbin/mount -m -o $rmntopts $rspecial \ >/dev/null 2>&1; then echo "Mounting $rmountp for swap" else echo "Mount of $rmountp for swap failed" fi return fi done <$VFSTAB } die() { echo "$*" >& 2 exit 1 } while getopts 12 opt; do case "$opt" in 1|2) PASS=$opt ;; \?) die "$USAGE" ;; esac done shift `expr $OPTIND - 1` [ $# -gt 1 ] && die "$USAGE" [ $# -gt 0 ] && VFSTAB="$1" # # If $VFSTAB is not "-" (stdin), re-open stdin as the specified file # if [ "x$VFSTAB" != x- ]; then [ -s "$VFSTAB" ] || die "swapadd: file system table ($VFSTAB) not found" exec <$VFSTAB fi # # Read the file system table to find entries of file system type "swap". # Add the swap device or file specified in the first column. # while read special t1 t2 fstype t3 t4 t5; do # # Ignore comments, empty lines, and no-action lines # case "$special" in '#'* | '' | '-') continue ;; esac # # Ignore non-swap fstypes # [ "$fstype" != swap ] && continue if [ $PASS = 1 ]; then # # Pass 1 should handle adding the swap files that # are accessable immediately; block devices, files # in / and /usr, and direct nfs mounted files. # if [ ! -b $special ]; then # # Read the file system table searching for mountpoints # matching the swap file about to be added. # # NB: This won't work correctly if the file to added # for swapping is a sub-directory of the mountpoint. # e.g. swapfile-> servername:/export/swap/clientname # mountpoint-> servername:/export/swap # checkmount $special fi if [ -f $special -a -w $special -o -b $special ]; then swap -$PASS -a $special >/dev/null fi else # # Pass 2 should skip all the swap already added. If something # added earlier uses the same name as something to be added # later, the following test won't work. This should only happen # if parts of a particular swap file are added or deleted by # hand between invocations. # swap -l 2>/dev/null | grep '\<'${special}'\>' >/dev/null 2>&1 \ || swap -$PASS -a $special >/dev/null fi done #!/sbin/sh # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. # # Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T # All Rights Reserved # # usage () { if [ -n "$1" ]; then echo "umountall: $1" 1>&2 fi echo "Usage:\n\tumountall [-k] [-s] [-F FSType] [-l|-r] [-Z] [-n]" 1>&2 echo "\tumountall [-k] [-s] [-h host] [-Z] [-n]" 1>&2 exit 2 } MNTTAB=/etc/mnttab # This script is installed as both /sbin/umountall (as used in some # /sbin/rc? and /etc/init.d scripts) _and_ as /sbin/umountall (typically # PATHed from the command line). As such it should not depend on /usr # being mounted (if /usr is a separate filesystem). # # /sbin/sh Bourne shell builtins we use: # echo # exit # getopts # test, [ ] # exec # read # # /sbin commands we use: # /sbin/uname # /sbin/umount # # The following /usr based commands may be used by this script (depending on # command line options). We will set our PATH to find them, but where they # are not present (eg, if /usr is not mounted) we will catch references to # them via shell functions conditionally defined after option processing # (don't use any of these commands before then). # # Command Command line option and use # /bin/sleep -k, to sleep after an fuser -c -k on the mountpoint # /usr/sbin/fuser -k, to kill processes keeping a mount point busy # # In addition, we use /bin/tail if it is available; if not we use # slower shell constructs to reverse a file. PATH=/bin:/sbin:/usr/bin:/usr/sbin # Clear these in case they were already set in our inherited environment. FSType= FFLAG= HOST= HFLAG= RFLAG= LFLAG= SFLAG= KFLAG= ZFLAG= NFLAG= LOCALNAME= UMOUNTFLAG= RemoteFSTypes= # Is the passed fstype a "remote" one? # Essentially: /bin/grep "^$1" /etc/dfs/fstypes isremote() { for t in $RemoteFSTypes do [ "$t" = "$1" ] && return 0 done return 1 } # Get list of remote FS types (just once) RemoteFSTypes=`while read t junk; do echo $t; done < /etc/dfs/fstypes` # # Process command line args # while getopts ?rslkF:h:Zn c do case $c in r) RFLAG="r";; l) LFLAG="l";; s) SFLAG="s";; k) KFLAG="k";; h) if [ -n "$HFLAG" ]; then usage "more than one host specified" fi HOST=$OPTARG HFLAG="h" LOCALNAME=`/bin/uname -n` ;; F) if [ -n "$FFLAG" ]; then usage "more than one FStype specified" fi FSType=$OPTARG FFLAG="f" case $FSType in ?????????*) usage "FSType ${FSType} exceeds 8 characters" esac; ;; Z) ZFLAG="z";; n) NFLAG="n" # Alias any commands that would perform real actions to # something that tells what action would have been performed UMOUNTFLAG="-V" fuser () { echo "fuser $*" 1>&2 } sleep () { : # No need to show where we'd sleep } ;; \?) usage "" ;; esac done # Sanity checking: # 1) arguments beyond those supported # 2) can't specify both remote and local # 3) can't specify a host with -r or -l # 4) can't specify a fstype with -h # 5) can't specify this host with -h (checks only uname -n) # 6) can't be fstype nfs and local # 7) only fstype nfs is remote if [ $# -ge $OPTIND ]; then # 1 usage "additional arguments not supported" fi if [ -n "$RFLAG" -a -n "$LFLAG" ]; then # 2 usage "options -r and -l are incompatible" fi if [ \( -n "$RFLAG" -o -n "$LFLAG" \) -a "$HFLAG" = "h" ]; then # 3 usage "option -${RFLAG}${LFLAG} incompatible with -h option" fi if [ -n "$FFLAG" -a "$HFLAG" = "h" ]; then # 4 usage "Specifying FStype incompatible with -h option" fi if [ -n "$HFLAG" -a "$HOST" = "$LOCALNAME" ]; then # 5 usage "Specifying local host illegal for -h option" fi if [ "$LFLAG" = "l" -a -n "$FSType" ]; then # 6 # remote FSType not allowed isremote "$FSType" && usage "option -l and FSType ${FSType} are incompatible" fi if [ "$RFLAG" = "r" -a -n "$FSType" ]; then # 7 # remote FSType required isremote "$FSType" || usage "option -r and FSType ${FSType} are incompatible" fi ZONENAME=`zonename` # # Take advantage of parallel unmounting at this point if we have no # criteria to match and we are in the global zone # if [ -z "${SFLAG}${LFLAG}${RFLAG}${HFLAG}${KFLAG}${FFLAG}${ZFLAG}" -a \ "$ZONENAME" = "global" ]; then umount -a ${UMOUNTFLAG} exit # with return code of the umount -a fi # # Catch uses of /usr commands when /usr is not mounted if [ -n "$KFLAG" -a -z "$NFLAG" ]; then if [ ! -x /usr/sbin/fuser ]; then fuser () { echo "umountall: fuser -k skipped (no /usr)" 1>&2 # continue - not fatal } sleep () { : # no point in sleeping if fuser is doing nothing } else if [ ! -x /bin/sleep ]; then sleep () { echo "umountall: sleep after fuser -k skipped (no /usr)" 1>&2 # continue - not fatal } fi fi fi # # Shell function to avoid using /usr/bin/cut. Given a dev from a # fstype=nfs line in mnttab (eg, "host:/export) extract the host # component. The dev string looks like: "host:/path" print_nfs_host () { OIFS=$IFS IFS=":" set -- $* echo $1 IFS=$OIFS } # # Similar for smbfs, but tricky due to the optional parts # of the "device" syntax. The dev strings look like: # "//server/share" or "//user@server/share" print_smbfs_host () { OIFS=$IFS IFS="/@" set -- $* case $# in 3) echo "$2";; 2) echo "$1";; esac IFS=$OIFS } # # doumounts echos its return code to stdout, so commands used within # this function should take care to produce no other output to stdout. doumounts () { ( rc=0 fslist="" while read dev mountp fstype mode dummy do case "${mountp}" in / | \ /dev | \ /dev/fd | \ /devices | \ /etc/mnttab | \ /etc/svc/volatile | \ /lib | \ /proc | \ /sbin | \ /system/contract | \ /system/object | \ /tmp | \ /tmp/.libgrubmgmt* | \ /usr | \ /var | \ /var/adm | \ /var/run | \ '' ) # # file systems possibly mounted in the kernel or # in the methods of some of the file system # services # continue ;; * ) if [ -n "$HFLAG" ]; then thishost='-' if [ "$fstype" = "nfs" ]; then thishost=`print_nfs_host $dev` fi if [ "$fstype" = "smbfs" ]; then thishost=`print_smbfs_host $dev` fi if [ "$HOST" != "$thishost" ]; then continue fi fi if [ -n "$FFLAG" -a "$FSType" != "$fstype" ]; then continue fi if [ -n "$LFLAG" ]; then # umount local filesystems isremote "$fstype" && continue fi # Note: isremote is true for both nfs & autofs, so # this will filter out autofs mounts with nfs file # system mounted on the top of it. # # WARNING: use of any syscall on a NFS file system has # the danger to go over-the-wire and could cause nfs # clients to hang on shutdown, if the nfs server is # down beforehand. # For the reason described above, a simple test like # "df -F nfs $mountp" can't be used to filter out # nfs-over-autofs mounts. (isremote works OK) # if [ -n "$RFLAG" ]; then # umount remote filesystems isremote "$fstype" || continue fi if [ "$ZONENAME" != "global" ]; then for option in `echo $mode | tr , '\012'`; do # # should not see any zone options # but our own # if [ "$option" = "zone=$ZONENAME" ]; then break fi done if [ "$option" != "zone=$ZONENAME" ]; then continue fi # we are called from the global zone else for option in `echo $mode | tr , '\012'`; do case "$option" in zone=*) option="zone=" break ;; esac done # skip mounts from non-global zones if ZFLAG is not set if [ "$option" = "zone=" -a -z "$ZFLAG" ]; then continue fi # skip mounts from the global zone if ZFLAG is set if [ "$option" != "zone=" -a -n "$ZFLAG" ]; then continue fi fi if [ -n "${KFLAG}" ]; then fuser -c -k $mountp 1>&2 sleep 2 fi if [ -n "$SFLAG" ]; then umount ${UMOUNTFLAG} ${mountp} 1>&2 trc=$? if [ $trc -ne 0 ]; then rc=$trc fi else # We want to umount in parallel fslist="$fslist $mountp" fi esac done if [ -n "$fslist" ]; then umount -a ${UMOUNTFLAG} $fslist 1>&2 trc=$? if [ $trc -ne 0 ]; then rc=$trc fi fi echo $rc ) } # # /etc/mnttab has the most recent mounts last. Reverse it so that we # may umount in opposite order to the original mounts. # if [ ! -x /bin/tail ]; then exec < $MNTTAB REVERSED= while read line; do if [ -n "$REVERSED" ]; then REVERSED="$line\n$REVERSED" else REVERSED="$line" fi done error=`echo $REVERSED | doumounts` else error=`/bin/tail -r $MNTTAB | doumounts` fi exit $error #!/sbin/sh # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "%Z%%M% %I% %E% SMI" # # Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T # All Rights Reserved # echo "#device device mount FS fsck mount mount #to mount to fsck point type pass at boot options # /devices - /devices devfs - no - /proc - /proc proc - no - ctfs - /system/contract ctfs - no - objfs - /system/object objfs - no - sharefs - /etc/dfs/sharetab sharefs - no - fd - /dev/fd fd - no - swap - /tmp tmpfs - yes - ">vfstab