Guest User

freebsd_rc.d

a guest
Dec 13th, 2012
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # $FreeBSD: ports/databases/postgresql91-server/files/postgresql.in,v 1.6 2011/06/11 23:14:30 girgen Exp $
  4. #
  5. # PROVIDE: postgresql
  6. # REQUIRE: LOGIN
  7. # KEYWORD: shutdown
  8. #
  9. # Add the following line to /etc/rc.conf to enable PostgreSQL:
  10. #
  11. # postgresql_enable="YES"
  12. # # optional
  13. # postgresql_data="/usr/local/pgsql/data"
  14. # postgresql_flags="-w -s -m fast"
  15. # postgresql_initdb_flags="--encoding=utf-8 --lc-collate=C"
  16. # postgresql_class="default"
  17. #
  18. # See /usr/local/share/doc/postgresql/README-server for more info
  19. #
  20. # This scripts takes one of the following commands:
  21. #
  22. # start stop restart reload status initdb
  23. #
  24. # For postmaster startup options, edit ${postgresql_data}/postgresql.conf
  25.  
  26. command=/usr/local/bin/pg_ctl
  27.  
  28. . /etc/rc.subr
  29.  
  30. load_rc_config postgresql
  31.  
  32. # set defaults
  33. postgresql_enable=${postgresql_enable:-"NO"}
  34. postgresql_flags=${postgresql_flags:-"-w -s -m fast"}
  35. postgresql_user=${postgresql_user:-"pgsql"}
  36. eval postgresql_data=${postgresql_data:-"~${postgresql_user}/data"}
  37. postgresql_class=${postgresql_class:-"default"}
  38. postgresql_initdb_flags=${postgresql_initdb_flags:-"--encoding=utf-8 --lc-collate=C"}
  39.  
  40. name=postgresql
  41. rcvar=`set_rcvar`
  42. command_args="-D ${postgresql_data} ${postgresql_flags}"
  43. extra_commands="reload initdb"
  44.  
  45. start_cmd="postgresql_command start"
  46. stop_cmd="postgresql_command stop"
  47. restart_cmd="postgresql_command restart"
  48. reload_cmd="postgresql_command reload"
  49. status_cmd="postgresql_command status"
  50.  
  51. initdb_cmd="postgresql_initdb"
  52.  
  53. postgresql_command()
  54. {
  55. su -l ${postgresql_user} -c "exec ${command} ${command_args} ${rc_arg}"
  56. }
  57.  
  58. postgresql_initdb()
  59. {
  60. su -l -c ${postgresql_class} ${postgresql_user} -c "exec /usr/local/bin/initdb ${postgresql_initdb_flags} -D ${postgresql_data}"
  61. }
  62.  
  63. run_rc_command "$1"
Add Comment
Please, Sign In to add comment