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 658091fd8Ssetje# Common Development and Distribution License (the "License"). 758091fd8Ssetje# You may not use this file except in compliance with the License. 87c478bd9Sstevel@tonic-gate# 97c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate# and limitations under the License. 137c478bd9Sstevel@tonic-gate# 147c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate# 207c478bd9Sstevel@tonic-gate# CDDL HEADER END 217c478bd9Sstevel@tonic-gate# 227c478bd9Sstevel@tonic-gate# 23*69da9f2fSgowtham thommandra - Sun Microsystems - Bangalore India# Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. 247c478bd9Sstevel@tonic-gate# 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate. /lib/svc/share/smf_include.sh 277c478bd9Sstevel@tonic-gate 28fa9e4066Sahrensresult=$SMF_EXIT_OK 29a38ddfeeSTim Haleymntretry=0 30fa9e4066Sahrens 317c478bd9Sstevel@tonic-gate# Mount all local filesystems. 327c478bd9Sstevel@tonic-gate 33a38ddfeeSTim Haleycd /; /sbin/mountall -l >/var/run/fs-local 2>&1 347c478bd9Sstevel@tonic-gaterc=$? 35a38ddfeeSTim Haleyif [ $rc -eq 111 ]; then 36a38ddfeeSTim Haley # 37a38ddfeeSTim Haley # The only failures were lofs mounts, we can try again 38a38ddfeeSTim Haley # after zfs is mounted, there is a chance a lofs mount 39a38ddfeeSTim Haley # failed due to it depending on a zfs not yet mounted. 40a38ddfeeSTim Haley # 41a38ddfeeSTim Haley mntretry=1 42a38ddfeeSTim Haleyelif [ $rc -ne 0 ]; then 43a38ddfeeSTim Haley cat /var/run/fs-local >/dev/msglog 447c478bd9Sstevel@tonic-gate msg="WARNING: /sbin/mountall -l failed: exit status $rc" 457c478bd9Sstevel@tonic-gate echo $msg 467c478bd9Sstevel@tonic-gate echo "$SMF_FMRI:" $msg >/dev/msglog 47fa9e4066Sahrens result=$SMF_EXIT_ERR_FATAL 487c478bd9Sstevel@tonic-gatefi 49a38ddfeeSTim Haleyrm -f /var/run/fs-local 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate# 527c478bd9Sstevel@tonic-gate# If there are non-global UFS filesystems with quotas, check and enable them. 537c478bd9Sstevel@tonic-gate# 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate# vlist is the non-global filesystems in vfstab requesting quotas 567c478bd9Sstevel@tonic-gatevlist=`/usr/bin/nawk '$1 !~ /^(#|-)/ && $4 == "ufs" { 577c478bd9Sstevel@tonic-gate if (match($7, "(^|,)(quota|rq)(,|$)") != 0 && 587c478bd9Sstevel@tonic-gate match($7, "(^|,)global(,|$)") == 0) print $1; }' /etc/vfstab` 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gateif [ -n "$vlist" ]; then 617c478bd9Sstevel@tonic-gate # mlist is the filesystems in mnttab that are ufs, mounted rw, 627c478bd9Sstevel@tonic-gate # and without quotas turned on 637c478bd9Sstevel@tonic-gate mlist=`/usr/sbin/mount -p | /usr/bin/nawk '$4 == "ufs" { 647c478bd9Sstevel@tonic-gate if (match($7, "(^|,)ro(,|$)") == 0) print $1; }'` 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate # qlist is the intersection of vlist and mlist 677c478bd9Sstevel@tonic-gate qlist=`echo "$vlist\n-\n$mlist" | \ 687c478bd9Sstevel@tonic-gate /usr/bin/nawk '{if ($1 == "-") { mlist = 1; } 697c478bd9Sstevel@tonic-gate else if (mlist == 0) { vlist[$1] = 1; } 707c478bd9Sstevel@tonic-gate else if (vlist[$1]) { print $1; } }'` 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate # 737c478bd9Sstevel@tonic-gate # Just check and enable the non-global UFS file systems with quotas 747c478bd9Sstevel@tonic-gate # enabled. Note that "quotacheck -a" and "quotaon -a" will try 757c478bd9Sstevel@tonic-gate # to process all UFS entries with quotas rather than excluding 767c478bd9Sstevel@tonic-gate # the entries with the global option (the global entries are handled 777c478bd9Sstevel@tonic-gate # later in another script if the cluster package is installed). 787c478bd9Sstevel@tonic-gate # 797c478bd9Sstevel@tonic-gate if [ -n "$qlist" ]; then 807c478bd9Sstevel@tonic-gate echo 'Checking UFS quotas: \c' 817c478bd9Sstevel@tonic-gate /usr/sbin/quotacheck -p $qlist 827c478bd9Sstevel@tonic-gate echo 'done.' 837c478bd9Sstevel@tonic-gate /usr/sbin/quotaon $qlist 847c478bd9Sstevel@tonic-gate fi 857c478bd9Sstevel@tonic-gatefi 867c478bd9Sstevel@tonic-gate 87fa9e4066Sahrens# Mount all ZFS filesystems. 88fa9e4066Sahrens 89fa9e4066Sahrensif [ -x /usr/sbin/zfs ]; then 90dae68f5eSmmusante /usr/sbin/zfs mount -va >/dev/msglog 2>&1 91fa9e4066Sahrens rc=$? 92fa9e4066Sahrens if [ $rc -ne 0 ]; then 93fa9e4066Sahrens msg="WARNING: /usr/sbin/zfs mount -a failed: exit status $rc" 94fa9e4066Sahrens echo $msg 95fa9e4066Sahrens echo "$SMF_FMRI:" $msg >/dev/msglog 96fa9e4066Sahrens result=$SMF_EXIT_ERR_FATAL 97fa9e4066Sahrens fi 98fa9e4066Sahrensfi 99fa9e4066Sahrens 100a38ddfeeSTim Haleyif [ $result = $SMF_EXIT_OK -a $mntretry -eq 1 ] 101a38ddfeeSTim Haleythen 102a38ddfeeSTim Haley cd /; /sbin/mountall -l >/dev/msglog 103a38ddfeeSTim Haley rc=$? 104a38ddfeeSTim Haley if [ $rc -ne 0 ]; then 105a38ddfeeSTim Haley msg="WARNING: /sbin/mountall -l failed: exit status $rc" 106a38ddfeeSTim Haley echo $msg 107a38ddfeeSTim Haley echo "$SMF_FMRI:" $msg >/dev/msglog 108a38ddfeeSTim Haley result=$SMF_EXIT_ERR_FATAL 109a38ddfeeSTim Haley fi 110a38ddfeeSTim Haleyfi 111a38ddfeeSTim Haley 112*69da9f2fSgowtham thommandra - Sun Microsystems - Bangalore India# Add swap filesystems 113*69da9f2fSgowtham thommandra - Sun Microsystems - Bangalore India/sbin/swapadd >/dev/null 2>&1 114*69da9f2fSgowtham thommandra - Sun Microsystems - Bangalore India 115fa9e4066Sahrensexit $result 116