source: packages/libs/postgresql/files/postgresql.init @ 7164

Last change on this file since 7164 was 7164, checked in by mbm, 10 years ago

START/STOP values must be specified in the init script

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 1.0 KB
Line 
1#!/bin/sh /etc/rc.common
2# Copyright (C) 2006 OpenWrt.org
3START=50
4
5start() {
6    config_load "postgresql"
7    if [ ! -e /bin/su ]; then
8        echo "The su command is requred to run postgres"
9        exit 1
10    fi
11    config_get pgdata config PGDATA
12
13    if [ ! -d ${pgdata} ]; then
14        echo "Create the data directory (${pgdata}) and try again"
15        exit 1
16    fi
17
18    if [ -f ${pgdata}/postmaster.pid ]; then
19        rm ${pgdata}/postmaster.pid
20    fi
21
22    config_get pguser config PGUSER
23    config_get pglog config PGLOG
24    config_get pgctl config PG_CTL
25    config_get pgopts config PGOPTS
26
27    /bin/su - ${pguser} -c "${pgctl} start -D '${pgdata}' -s -l '${pglog}' -o '${pgopts}'"
28
29    while :
30    do
31        cnt=$((${cnt} + 1))
32        if [ -f "${pgdata}/postmaster.pid" ]; then
33            ret=0
34            break
35        fi
36
37        if [ ${cnt} -eq 30 ]; then
38            echo "Postgres failed to start.  See ${pglog} for details"
39            ret=1
40            break
41        fi
42        sleep 1
43    done
44
45    return ${ret}
46}
Note: See TracBrowser for help on using the repository browser.