implement adding users
This commit is contained in:
parent
0f9f1a84f9
commit
bc0f9db31d
4 changed files with 34 additions and 5 deletions
|
@ -15,14 +15,21 @@ require 'ostruct'
|
|||
# dat command service zulip
|
||||
|
||||
module Execute
|
||||
attr_accessor :options
|
||||
|
||||
def context(new_value = nil)
|
||||
@options = new_value
|
||||
end
|
||||
|
||||
class ServiceInstallContext
|
||||
attr_accessor :bin_dir, :data_dir, :version, :user_name
|
||||
attr_accessor :bin_dir, :data_dir, :version, :user_name, :forced
|
||||
|
||||
def initialize(bin_dir, data_dir, user_name, version)
|
||||
def initialize(bin_dir, data_dir, user_name, version, forced = false)
|
||||
@bin_dir = bin_dir
|
||||
@data_dir = data_dir
|
||||
@user_name = user_name
|
||||
@version = version
|
||||
@forced = forced
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -73,7 +80,7 @@ module Execute
|
|||
bin_dir = pdata.get_prefix
|
||||
data_dir = "/data/#{pdata.name}/#{pdata.version.split(".").first}"
|
||||
service_install_context = ServiceInstallContext.new(
|
||||
bin_dir, data_dir, name, pdata.version
|
||||
bin_dir, data_dir, name, pdata.version, @options.forced
|
||||
)
|
||||
|
||||
case name
|
||||
|
@ -130,6 +137,7 @@ module Execute
|
|||
def self.file(options)
|
||||
dsl = Object.new
|
||||
dsl.extend(Execute)
|
||||
dsl.options = options
|
||||
|
||||
# Configfile
|
||||
path = File.join(Dir.pwd, options.name || "./Configfile")
|
||||
|
|
|
@ -29,13 +29,14 @@ module Make
|
|||
|
||||
class Context
|
||||
attr_accessor :name, :use_cache, :environment, :steps, :packages, :repository
|
||||
attr_accessor :target, :archive, :source_type, :version
|
||||
attr_accessor :target, :archive, :source_type, :version, :forced
|
||||
|
||||
def initialize(options: OpenStruct.new)
|
||||
@target = options.target || :user
|
||||
|
||||
@name = options.name
|
||||
@use_cache = options.use_cache || false
|
||||
@forced = options.forced || false
|
||||
|
||||
#System.detect_os
|
||||
# rbenv: brew install rbenv && rbenv install 3.0.0
|
||||
|
|
|
@ -14,7 +14,21 @@ module Setup
|
|||
# attr_accessor :te
|
||||
|
||||
def self.init_db(context)
|
||||
system(" -D /opt/pgsql/16/data")
|
||||
puts "Mode, isForced #{context.forced}"
|
||||
if Dir.exist?(context.data_dir)
|
||||
if context.forced
|
||||
puts("sudo rm -rf #{context.data_dir}")
|
||||
else
|
||||
raise "PostgreSQL data already exists"
|
||||
end
|
||||
end
|
||||
system("sudo mkdir -p #{context.data_dir}")
|
||||
system("sudo chown #{context.user_name}:services #{context.data_dir}")
|
||||
system("sudo -u postgresql #{File.join(context.bin_dir, "/bin/initdb")} -D #{context.data_dir}")
|
||||
end
|
||||
|
||||
def self.setup_systemd(context)
|
||||
|
||||
end
|
||||
|
||||
def self.install(context)
|
||||
|
@ -34,6 +48,8 @@ module Setup
|
|||
|
||||
user_context = Execute::UserInstallContext.new(context.user_name, :service)
|
||||
User.install(user_context)
|
||||
init_db(context)
|
||||
setup_systemd(context)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue