Class: SmartCloud::User

Inherits:
Base
  • Object
show all
Defined in:
lib/smart_cloud/user.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logger

configure_logger_for, included, #logger, logger_for

Constructor Details

#initializeUser

Returns a new instance of User.



8
9
# File 'lib/smart_cloud/user.rb', line 8

def initialize
end

Class Method Details

.create_htpasswd_filesObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/smart_cloud/user.rb', line 11

def self.create_htpasswd_files
	htpasswd_dirpath = "#{Dir.pwd}/grids/nginx/htpasswd"

	# Remove existing htpasswd_dirpath
	FileUtils.rm_r htpasswd_dirpath if Dir.exist?(htpasswd_dirpath)
	
	# Create new htpasswd_dirpath
	FileUtils.mkdir htpasswd_dirpath

	# Add hostfiles to htpasswd_dirpath
	self.get_users_from_file.each do |domainname, users|
		next unless users

		file_data = ""
		users.each do |user, password|
			file_data += "#{user}:#{BCrypt::Password.create(password)}\n"
		end
		File.open("#{Dir.pwd}/grids/nginx/htpasswd/#{domainname}", "w") { |file| file.write(file_data) }
	end
end