Skip to content
Browse files

split logic into separate ci_user_nopasswd_sudo.sh script

  • Loading branch information...
1 parent d37ccaf commit 981e3f24e5c9af4c9cc717c37215da45fc8bc920 @thewoolleyman committed
Showing with 15 additions and 12 deletions.
  1. +14 −0 ci_user_nopasswd_sudo.sh
  2. +1 −12 create_ci_user.sh
View
14 ci_user_nopasswd_sudo.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+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
View
13 create_ci_user.sh
@@ -22,15 +22,4 @@ echo
sudo passwd ci
if [ ! $? = 0 ]; then echo "password assignment for CI user failed, aborting..." && exit 1; fi # Note that Ubuntu 8.10 returns zero even on passwd retype failure...
-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
+# Run ci_user_nopasswd_sudo.sh to give ci user no-password sudo authority

0 comments on commit 981e3f2

Please sign in to comment.
Something went wrong with that request. Please try again.