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# 2369da9f2fSgowtham thommandra - Sun Microsystems - Bangalore India# Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. 24*d2d3a1e2SAndrew Stormont# Copyright 2017 RackTop Systems. 257c478bd9Sstevel@tonic-gate# 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate. /lib/svc/share/smf_include.sh 287c478bd9Sstevel@tonic-gate 29fa9e4066Sahrensresult=$SMF_EXIT_OK 30a38ddfeeSTim Haleymntretry=0 31fa9e4066Sahrens 327c478bd9Sstevel@tonic-gate# Mount all local filesystems. 337c478bd9Sstevel@tonic-gate 34a38ddfeeSTim Haleycd /; /sbin/mountall -l >/var/run/fs-local 2>&1 357c478bd9Sstevel@tonic-gaterc=$? 36a38ddfeeSTim Haleyif [ $rc -eq 111 ]; then 37a38ddfeeSTim Haley # 38a38ddfeeSTim Haley # The only failures were lofs mounts, we can try again 39a38ddfeeSTim Haley # after zfs is mounted, there is a chance a lofs mount 40a38ddfeeSTim Haley # failed due to it depending on a zfs not yet mounted. 41a38ddfeeSTim Haley # 42a38ddfeeSTim Haley mntretry=1 43a38ddfeeSTim Haleyelif [ $rc -ne 0 ]; then 44a38ddfeeSTim Haley cat /var/run/fs-local >/dev/msglog 457c478bd9Sstevel@tonic-gate msg="WARNING: /sbin/mountall -l failed: exit status $rc" 467c478bd9Sstevel@tonic-gate echo $msg 477c478bd9Sstevel@tonic-gate echo "$SMF_FMRI:" $msg >/dev/msglog 48*d2d3a1e2SAndrew Stormont result=$SMF_EXIT_MON_DEGRADE 497c478bd9Sstevel@tonic-gatefi 50a38ddfeeSTim Haleyrm -f /var/run/fs-local 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate# 537c478bd9Sstevel@tonic-gate# If there are non-global UFS filesystems with quotas, check and enable them. 547c478bd9Sstevel@tonic-gate# 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate# vlist is the non-global filesystems in vfstab requesting quotas 577c478bd9Sstevel@tonic-gatevlist=`/usr/bin/nawk '$1 !~ /^(#|-)/ && $4 == "ufs" { 587c478bd9Sstevel@tonic-gate if (match($7, "(^|,)(quota|rq)(,|$)") != 0 && 597c478bd9Sstevel@tonic-gate match($7, "(^|,)global(,|$)") == 0) print $1; }' /etc/vfstab` 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gateif [ -n "$vlist" ]; then 627c478bd9Sstevel@tonic-gate # mlist is the filesystems in mnttab that are ufs, mounted rw, 637c478bd9Sstevel@tonic-gate # and without quotas turned on 647c478bd9Sstevel@tonic-gate mlist=`/usr/sbin/mount -p | /usr/bin/nawk '$4 == "ufs" { 657c478bd9Sstevel@tonic-gate if (match($7, "(^|,)ro(,|$)") == 0) print $1; }'` 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate # qlist is the intersection of vlist and mlist 687c478bd9Sstevel@tonic-gate qlist=`echo "$vlist\n-\n$mlist" | \ 697c478bd9Sstevel@tonic-gate /usr/bin/nawk '{if ($1 == "-") { mlist = 1; } 707c478bd9Sstevel@tonic-gate else if (mlist == 0) { vlist[$1] = 1; } 717c478bd9Sstevel@tonic-gate else if (vlist[$1]) { print $1; } }'` 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate # 747c478bd9Sstevel@tonic-gate # Just check and enable the non-global UFS file systems with quotas 757c478bd9Sstevel@tonic-gate # enabled. Note that "quotacheck -a" and "quotaon -a" will try 767c478bd9Sstevel@tonic-gate # to process all UFS entries with quotas rather than excluding 777c478bd9Sstevel@tonic-gate # the entries with the global option (the global entries are handled 787c478bd9Sstevel@tonic-gate # later in another script if the cluster package is installed). 797c478bd9Sstevel@tonic-gate # 807c478bd9Sstevel@tonic-gate if [ -n "$qlist" ]; then 817c478bd9Sstevel@tonic-gate echo 'Checking UFS quotas: \c' 827c478bd9Sstevel@tonic-gate /usr/sbin/quotacheck -p $qlist 837c478bd9Sstevel@tonic-gate echo 'done.' 847c478bd9Sstevel@tonic-gate /usr/sbin/quotaon $qlist 857c478bd9Sstevel@tonic-gate fi 867c478bd9Sstevel@tonic-gatefi 877c478bd9Sstevel@tonic-gate 88fa9e4066Sahrens# Mount all ZFS filesystems. 89fa9e4066Sahrens 90fa9e4066Sahrensif [ -x /usr/sbin/zfs ]; then 91dae68f5eSmmusante /usr/sbin/zfs mount -va >/dev/msglog 2>&1 92fa9e4066Sahrens rc=$? 93fa9e4066Sahrens if [ $rc -ne 0 ]; then 94fa9e4066Sahrens msg="WARNING: /usr/sbin/zfs mount -a failed: exit status $rc" 95fa9e4066Sahrens echo $msg 96fa9e4066Sahrens echo "$SMF_FMRI:" $msg >/dev/msglog 97*d2d3a1e2SAndrew Stormont result=$SMF_EXIT_MON_DEGRADE 98fa9e4066Sahrens fi 99fa9e4066Sahrensfi 100fa9e4066Sahrens 101a38ddfeeSTim Haleyif [ $result = $SMF_EXIT_OK -a $mntretry -eq 1 ] 102a38ddfeeSTim Haleythen 103a38ddfeeSTim Haley cd /; /sbin/mountall -l >/dev/msglog 104a38ddfeeSTim Haley rc=$? 105a38ddfeeSTim Haley if [ $rc -ne 0 ]; then 106a38ddfeeSTim Haley msg="WARNING: /sbin/mountall -l failed: exit status $rc" 107a38ddfeeSTim Haley echo $msg 108a38ddfeeSTim Haley echo "$SMF_FMRI:" $msg >/dev/msglog 109*d2d3a1e2SAndrew Stormont result=$SMF_EXIT_MON_DEGRADE 110a38ddfeeSTim Haley fi 111a38ddfeeSTim Haleyfi 112a38ddfeeSTim Haley 11369da9f2fSgowtham thommandra - Sun Microsystems - Bangalore India# Add swap filesystems 11469da9f2fSgowtham thommandra - Sun Microsystems - Bangalore India/sbin/swapadd >/dev/null 2>&1 11569da9f2fSgowtham thommandra - Sun Microsystems - Bangalore India 116fa9e4066Sahrensexit $result 117