From 13d74b43b74510ce72f512af116b5c7133baabc6 Mon Sep 17 00:00:00 2001 From: Mike Hibler <hibler@cs.utah.edu> Date: Mon, 16 Nov 2015 10:34:49 -0700 Subject: [PATCH] Automate some of the support for using autofs rather than amd. This will only be for boss and for FreeBSD 10.2 and beyond. --- GNUmakefile.in | 4 +-- autofs/GNUmakefile.in | 74 ++++++++++++++++++++++++++++++++++++++++ autofs/auto_master | 13 +++++++ autofs/autofs_boss.sh.in | 71 ++++++++++++++++++++++++++++++++++++++ configure | 2 +- configure.ac | 2 +- defs-default | 2 ++ 7 files changed, 164 insertions(+), 4 deletions(-) create mode 100644 autofs/GNUmakefile.in create mode 100644 autofs/auto_master create mode 100644 autofs/autofs_boss.sh.in diff --git a/GNUmakefile.in b/GNUmakefile.in index b24c26934a..2bb6a74782 100644 --- a/GNUmakefile.in +++ b/GNUmakefile.in @@ -52,10 +52,10 @@ SUBDIRS = \ clientside/lib \ db assign www @optional_subdirs@ clientside ipod security sensors \ pxe tbsetup account tmcd utils backend tip ipod vis \ - sensors os xmlrpc install/newnode_sshkeys tools/whol \ + sensors os xmlrpc autofs install/newnode_sshkeys \ tools/svn wiki collab/exp-vis node_usage install ifeq ($(ISMAINSITE),1) -SUBDIRS += tools/rmanage +SUBDIRS += tools/rmanage tools/whol endif ifeq ($(PGENISUPPORT),1) SUBDIRS += protogeni apt diff --git a/autofs/GNUmakefile.in b/autofs/GNUmakefile.in new file mode 100644 index 0000000000..c1e86b4d01 --- /dev/null +++ b/autofs/GNUmakefile.in @@ -0,0 +1,74 @@ +# +# Copyright (c) 2015 University of Utah and the Flux Group. +# +# {{{EMULAB-LICENSE +# +# This file is part of the Emulab network testbed software. +# +# This file is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or (at +# your option) any later version. +# +# This file is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public +# License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this file. If not, see <http://www.gnu.org/licenses/>. +# +# }}} +# +# +# For installation only. +# +SRCDIR = @srcdir@ +TESTBED_SRCDIR = @top_srcdir@ +OBJDIR = .. +SUBDIR = autofs + +SYSETCDIR = $(DESTDIR)/etc + +SYSTEM := $(shell uname -s) +ifeq ($(SYSTEM),FreeBSD) +FBSDREL := $(shell uname -r | sed -e 's/\([^-][^-]*\)-.*/\1/') +FBSDMAJ := $(basename $(FBSDREL)) +endif + +include $(OBJDIR)/Makeconf + +AUTOFS_FILES = autofs_boss.sh + +# +# Force dependencies to make sure configure regenerates if the .in file +# is changed. +# +all: $(AUTOFS_FILES) + +include $(TESTBED_SRCDIR)/GNUmakerules + +freebsd-os-check: + @if [ -z "$(FBSDMAJ)" -o $(FBSDMAJ) -lt 10 -o \ + \( $(FBSDMAJ) -eq 10 -a \ + \( $(FBSDREL) = "10.0" -o $(FBSDREL) = "10.1" \) \) ]; then \ + echo "Can only install autofs on FreeBSD 10.2 or later"; \ + false; \ + fi + +first-install: freebsd-os-check install + $(INSTALL) -m 644 $(SRCDIR)/auto_master $(SYSETCDIR)/auto_master + ln -sf $(INSTALL_ETCDIR)/autofs_boss.sh $(SYSETCDIR)/auto_users + ln -sf $(INSTALL_ETCDIR)/autofs_boss.sh $(SYSETCDIR)/auto_proj + ln -sf $(INSTALL_ETCDIR)/autofs_boss.sh $(SYSETCDIR)/auto_groups + @echo "NOTE: Be sure to add 'autofs_enable=\"YES\"' to /etc/rc.conf" + +install: all + $(INSTALL) -m 755 autofs_boss.sh $(INSTALL_ETCDIR)/autofs_boss.sh + +post-install: + +control-install: + +clean: + rm -f $(AUTOFS_FILES) diff --git a/autofs/auto_master b/autofs/auto_master new file mode 100644 index 0000000000..0e5129f324 --- /dev/null +++ b/autofs/auto_master @@ -0,0 +1,13 @@ +# $FreeBSD: releng/10.2/etc/auto_master 283242 2015-05-21 13:42:37Z trasz $ +# +# Automounter master map, see auto_master(5) for details. +# +# This version is customized for the Emulab boss node to access the fs node +# filesystem when fs is using ZFS to provide per-user, per-project +# filesystems. The auto_* maps below are symlinked to the auto_boss.sh +# script that provides an executable map to identify valid filesystems that +# are exported. +# +/users auto_users -nobrowse +/proj auto_proj -nobrowse +/groups auto_groups -nobrowse diff --git a/autofs/autofs_boss.sh.in b/autofs/autofs_boss.sh.in new file mode 100644 index 0000000000..517bd23503 --- /dev/null +++ b/autofs/autofs_boss.sh.in @@ -0,0 +1,71 @@ +#!/bin/sh +# +# Copyright (c) 2000-2015 University of Utah and the Flux Group. +# +# {{{EMULAB-LICENSE +# +# This file is part of the Emulab network testbed software. +# +# This file is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or (at +# your option) any later version. +# +# This file is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public +# License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this file. If not, see <http://www.gnu.org/licenses/>. +# +# }}} +# + +# +# Script invoked by FreeBSD autofs to return info for valid fs mountpoints. +# Must be executable and must be a /bin/sh script. +# +TB=@prefix@ + +mountopts="-nosuid,vers=3,tcp" + +case $0 in +*auto_users*) + map=users + ;; +*auto_proj*) + map=proj + ;; +*auto_groups*) + map=groups + ;; +*auto_scratch*) + map=scratch + ;; +*) + exit 1 + ;; +esac + +if [ $# -eq 0 ]; then + if [ ! -f "$TB/etc/validmounts.txt" ]; then + exit 1 + fi + + list=`grep -s "^/$map/" $TB/etc/validmounts.txt | sed -e "s;^/$map/;;"` + for l in $list; do + echo "$l $mountopts fs:/$map/$l" + done + exit 0 +fi + +key=$1 +if test -f "$TB/etc/validmounts.txt" && + ! grep -q "^/$map/$key\$" $TB/etc/validmounts.txt; then + # apparently returning no error is the right thing do to + exit 0 +fi + +echo "$mountopts fs:/$map/$key" +exit 0 diff --git a/configure b/configure index 2ed7d5638f..b9a5b0546f 100755 --- a/configure +++ b/configure @@ -6992,7 +6992,7 @@ outfiles="$outfiles Makeconf GNUmakefile \ xmlrpc/imageid xmlrpc/osid xmlrpc/server xmlrpc/xmlrpcbag \ cdrom/GNUmakefile cdrom/tbbootconfig/GNUmakefile \ cdrom/groklilo/GNUmakefile \ - flash/GNUmakefile \ + autofs/GNUmakefile flash/GNUmakefile \ dhcpd/dhcpd.conf.template dhcpd/GNUmakefile \ dhcpd/dhcpd.conf.subboss.template \ ntpd/GNUmakefile \ diff --git a/configure.ac b/configure.ac index c686e225d6..2d3dfe25c5 100644 --- a/configure.ac +++ b/configure.ac @@ -1361,7 +1361,7 @@ outfiles="$outfiles Makeconf GNUmakefile \ xmlrpc/imageid xmlrpc/osid xmlrpc/server xmlrpc/xmlrpcbag \ cdrom/GNUmakefile cdrom/tbbootconfig/GNUmakefile \ cdrom/groklilo/GNUmakefile \ - flash/GNUmakefile \ + autofs/GNUmakefile flash/GNUmakefile \ dhcpd/dhcpd.conf.template dhcpd/GNUmakefile \ dhcpd/dhcpd.conf.subboss.template \ ntpd/GNUmakefile \ diff --git a/defs-default b/defs-default index cfdd8d3ed8..190596a985 100644 --- a/defs-default +++ b/defs-default @@ -182,6 +182,8 @@ ZFS_QUOTA_USER="1G" ZFS_QUOTA_PROJECT="100G" ZFS_QUOTA_GROUP="5G" ZFS_NOEXPORT=1 + +# WITHZFS only: use AMD instead of autofs for /proj, /users mounts on boss WITHAMD=0 # Utah-only hacked mountd -- GitLab