# File lib/openshift-origin-node/model/unix_user.rb, line 86
    def create
      skel_dir = @config.get("GEAR_SKEL_DIR") || DEFAULT_SKEL_DIR
      shell    = @config.get("GEAR_SHELL")     || "/bin/bash"
      gecos    = @config.get("GEAR_GECOS")     || "OO application container"
      notify_observers(:before_unix_user_create)
      basedir = @config.get("GEAR_BASE_DIR")

      # lock to prevent race condition between create and delete of gear
      uuid_lock_file = "/var/lock/oo-create.#{@uuid}"
      File.open(uuid_lock_file, File::RDWR|File::CREAT, 0o0600) do | uuid_lock |
        uuid_lock.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
        uuid_lock.flock(File::LOCK_EX)

        # Lock to prevent race condition on obtaining a UNIX user uid.
        # When running without districts, there is a simple search on the
        #   passwd file for the next available uid.
        File.open("/var/lock/oo-create", File::RDWR|File::CREAT, 0o0600) do | uid_lock |
          uid_lock.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
          uid_lock.flock(File::LOCK_EX)

          unless @uid
            @uid = @gid = next_uid
          end

          unless @homedir
            @homedir = File.join(basedir,@uuid)
          end

          cmd = %{useradd -u #{@uid} \
                  -d #{@homedir} \
                  -s #{shell} \
                  -c '#{gecos}' \
                  -m \
                  -k #{skel_dir} \
                  #{@uuid}}
          out,err,rc = shellCmd(cmd)
          raise UserCreationException.new(
                  "ERROR: unable to create user account #{@uuid}, #{cmd}"
                  ) unless rc == 0

          FileUtils.chown("root", @uuid, @homedir)
          FileUtils.chmod 0o0750, @homedir

          if @config.get("CREATE_APP_SYMLINKS").to_i == 1
            unobfuscated = File.join(File.dirname(@homedir),"#{@container_name}-#{namespace}")
            if not File.exists? unobfuscated
              FileUtils.ln_s File.basename(@homedir), unobfuscated, :force=>true
            end
          end
        end
        notify_observers(:after_unix_user_create)
        initialize_homedir(basedir, @homedir, @config.get("CARTRIDGE_BASE_PATH"))
        initialize_openshift_port_proxy

        uuid_lock.flock(File::LOCK_UN)
        File.unlink(uuid_lock_file)
      end
    end