Sha256: 2a8f704e87ce04fad7a434bae8fa90d8a5a52361595fba5c030e9c5eb638875d

Contents?: true

Size: 836 Bytes

Versions: 5

Compression:

Stored size: 836 Bytes

Contents

module GitWit::Actions::Dscl
  class User < Base
    def initialize(base, name, home, config = {})
      super base, :user, name, config
      @home = home
    end

    def invoke!
      invoke_with_conflict_check do
        create
      end
      home
    end

    def revoke!
      say_status :remove, :red
      destroy if !pretend? && exists?
      home
    end

    protected
    def home
      @home || "/Users/#{name}"
    end

    def create
      uid = next_id
      sudo_dscl "create /Users/#{name}"
      sudo_dscl "create /Users/#{name} RealName '#{name}'"
      sudo_dscl "create /Users/#{name} UniqueID #{uid}"
      sudo_dscl "create /Users/#{name} NFSHomeDirectory '#{home}'"
      sudo_dscl "create /Users/#{name} UserShell '/bin/bash'"
    end

    def destroy
      sudo_dscl "delete /Users/#{name}"
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
git_wit-0.0.6 lib/git_wit/actions/dscl/user.rb
git_wit-0.0.6.pre lib/git_wit/actions/dscl/user.rb
git_wit-0.0.5 lib/git_wit/actions/dscl/user.rb
git_wit-0.0.4.pre2 lib/git_wit/actions/dscl/user.rb
git_wit-0.0.4.pre lib/git_wit/actions/dscl/user.rb