Skip to content

Commit

Permalink
re-factored
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Cunnie & Matthew Kocher committed Oct 26, 2011
1 parent a38acac commit aeabb6c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions recipes/add_ops_user.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#password_hash = node[:users][:operations][:password_hash] || "!NOLOGIN"
#password_hash = "!NOLOGIN"
require 'etc'

# Find the first available uid > 500
# Find the first available uid > 500 so it shows up in System Preferences
uids = `dscl . -list /Users UniqueID`.split("\n").collect { |pair| pair.squeeze(" ").split(" ").last.to_i }
uid = 501
while ( uids.include?(uid) ) do
Expand All @@ -11,13 +12,15 @@
username="ops"
user username do
comment username.capitalize
gid 20
gid Etc.getgrnam("staff").gid
uid uid
home "/Users/#{username}"
shell "/bin/bash"
not_if Kernel.system("id santa").to_s
not_if "id #{username}"
end

execute "defaults write /var/db/dslocal/nodes/Default/users/#{username} ShadowHashData -array -data \"#{node["ops_user_password_hash"]}\""

group "admin" do
members [username]
append true
Expand Down

0 comments on commit aeabb6c

Please sign in to comment.