postgresql upgrade to 8.2.3, bringing in the server as well... this needs some data...
[openwrt/svn-archive/archive.git] / libs / postgresql / files / postgresql.init
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2006 OpenWrt.org
3
4 start() {
5 config_load "postgresql"
6 if [ ! -e /bin/su ]; then
7 echo "The su command is requred to run postgres"
8 exit 1
9 fi
10 config_get pgdata config PGDATA
11
12 if [ ! -d ${pgdata} ]; then
13 echo "Create the data directory (${pgdata}) and try again"
14 exit 1
15 fi
16
17 if [ -f ${pgdata}/postmaster.pid ]; then
18 rm ${pgdata}/postmaster.pid
19 fi
20
21 config_get pguser config PGUSER
22 config_get pglog config PGLOG
23 config_get pgctl config PG_CTL
24 config_get pgopts config PGOPTS
25
26 /bin/su - ${pguser} -c "${pgctl} start -D '${pgdata}' -s -l '${pglog}' -o '${pgopts}'"
27
28 while :
29 do
30 cnt=$((${cnt} + 1))
31 if [ -f "${pgdata}/postmaster.pid" ]; then
32 ret=0
33 break
34 fi
35
36 if [ ${cnt} -eq 30 ]; then
37 echo "Postgres failed to start. See ${pglog} for details"
38 ret=1
39 break
40 fi
41 sleep 1
42 done
43
44 return ${ret}
45 }