1203790Sfabient#!/bin/sh 2203790Sfabient# 3203790Sfabient# Copyright (c) 1999 Matt Dillon 4203790Sfabient# All rights reserved. 5203790Sfabient# 6203790Sfabient# Redistribution and use in source and binary forms, with or without 7203790Sfabient# modification, are permitted provided that the following conditions 8203790Sfabient# are met: 9203790Sfabient# 1. Redistributions of source code must retain the above copyright 10203790Sfabient# notice, this list of conditions and the following disclaimer. 11203790Sfabient# 2. Redistributions in binary form must reproduce the above copyright 12203790Sfabient# notice, this list of conditions and the following disclaimer in the 13203790Sfabient# documentation and/or other materials provided with the distribution. 14203790Sfabient# 15203790Sfabient# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16203790Sfabient# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17203790Sfabient# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18203790Sfabient# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19203790Sfabient# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20203790Sfabient# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21203790Sfabient# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22203790Sfabient# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23203790Sfabient# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24203790Sfabient# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25203790Sfabient# SUCH DAMAGE. 26203790Sfabient# 27203790Sfabient# $FreeBSD: releng/11.0/etc/rc.d/tmp 298514 2016-04-23 16:10:54Z lme $ 28203790Sfabient# 29203790Sfabient 30203790Sfabient# PROVIDE: tmp 31203790Sfabient# REQUIRE: mountcritremote 32203790Sfabient 33203790Sfabient. /etc/rc.subr 34203790Sfabient 35203790Sfabientname="tmp" 36203790Sfabientdesc="Configure tmpfs" 37203790Sfabientstop_cmd=':' 38203790Sfabient 39203790Sfabientload_rc_config $name 40203790Sfabient 41203790Sfabientmount_tmpmfs() 42203790Sfabient{ 43203790Sfabient if ! /bin/df /tmp | grep -q "^/dev/md[0-9].* /tmp"; then 44203790Sfabient mount_md ${tmpsize} /tmp "${tmpmfs_flags}" 45203790Sfabient chmod 01777 /tmp 46203790Sfabient fi 47203790Sfabient} 48203790Sfabient 49203790Sfabient# If we do not have a writable /tmp, create a memory 50203790Sfabient# filesystem for /tmp. If /tmp is a symlink (e.g. to /var/tmp, 51203790Sfabient# then it should already be writable). 52203790Sfabient# 53203790Sfabientcase "${tmpmfs}" in 54203790Sfabient[Aa][Uu][Tt][Oo]) 55203790Sfabient if _tmpdir=$(mktemp -d -q /tmp/.diskless.XXXXXX); then 56203790Sfabient rmdir ${_tmpdir} 57203790Sfabient else 58203790Sfabient if [ -h /tmp ]; then 59203790Sfabient echo "*** /tmp is a symlink to a non-writable area!" 60203790Sfabient echo "dropping into shell, ^D to continue anyway." 61203790Sfabient /bin/sh 62203790Sfabient else 63203790Sfabient mount_tmpmfs 64203790Sfabient fi 65203790Sfabient fi 66203790Sfabient ;; 67203790Sfabient*) 68203790Sfabient if checkyesno tmpmfs; then 69203790Sfabient mount_tmpmfs 70203790Sfabient fi 71203790Sfabient ;; 72203790Sfabientesac 73203790Sfabient