From 8e3d7dfa20b966b928078d8071d10fb186a0d781 Mon Sep 17 00:00:00 2001 From: Cullum Smith Date: Mon, 21 Oct 2024 09:17:49 -0400 Subject: cleanup nfs1 host script --- files/etc/cron.d/poudriere.pkg_server | 1 + files/etc/cron.d/zfs-trim.freebsd | 4 +- .../local/libexec/poudriere-cron.pkg_repository | 2 +- lib/30-files | 9 ++ scripts/hostclass/nfs_server | 3 + scripts/hostclass/pkg_repository | 3 +- scripts/hostname/nfs1 | 134 --------------------- scripts/hostname/nfs1/10-homedirs | 50 ++++++++ scripts/hostname/nfs1/20-shares | 11 ++ scripts/hostname/nfs1/30-autofs | 81 +++++++++++++ 10 files changed, 158 insertions(+), 140 deletions(-) create mode 100644 files/etc/cron.d/poudriere.pkg_server delete mode 100644 scripts/hostname/nfs1 create mode 100644 scripts/hostname/nfs1/10-homedirs create mode 100644 scripts/hostname/nfs1/20-shares create mode 100644 scripts/hostname/nfs1/30-autofs diff --git a/files/etc/cron.d/poudriere.pkg_server b/files/etc/cron.d/poudriere.pkg_server new file mode 100644 index 0000000..57d9dac --- /dev/null +++ b/files/etc/cron.d/poudriere.pkg_server @@ -0,0 +1 @@ +@weekly root lockf -t 0 /tmp/poudriere-cron.lock /usr/local/libexec/poudriere-cron $(echo "$poudriere_versions" | tr . _) diff --git a/files/etc/cron.d/zfs-trim.freebsd b/files/etc/cron.d/zfs-trim.freebsd index 64b07b9..80e0cd5 100644 --- a/files/etc/cron.d/zfs-trim.freebsd +++ b/files/etc/cron.d/zfs-trim.freebsd @@ -1,3 +1 @@ -SHELL=/bin/sh -PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin -@weekly root zfs list -Ho name | xargs -r -n1 zpool trim +@weekly root zpool list -Ho name | xargs -r -n1 zpool trim diff --git a/files/usr/local/libexec/poudriere-cron.pkg_repository b/files/usr/local/libexec/poudriere-cron.pkg_repository index b79535b..f7a5c1c 100644 --- a/files/usr/local/libexec/poudriere-cron.pkg_repository +++ b/files/usr/local/libexec/poudriere-cron.pkg_repository @@ -16,7 +16,7 @@ done for jail in "$@"; do poudriere jail -u -j "$jail" > /dev/null - poudriere bulk -j "$jail" -f /usr/local/etc/poudriere.d/pkglist-idm -p "$ports_tree" -z idm > /dev/null + poudriere bulk -j "$jail" -f /usr/local/etc/poudriere.d/idm-pkglist -p "$ports_tree" -z idm > /dev/null poudriere bulk -j "$jail" -f /usr/local/etc/poudriere.d/pkglist -p "$ports_tree" > /dev/null done diff --git a/lib/30-files b/lib/30-files index 767bbeb..4ba6587 100644 --- a/lib/30-files +++ b/lib/30-files @@ -179,3 +179,12 @@ install_ca_certificate(){ install -m "$_bcicc_mode" $_bcicc_install_args "${BOXCONF_CA_DIR}/ca.crt" "$1" log "installed root CA to ${1}" } + +set_facl(){ + # Replaces the NFSv4 ACL on a file with the specified ACL list. + # $1 = path + # $2-$N = ACL entries + [ "$BOXCONF_OS" = freebsd ] || bug 'set_facl only supported on FreeBSD' + _bcsetfacl_path=$1; shift + setfacl -b -a 0 "$(join ',' "$@")" "$_bcsetfacl_path" +} diff --git a/scripts/hostclass/nfs_server b/scripts/hostclass/nfs_server index ec06bfe..a775859 100644 --- a/scripts/hostclass/nfs_server +++ b/scripts/hostclass/nfs_server @@ -13,6 +13,9 @@ nfs_dataset="${state_dataset}/nfs" # Create ZFS dataset for NFS share. create_dataset -o "mountpoint=${nfs_root}" "${nfs_dataset}" +# Allow NFSv4 ACLs to propagate. +zfs set aclinherit=passthrough aclmode=passthrough "$nfs_dataset" + # Create nfs service principal and keytab. add_principal -nokey -x "containerdn=${services_basedn}" "nfs/${fqdn}" ktadd -k "${keytab_dir}/host.keytab" "nfs/${fqdn}" diff --git a/scripts/hostclass/pkg_repository b/scripts/hostclass/pkg_repository index 7226b77..969dff7 100644 --- a/scripts/hostclass/pkg_repository +++ b/scripts/hostclass/pkg_repository @@ -99,8 +99,7 @@ install_directory -m 0555 "${poudriere_data_dir}/data/packages/poudriere" # Create cron job to update packages automatically. install_file -m 0555 /usr/local/libexec/poudriere-cron -echo "@weekly root lockf -t 0 /tmp/poudriere-cron.lock /usr/local/libexec/poudriere-cron $(echo "$poudriere_versions" | tr . _)" \ - | tee /etc/cron.d/poudriere +install_file -m 0644 /etc/cron.d/poudriere # Now that we have a valid repo, switch the pkg repo to the local filesystem. install_directory -m 0755 \ diff --git a/scripts/hostname/nfs1 b/scripts/hostname/nfs1 deleted file mode 100644 index 673c7a9..0000000 --- a/scripts/hostname/nfs1 +++ /dev/null @@ -1,134 +0,0 @@ -#!/bin/sh - -nfs_mount_opts='-nfsv4,gssname=host,sec=krb5p' - -default_priv_quota=250G -default_pub_quota=10G - -# Add /home autofs map. -ldap_add "automountKey=/home,automountMapName=auto_master,${automount_basedn}" <