6 pkg_cmd_name="postgres"
9 POSTGRES_DATA_DIR=$HOME/.local/share/postgres/var
11 function pkg_get_current_version() {
12 # 'postgres --version' has output in this format:
13 # postgres (PostgreSQL) 10.13
14 # This trims it down to just the version number:
16 echo "$(postgres --version 2> /dev/null | head -n 1 | cut -d' ' -f3)"
19 function pkg_install() {
20 # mkdir -p $HOME/.local/opt
21 mkdir -p "$(dirname $pkg_src)"
23 # mv ./pgqsl* "$HOME/.local/opt/postgres-v10.13"
28 # rm -f "$HOME/.local/opt/postgres"
30 rm -f "$HOME/Applications/pgAdmin"*.app || true
32 # ln -s "$HOME/.local/opt/postgres-v10.13" "$HOME/.local/opt/postgres"
33 ln -s "$pkg_src" "$pkg_dst"
34 mkdir -p ~/Applications
35 ln -s "$pkg_src/pgAdmin 4.app" "$HOME/Applications/pgAdmin 4.app" || true
38 function pkg_post_install() {
39 webi_path_add "$pkg_dst_bin"
41 #echo "Initializing PostgreSQL with database at $POSTGRES_DATA_DIR/"
43 PWFILE="$(pwd)/pwfile.tmp"
44 mkdir -p "$POSTGRES_DATA_DIR"
45 chmod 0700 "$POSTGRES_DATA_DIR"
47 if [ ! -f "$POSTGRES_DATA_DIR/postgresql.conf" ]; then
48 echo "postgres" > "$PWFILE"
49 "$pkg_src/bin/initdb" \
50 -D "$POSTGRES_DATA_DIR/" \
51 --username postgres --pwfile "$PWFILE" \
52 --auth-local=password --auth-host=password
56 function pkg_done_message() {
57 # TODO show with serviceman
58 echo "Installed 'postgres' and 'psql' at $pkg_dst"
62 echo "Database initialized at $POSTGRES_DATA_DIR:"
63 echo " postgres -D $POSTGRES_DATA_DIR -p 5432"
65 echo "Username and password set to 'postgres':"
66 echo " psql 'postgres://postgres:postgres@localhost:5432/postgres'"