implement adding users

This commit is contained in:
Artur Gurgul1 2025-08-07 17:36:47 +02:00
parent 0f9f1a84f9
commit bc0f9db31d
4 changed files with 34 additions and 5 deletions

View file

@ -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