public
Description: Continuous Integration. In a Box!
Homepage: http://github.com/thewoolleyman/cinabox/tree/master/README.txt
Clone URL: git://github.com/thewoolleyman/cinabox.git
cinabox / ci_user_nopasswd_sudo.sh
100644 15 lines (14 sloc) 0.706 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/bin/bash
 
# TODO: use a regexp to match any whitespace
sudo grep -q 'ci ALL=(ALL) NOPASSWD: ALL' /etc/sudoers
if [ ! $? = 0 ]; then
echo " Giving ci user NO PASSWORD sudo privileges"
  sudo rm -f /tmp/sudoers.tmp
  sudo cp /etc/sudoers /etc/sudoers.bak
  sudo cp /etc/sudoers /tmp/sudoers.tmp
  sudo sh -c 'echo "ci ALL=(ALL) NOPASSWD: ALL" >> /tmp/sudoers.tmp'
  if [ ! -e /tmp/sudoers.tmp ]; then echo "/tmp/sudoers.tmp does not exist, aborting before we blow away all sudo access and completely hose this system..." && exit 1; fi
sudo visudo -q -c -s -f /tmp/sudoers.tmp
  if [ ! $? = 0 ]; then echo "error editing sudoers file" && exit; fi
sudo cp /tmp/sudoers.tmp /etc/sudoers
fi