File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4747 " git-submodules" ,
4848 " init-repo" ,
4949 " migrations" ,
50+ " nfsexports-setsudoaccess" ,
5051 " paths" ,
5152 " pear-install-deps" ,
5253 " pear-package-installed" ,
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ # ---------------------------------------------------------------------
4+ usage ()
5+ {
6+ cat << EOT
7+
8+ ${0##*/ }
9+ Script to inject the proper command exceptions into a system's
10+ /etc/sudoers file to allow vagrant to modify /etc/exports for
11+ NFS shared folder use without prompting the user for an
12+ administrator password during \` vagrant up\` .
13+ See: https://docs.vagrantup.com/v2/synced-folders/nfs.html
14+ Has no effect if run repeatedly.
15+
16+ Usage:
17+ bin/${0##*/ }
18+
19+
20+ EOT
21+
22+ exit 0
23+ }
24+ if [ " $1 " = ' -h' ]; then
25+ usage
26+ fi
27+
28+ # Make sure only root can run our script
29+ if [[ $EUID -ne 0 ]]; then
30+ echo " !! This script must be run using sudo." 1>&2
31+ exit 1
32+ fi
33+
34+ comment=" Allow Vagrant with NFS without requiring a password"
35+ if grep -q " $comment " " /etc/sudoers" ; then
36+ echo ' Vagrant permissions already present in /etc/sudoers' ;
37+ else
38+ echo ' Adding Vagrant permissions into /etc/sudoers' ;
39+ cat << EOF >> /etc/sudoers
40+
41+ # $comment
42+ Cmnd_Alias VAGRANT_EXPORTS_ADD = /usr/bin/tee -a /etc/exports
43+ Cmnd_Alias VAGRANT_NFSD = /sbin/nfsd restart
44+ Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /usr/bin/sed -E -e /*/ d -ibak /etc/exports
45+ %admin ALL=(root) NOPASSWD: VAGRANT_EXPORTS_ADD, VAGRANT_NFSD, VAGRANT_EXPORTS_REMOVE
46+ EOF
47+ fi
You can’t perform that action at this time.
0 commit comments