forked from ungleich-public/cdist
[type/__postgres_database] Include postgres_user explorer from __postgres_conf
This commit is contained in:
parent
512e9b23c0
commit
6ac8cbf98f
3 changed files with 8 additions and 29 deletions
1
cdist/conf/type/__postgres_database/explorer/postgres_user
Symbolic link
1
cdist/conf/type/__postgres_database/explorer/postgres_user
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../../__postgres_conf/explorer/postgres_user
|
|
@ -1,6 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||||
|
# 2021 Dennis Camera (dennis.camera at ssrq-sds-fds.ch)
|
||||||
#
|
#
|
||||||
# This file is part of cdist.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -18,23 +19,11 @@
|
||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
case "$("${__explorer}/os")"
|
postgres_user=$("${__type_explorer:?}/postgres_user")
|
||||||
in
|
|
||||||
netbsd)
|
|
||||||
postgres_user='pgsql'
|
|
||||||
;;
|
|
||||||
openbsd)
|
|
||||||
postgres_user='_postgresql'
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
postgres_user='postgres'
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
|
name=${__object_id:?}
|
||||||
|
|
||||||
name="$__object_id"
|
if test -n "$(su - "${postgres_user}" -c "psql postgres -twAc \"SELECT 1 FROM pg_database WHERE datname='${name}'\"")"
|
||||||
|
|
||||||
if test -n "$(su - "$postgres_user" -c "psql postgres -twAc \"SELECT 1 FROM pg_database WHERE datname='$name'\"")"
|
|
||||||
then
|
then
|
||||||
echo 'present'
|
echo 'present'
|
||||||
else
|
else
|
||||||
|
|
|
@ -18,23 +18,12 @@
|
||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
case "$(cat "${__global}/explorer/os")"
|
|
||||||
in
|
|
||||||
netbsd)
|
|
||||||
postgres_user='pgsql'
|
|
||||||
;;
|
|
||||||
openbsd)
|
|
||||||
postgres_user='_postgresql'
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
postgres_user='postgres'
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
|
|
||||||
name="$__object_id"
|
name="$__object_id"
|
||||||
state_should="$(cat "$__object/parameter/state")"
|
state_should="$(cat "$__object/parameter/state")"
|
||||||
state_is="$(cat "$__object/explorer/state")"
|
state_is="$(cat "$__object/explorer/state")"
|
||||||
|
postgres_user=$(cat "${__object:?}/explorer/postgres_user")
|
||||||
|
|
||||||
if [ "$state_should" != "$state_is" ]; then
|
if [ "$state_should" != "$state_is" ]; then
|
||||||
case "$state_should" in
|
case "$state_should" in
|
||||||
|
|
Loading…
Reference in a new issue