xref: /freebsd/usr.sbin/bsdconfig/networking/share/common.subr (revision 56961fd7949de755f95a60fe8ac936f81e953f5b)
1ab2043b8SDevin Teskeif [ ! "$_NETWORKING_COMMON_SUBR" ]; then _NETWORKING_COMMON_SUBR=1
2ab2043b8SDevin Teske#
3ab2043b8SDevin Teske# Copyright (c) 2006-2012 Devin Teske
4ab2043b8SDevin Teske# All Rights Reserved.
5ab2043b8SDevin Teske#
6ab2043b8SDevin Teske# Redistribution and use in source and binary forms, with or without
7ab2043b8SDevin Teske# modification, are permitted provided that the following conditions
8ab2043b8SDevin Teske# are met:
9ab2043b8SDevin Teske# 1. Redistributions of source code must retain the above copyright
10ab2043b8SDevin Teske#    notice, this list of conditions and the following disclaimer.
11ab2043b8SDevin Teske# 2. Redistributions in binary form must reproduce the above copyright
12ab2043b8SDevin Teske#    notice, this list of conditions and the following disclaimer in the
13ab2043b8SDevin Teske#    documentation and/or other materials provided with the distribution.
14ab2043b8SDevin Teske#
15ab2043b8SDevin Teske# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16ab2043b8SDevin Teske# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
17ab2043b8SDevin Teske# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18ab2043b8SDevin Teske# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19ab2043b8SDevin Teske# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20ab2043b8SDevin Teske# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21ab2043b8SDevin Teske# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22ab2043b8SDevin Teske# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23ab2043b8SDevin Teske# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24ab2043b8SDevin Teske# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25ab2043b8SDevin Teske# SUCH DAMAGE.
26ab2043b8SDevin Teske#
27ab2043b8SDevin Teske# $FreeBSD$
28ab2043b8SDevin Teske#
29ab2043b8SDevin Teske############################################################ INCLUDES
30ab2043b8SDevin Teske
31ab2043b8SDevin TeskeBSDCFG_SHARE="/usr/share/bsdconfig"
32ab2043b8SDevin Teske. $BSDCFG_SHARE/common.subr || exit 1
33ab2043b8SDevin Teske
34ab2043b8SDevin Teske############################################################ FUNCTIONS
35ab2043b8SDevin Teske
36ab2043b8SDevin Teske# f_mounted $local_directory
37ab2043b8SDevin Teske#
38ab2043b8SDevin Teske# Return success if a filesystem is mounted on a particular directory.
39ab2043b8SDevin Teske#
40ab2043b8SDevin Teskef_mounted()
41ab2043b8SDevin Teske{
42ab2043b8SDevin Teske	local dir="$1"
43ab2043b8SDevin Teske	[ -d "$dir" ] || return $FAILURE
44ab2043b8SDevin Teske	mount | grep -Eq " on $dir \([^)]+\)$"
45ab2043b8SDevin Teske}
46ab2043b8SDevin Teske
47ab2043b8SDevin Teske# f_jailed
48ab2043b8SDevin Teske#
49ab2043b8SDevin Teske# Returns true if the current process is jail(8)ed.
50ab2043b8SDevin Teske#
51ab2043b8SDevin Teskef_jailed()
52ab2043b8SDevin Teske{
53ab2043b8SDevin Teske	! f_quietly ps 1
54ab2043b8SDevin Teske}
55ab2043b8SDevin Teske
56ab2043b8SDevin Teske# f_nfs_mounted
57ab2043b8SDevin Teske#
58ab2043b8SDevin Teske# Returns true if there are any NFS mounts currently active, otherwise false.
59ab2043b8SDevin Teske#
60ab2043b8SDevin Teskef_nfs_mounted()
61ab2043b8SDevin Teske{
62ab2043b8SDevin Teske	[ "$( df -t nfs )" ]
63ab2043b8SDevin Teske}
64ab2043b8SDevin Teske
65*56961fd7SDevin Teske############################################################ MAIN
66*56961fd7SDevin Teske
67*56961fd7SDevin Teskef_dprintf "%s: Successfully loaded." networking/common.subr
68*56961fd7SDevin Teske
69ab2043b8SDevin Teskefi # ! $_NETWORKING_COMMON_SUBR
70