Sha256: be4c2cbbbe53dceb0913e1298301143a8dccf6b56468624b8126d72475e25df2

Contents?: true

Size: 849 Bytes

Versions: 9

Compression:

Stored size: 849 Bytes

Contents

# frozen_string_literal: true

module Getch
  module Config
    class Account
      def initialize
        @user = OPTIONS[:username] ||= nil
        @log = Log.new
      end

      def root
        @log.info "Add a password for root.\n"
        ChrootOutput.new('passwd')
      end

      def new_user
        return unless @user

        create_user
        @log.info "Add a password for #{@user}.\n"
        ChrootOutput.new("passwd #{@user}")
        fix_perm
      end

      private

      def create_user
        @log.info "Creating a new user #{@user}..."
        Getch::Chroot.new("useradd -m -G users,wheel,audio,video #{@user}")
        @log.result_ok
      end

      def fix_perm
        Getch::Chroot.new("chown -R #{@user}:#{@user} /home/#{@user}")
        Getch::Chroot.new("chmod 700 -R /home/#{@user}")
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
getch-0.11.0 lib/getch/config/account.rb
getch-0.7.3 lib/getch/config/account.rb
getch-0.7.0 lib/getch/config/account.rb
getch-0.5.0 lib/getch/config/account.rb
getch-0.3.6 lib/getch/config/account.rb
getch-0.3.5 lib/getch/config/account.rb
getch-0.3.4 lib/getch/config/account.rb
getch-0.3.3 lib/getch/config/account.rb
getch-0.3.0 lib/getch/config/account.rb