nix: improve prymn_db script, adding a 'shell' command
This commit is contained in:
parent
818b20f775
commit
62c40358a2
1 changed files with 25 additions and 11 deletions
|
@ -15,6 +15,7 @@
|
||||||
export PGHOST=/tmp
|
export PGHOST=/tmp
|
||||||
export DB_LOG=$PROJECT_ROOT_DIR/.db/log
|
export DB_LOG=$PROJECT_ROOT_DIR/.db/log
|
||||||
|
|
||||||
|
start_db() {
|
||||||
if [ ! -d "$PGDATA" ]; then
|
if [ ! -d "$PGDATA" ]; then
|
||||||
initdb "$PGDATA" --auth=trust
|
initdb "$PGDATA" --auth=trust
|
||||||
fi
|
fi
|
||||||
|
@ -28,6 +29,19 @@
|
||||||
if [ "$user_exists" != "1" ]; then
|
if [ "$user_exists" != "1" ]; then
|
||||||
createuser -s -h "$PGHOST" postgres
|
createuser -s -h "$PGHOST" postgres
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
command="''${1-default}"
|
||||||
|
case $command in
|
||||||
|
shell)
|
||||||
|
psql -U postgres
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
start | default | *)
|
||||||
|
start_db
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue