+#!/bin/bash
+
set -e
set -u
POSTGRES_DATA_DIR=$HOME/.local/share/postgres/var
-pkg_get_current_version() {
+function pkg_get_current_version() {
# 'postgres --version' has output in this format:
# postgres (PostgreSQL) 10.13
# This trims it down to just the version number:
# 10.13
- echo "$(postgres --version 2>/dev/null | head -n 1 | cut -d' ' -f3)"
+ echo "$(postgres --version 2> /dev/null | head -n 1 | cut -d' ' -f3)"
}
-pkg_install() {
+function pkg_install() {
# mkdir -p $HOME/.local/opt
mkdir -p "$(dirname $pkg_src)"
mv ./"p"* "$pkg_src"
}
-pkg_link() {
+function pkg_link() {
# rm -f "$HOME/.local/opt/postgres"
rm -f "$pkg_dst"
- rm -f "$HOME/Applications/pgAdmin*.app" || true
+ rm -f "$HOME/Applications/pgAdmin"*.app || true
# ln -s "$HOME/.local/opt/postgres-v10.13" "$HOME/.local/opt/postgres"
ln -s "$pkg_src" "$pkg_dst"
+ mkdir -p ~/Applications
ln -s "$pkg_src/pgAdmin 4.app" "$HOME/Applications/pgAdmin 4.app" || true
}
-pkg_post_install() {
+function pkg_post_install() {
webi_path_add "$pkg_dst_bin"
#echo "Initializing PostgreSQL with database at $POSTGRES_DATA_DIR/"
chmod 0700 "$POSTGRES_DATA_DIR"
if [ ! -f "$POSTGRES_DATA_DIR/postgresql.conf" ]; then
- echo "postgres" > "$PWFILE"
- "$pkg_src/bin/initdb" \
- -D "$POSTGRES_DATA_DIR/" \
- --username postgres --pwfile "$PWFILE" \
- --auth-local=password --auth-host=password
+ echo "postgres" > "$PWFILE"
+ "$pkg_src/bin/initdb" \
+ -D "$POSTGRES_DATA_DIR/" \
+ --username postgres --pwfile "$PWFILE" \
+ --auth-local=password --auth-host=password
fi
}
-pkg_done_message() {
+function pkg_done_message() {
# TODO show with serviceman
echo "Installed 'postgres' and 'psql' at $pkg_dst"
echo ""
echo " psql 'postgres://postgres:postgres@localhost:5432/postgres'"
echo ""
}
-