clean up postgresql init script to their recommended practices
git-svn-id: svn://svn.openwrt.org/openwrt/packages@10222 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
b3cc500bf9
commit
0e74f10bb8
@ -2,10 +2,13 @@
|
|||||||
# Copyright (C) 2006 OpenWrt.org
|
# Copyright (C) 2006 OpenWrt.org
|
||||||
START=50
|
START=50
|
||||||
|
|
||||||
|
EXTRA_COMMANDS="status reload"
|
||||||
|
|
||||||
config_load "postgresql"
|
config_load "postgresql"
|
||||||
config_get pgdata config PGDATA
|
config_get pgdata config PGDATA
|
||||||
config_get pguser config PGUSER
|
config_get pguser config PGUSER
|
||||||
config_get pgctl config PG_CTL
|
config_get pgctl config PG_CTL
|
||||||
|
config_get pglog config PGLOG
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
if [ ! -e /bin/su ]; then
|
if [ ! -e /bin/su ]; then
|
||||||
@ -18,6 +21,7 @@ start() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "starting postgres..."
|
||||||
# make sure localhost (without a dot) is in /etc/hosts
|
# make sure localhost (without a dot) is in /etc/hosts
|
||||||
grep -q 'localhost$' /etc/hosts || echo '127.0.0.1 localhost' >> /etc/hosts
|
grep -q 'localhost$' /etc/hosts || echo '127.0.0.1 localhost' >> /etc/hosts
|
||||||
|
|
||||||
@ -28,12 +32,11 @@ start() {
|
|||||||
rm ${pgdata}/postmaster.pid
|
rm ${pgdata}/postmaster.pid
|
||||||
fi
|
fi
|
||||||
|
|
||||||
config_get pglog config PGLOG
|
|
||||||
config_get pgopts config PGOPTS
|
config_get pgopts config PGOPTS
|
||||||
if [ -n "${pgopts}" ]; then
|
if [ -n "${pgopts}" ]; then
|
||||||
pgopts="-o ${pgopts}"
|
pgopts="-o ${pgopts}"
|
||||||
fi
|
fi
|
||||||
/bin/su ${pguser} -c "${pgctl} start -D ${pgdata} -s -l ${pglog} ${pgopts}"
|
/bin/su ${pguser} -c "/usr/bin/postgres -D '${pgdata}' &" >> ${pglog} 2>&1
|
||||||
|
|
||||||
while :
|
while :
|
||||||
do
|
do
|
||||||
@ -41,7 +44,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"
|
||||||
@ -51,11 +54,40 @@ start() {
|
|||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
|
||||||
|
echo "ok"
|
||||||
return ${ret}
|
return ${ret}
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
|
echo "stopping postgres..."
|
||||||
|
/bin/su ${pguser} -c "${pgctl} stop -D '${pgdata}' -s -m fast"
|
||||||
|
ret=$?
|
||||||
|
if [ -f ${pgdata}/postmaster.pid ]; then
|
||||||
|
rm ${pgdata}/postmaster.pid
|
||||||
|
fi
|
||||||
|
echo "ok"
|
||||||
|
return ${ret}
|
||||||
|
}
|
||||||
|
|
||||||
/bin/su ${pguser} -c "${pgctl} stop -D '${pgdata}'"
|
restart() {
|
||||||
|
echo "restarting postgres..."
|
||||||
|
/bin/su ${pguser} -c "${pgctl} stop -D '${pgdata}' -s -m fast -w"
|
||||||
|
if [ -f ${pgdata}/postmaster.pid ]; then
|
||||||
|
rm ${pgdata}/postmaster.pid
|
||||||
|
fi
|
||||||
|
/bin/su ${pguser} -c "/usr/bin/postgres -D '${pgdata}' &" >> ${pglog} 2>&1
|
||||||
|
echo "ok"
|
||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reload() {
|
||||||
|
echo "reloading postgres..."
|
||||||
|
/bin/su ${pguser} -c "${pgctl} reload -D '${pgdata}' -s"
|
||||||
|
echo "ok"
|
||||||
|
}
|
||||||
|
|
||||||
|
status() {
|
||||||
|
echo "status postgres..."
|
||||||
|
/bin/su ${pguser} -c "${pgctl} status -D '${pgdata}'"
|
||||||
|
echo "ok"
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user