correct postgresql.init to newer conventions
git-svn-id: svn://svn.openwrt.org/openwrt/packages@7518 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
7a467e8942
commit
b41e7a725e
@ -2,29 +2,38 @@
|
|||||||
# Copyright (C) 2006 OpenWrt.org
|
# Copyright (C) 2006 OpenWrt.org
|
||||||
START=50
|
START=50
|
||||||
|
|
||||||
|
config_load "postgresql"
|
||||||
|
config_get pgdata config PGDATA
|
||||||
|
config_get pguser config PGUSER
|
||||||
|
config_get pgctl config PG_CTL
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
config_load "postgresql"
|
|
||||||
if [ ! -e /bin/su ]; then
|
if [ ! -e /bin/su ]; then
|
||||||
echo "The su command is requred to run postgres"
|
echo "The su command is requred to run postgres"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
config_get pgdata config PGDATA
|
|
||||||
|
|
||||||
if [ ! -d ${pgdata} ]; then
|
if [ ! -d ${pgdata} ]; then
|
||||||
echo "Create the data directory (${pgdata}) and try again"
|
echo "Create the data directory (${pgdata}) and try again"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# make sure localhost (without a dot) is in /etc/hosts
|
||||||
|
grep -q 'localhost$' /etc/hosts || echo '127.0.0.1 localhost' >> /etc/hosts
|
||||||
|
|
||||||
|
# for whatever reason, /dev/null gets wrong perms
|
||||||
|
chmod a+w /dev/null
|
||||||
|
|
||||||
if [ -f ${pgdata}/postmaster.pid ]; then
|
if [ -f ${pgdata}/postmaster.pid ]; then
|
||||||
rm ${pgdata}/postmaster.pid
|
rm ${pgdata}/postmaster.pid
|
||||||
fi
|
fi
|
||||||
|
|
||||||
config_get pguser config PGUSER
|
|
||||||
config_get pglog config PGLOG
|
config_get pglog config PGLOG
|
||||||
config_get pgctl config PG_CTL
|
|
||||||
config_get pgopts config PGOPTS
|
config_get pgopts config PGOPTS
|
||||||
|
if [ -n "${pgopts}" ]; then
|
||||||
/bin/su - ${pguser} -c "${pgctl} start -D '${pgdata}' -s -l '${pglog}' -o '${pgopts}'"
|
pgopts="-o ${pgopts}"
|
||||||
|
fi
|
||||||
|
/bin/su ${pguser} -c "${pgctl} start -D ${pgdata} -s -l ${pglog} ${pgopts}"
|
||||||
|
|
||||||
while :
|
while :
|
||||||
do
|
do
|
||||||
@ -32,7 +41,7 @@ start() {
|
|||||||
if [ -f "${pgdata}/postmaster.pid" ]; then
|
if [ -f "${pgdata}/postmaster.pid" ]; then
|
||||||
ret=0
|
ret=0
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ${cnt} -eq 30 ]; then
|
if [ ${cnt} -eq 30 ]; then
|
||||||
echo "Postgres failed to start. See ${pglog} for details"
|
echo "Postgres failed to start. See ${pglog} for details"
|
||||||
@ -44,3 +53,9 @@ start() {
|
|||||||
|
|
||||||
return ${ret}
|
return ${ret}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
|
||||||
|
/bin/su ${pguser} -c "${pgctl} stop -D '${pgdata}'"
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user