postgresql.lua 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. local postgres_data_dir="/var/lib/postgres/data"
  2. local postgres_pid_dir="/run/postgresql"
  3. if loconfig and loconfig.data_dir then postgres_data_dir=loconfig.data_dir end
  4. local task={
  5. desc="PostgreSQL daemon",
  6. program="postgres",
  7. start=function()
  8. _,control=l5.readlink("/usr/bin/psql")
  9. if control == 2 then
  10. print("postgresql kurulu değil!")
  11. result=false
  12. return result
  13. end
  14. _,control=l5.readlink(postgres_pid_dir)
  15. if control == 2 then
  16. action("install -v -dm755 "..postgres_pid_dir)
  17. action("chown -Rv postgres:postgres /run/postgresql")
  18. end
  19. _,control=l5.readlink(postgres_data_dir.."/base")
  20. -- control=2 file not exist
  21. if control == 2 then
  22. action("chsh -s /bin/bash postgres")
  23. action("install -v -dm700 "..postgres_data_dir)
  24. action("chown -Rv postgres:postgres "..postgres_data_dir)
  25. initdb_cmd="su - postgres -c '/usr/bin/initdb -E UTF8 -D %s'"
  26. action(initdb_cmd:format(postgres_data_dir))
  27. end
  28. start_cmd="su - postgres -c '/usr/bin/pg_ctl start -s -W -D "..postgres_data_dir..
  29. " -l "..postgres_data_dir.."/logfile -o \"-i\" '"
  30. action(start_cmd)
  31. result=0
  32. return result
  33. end,
  34. stop={
  35. cmd="su - postgres -c '/usr/bin/pg_ctl stop -s -m smart -D "..postgres_data_dir.."'",
  36. },
  37. status={
  38. cmd="su - postgres -c '/usr/bin/pg_ctl status -D "..postgres_data_dir.."'",
  39. },
  40. }
  41. return task