Skip to content

Commit c6e2fb5

Browse files
committed
Add script for configuring nfsexport commands in /etc/sudoers
1 parent 8a4e481 commit c6e2fb5

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"git-submodules",
4848
"init-repo",
4949
"migrations",
50+
"nfsexports-setsudoaccess",
5051
"paths",
5152
"pear-install-deps",
5253
"pear-package-installed",

nfsexports-setsudoaccess

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
# Make sure only root can run our script
4+
if [[ $EUID -ne 0 ]]; then
5+
echo "This script must be run using sudo" 1>&2
6+
exit 1
7+
fi
8+
9+
comment="Allow Vagrant with NFS without requiring a password"
10+
if grep -q "$comment" "/etc/sudoers"; then
11+
echo 'Vagrant permissions already present in /etc/sudoers';
12+
else
13+
echo 'Adding Vagrant permissions into /etc/sudoers';
14+
cat <<EOF >> /etc/sudoers
15+
16+
# $comment
17+
Cmnd_Alias VAGRANT_EXPORTS_ADD = /usr/bin/tee -a /etc/exports
18+
Cmnd_Alias VAGRANT_NFSD = /sbin/nfsd restart
19+
Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /usr/bin/sed -E -e /*/ d -ibak /etc/exports
20+
%admin ALL=(root) NOPASSWD: VAGRANT_EXPORTS_ADD, VAGRANT_NFSD, VAGRANT_EXPORTS_REMOVE
21+
EOF
22+
fi

0 commit comments

Comments
 (0)