1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2006-2015 OpenWrt.org
5 PROG=/usr/bin/postmaster
9 EXTRA_COMMANDS="status"
10 EXTRA_HELP=" status Show current status of the PostgreSQL server"
13 # make sure localhost (without a dot) is in /etc/hosts
14 grep -q 'localhost$' /etc/hosts || echo '127.0.0.1 localhost' >> /etc/hosts
18 # for whatever reason, /dev/null gets wrong perms
23 if [ -f "$1/postmaster.pid" ]; then
24 rm "$1/postmaster.pid"
29 . /lib/functions/postgresql.sh
31 config_load "postgresql"
32 config_get pgdata config PGDATA
33 config_get pgopts config PGOPTS
35 user_exists postgres 5432 || user_add postgres 5432
36 group_exists postgres 5432 || group_add postgres 5432
41 if [ ! -d "${pgdata}" ]; then
42 pg_init_data ${pgdata}
43 [ $? -gt 0 ] && return 1
49 procd_set_param user postgres
50 procd_set_param command $PROG
51 procd_append_param command -D "${pgdata}"
52 [ -n "${pgopts}" ] && procd_append_param command -o "${pgopts}"
53 procd_set_param respawn retry=60
57 procd_set_param user postgres
58 procd_set_param command /lib/functions/postgresql.sh init "${pgdata}"
63 config_load "postgresql"
64 config_get pgdata config PGDATA
65 /usr/bin/pg_ctl reload -U postgres -D "${pgdata}" -s
69 config_load "postgresql"
70 config_get pgdata config PGDATA
71 /usr/bin/pg_ctl stop -U postgres -D "${pgdata}" -s
75 config_load "postgresql"
76 config_get pgdata config PGDATA
77 /usr/bin/pg_ctl status -U postgres -D "${pgdata}"