mirror of
https://github.com/openwrt/packages.git
synced 2025-12-22 06:04:31 +04:00
postgresql: update to version 9.5.4 and major rework
* convert package build to use host-build for ecpg, pg_config and zic * introduce /lib/functions/postgresql.sh to be used by packages requiring a postgres database to exist as well as postgres' init * no longer require shadow-su, patch pg_ctl to setuid() ifself instead * auto-create database directory if there is enough free space * auto-create databases configured in UCI * remove some dead uci config options * grab maintainership Signed-off-by: Daniel Golle <daniel@makrotopia.org>
This commit is contained in:
@@ -26,48 +26,47 @@ cleanup() {
|
||||
}
|
||||
|
||||
start_service() {
|
||||
. /lib/functions/postgresql.sh
|
||||
|
||||
config_load "postgresql"
|
||||
config_get pgdata config PGDATA
|
||||
config_get pguser config PGUSER
|
||||
config_get pgctl config PG_CTL
|
||||
config_get pgopts config PGOPTS
|
||||
|
||||
user_exists postgres 5432 || user_add postgres 5432
|
||||
group_exists postgres 5432 || group_add postgres 5432
|
||||
|
||||
if [ ! -d "${pgdata}" ]; then
|
||||
echo "Create the data directory (${pgdata}) and try again"
|
||||
return 1
|
||||
fi
|
||||
|
||||
fix_perms
|
||||
fix_hosts
|
||||
|
||||
procd_open_instance
|
||||
if [ ! -d "${pgdata}" ]; then
|
||||
pg_init_data ${pgdata}
|
||||
[ $? -gt 0 ] && return 1
|
||||
fi
|
||||
|
||||
procd_set_param user ${pguser}
|
||||
cleanup "${pgdata}"
|
||||
|
||||
procd_open_instance
|
||||
procd_set_param user postgres
|
||||
procd_set_param command $PROG
|
||||
procd_append_param command -D "${pgdata}"
|
||||
[ -n "${pgopts}" ] && procd_append_param command -o "${pgopts}"
|
||||
|
||||
procd_set_param respawn retry=60
|
||||
procd_close_instance
|
||||
|
||||
procd_open_instance
|
||||
procd_set_param user postgres
|
||||
procd_set_param command /lib/functions/postgresql.sh init "${pgdata}"
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
config_load "postgresql"
|
||||
config_get pgdata config PGDATA
|
||||
config_get pguser config PGUSER
|
||||
config_get pgctl config PG_CTL
|
||||
${pgctl} reload -U ${pguser} -D '${pgdata}' -s
|
||||
/usr/bin/pg_ctl reload -U postgres -D "${pgdata}" -s
|
||||
}
|
||||
|
||||
status() {
|
||||
config_load "postgresql"
|
||||
config_get pgdata config PGDATA
|
||||
config_get pguser config PGUSER
|
||||
config_get pgctl config PG_CTL
|
||||
echo "status postgres..."
|
||||
${pgctl} status -U ${pguser} -D '${pgdata}'
|
||||
echo "ok"
|
||||
/usr/bin/pg_ctl status -U postgres -D "${pgdata}"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user