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