-
-
Save azizshamim/5736498 to your computer and use it in GitHub Desktop.
Revisions
-
GUI revised this gist
Jun 3, 2012 . 1 changed file with 16 additions and 18 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,27 +1,25 @@ #!/bin/bash # Script for placing sudoers.d files with syntax-checking # Making a temporary file to contain the sudoers-changes to be pre-checked TMP=$(mktemp -t vagrant_sudoers) cat /etc/sudoers > $TMP cat >> $TMP <<EOF # Allow passwordless startup of Vagrant when using NFS. Cmnd_Alias VAGRANT_EXPORTS_ADD = /usr/bin/su root -c echo '*' >> /etc/exports Cmnd_Alias VAGRANT_NFSD = /sbin/nfsd restart Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /usr/bin/sed -e /*/ d -ibak /etc/exports %staff ALL=(root) NOPASSWD: VAGRANT_EXPORTS_ADD, VAGRANT_NFSD, VAGRANT_EXPORTS_REMOVE EOF # Check if the changes we want are OK visudo -c -f $TMP if [ $? -eq 0 ]; then echo "Adding vagrant commands to sudoers" cat $TMP > /etc/sudoers else echo "sudoers syntax wasn't valid. Aborting!" fi rm -f $TMP -
GUI revised this gist
Jun 3, 2012 . 1 changed file with 22 additions and 19 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,22 +3,25 @@ if [ -z "$1" ]; then # Making a temporary file to contain the sudoers-changes to be pre-checked TMP=$(mktemp -t vagrant_sudoers) cat /etc/sudoers > $TMP cat >> $TMP <<EOF # Allow passwordless startup of Vagrant when using NFS. Cmnd_Alias VAGRANT_EXPORTS_ADD = /usr/bin/su root -c echo '*' >> /etc/exports Cmnd_Alias VAGRANT_NFSD = /sbin/nfsd restart Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /usr/bin/sed -e /*/ d -ibak /etc/exports %staff ALL=(root) NOPASSWD: VAGRANT_EXPORTS_ADD, VAGRANT_NFSD, VAGRANT_EXPORTS_REMOVE EOF # Check if the changes we want are OK visudo -c -f $TMP if [ $? -eq 0 ]; then echo "Adding vagrant commands to sudoers" cat $TMP > /etc/sudoers else echo "sudoers syntax wasn't valid. Aborting!" fi rm -f $TMP fi -
Jan Ivar Beddari created this gist
Dec 13, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ #!/bin/bash # Script for placing sudoers.d files with syntax-checking if [ -z "$1" ]; then # Making a temporary file to contain the sudoers-changes to be pre-checked TMP=$(mktemp) cat > $TMP <<EOF Cmnd_Alias VAGRANT_EXPORTS_ADD = /bin/su root -c echo '*' >> /etc/exports Cmnd_Alias VAGRANT_NFSD = /etc/init.d/nfs-kernel-server restart Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /bin/sed -e /*/ d -ibak /etc/exports %admin ALL=(root) NOPASSWD: VAGRANT_EXPORTS_ADD, VAGRANT_NFSD, VAGRANT_EXPORTS_REMOVE EOF # Check if the changes we want are OK visudo -c -f $TMP if [ $? -eq 0 ]; then # This computes! Starting up visudo with this script as first parameter export EDITOR=$0 && export FILE_OK=$TMP && sudo -E visudo -f /etc/sudoers.d/vagrant_sudoers fi else # Copying changes to the visudo-managed tmp-file cat $FILE_OK | tee -a $1 rm -f $FILE_OK fi # Exiting, visudo will check syntax again (which we already know is OK)