postgres joins the fight
authorAJ ONeal <coolaj86@gmail.com>
Tue, 16 Jun 2020 12:25:31 +0000 (06:25 -0600)
committerAJ ONeal <coolaj86@gmail.com>
Tue, 16 Jun 2020 12:25:31 +0000 (06:25 -0600)
postgres/install.sh [new file with mode: 0644]
postgres/package.yash [new file with mode: 0644]
postgres/releases.js [new file with mode: 0644]
postgresql/install.sh [new file with mode: 0644]

diff --git a/postgres/install.sh b/postgres/install.sh
new file mode 100644 (file)
index 0000000..c21cdb7
--- /dev/null
@@ -0,0 +1,66 @@
+set -e
+set -u
+
+pkg_cmd_name="postgres"
+#WEBI_SINGLE=""
+
+POSTGRES_DATA_DIR=$HOME/.local/share/postgres/var
+
+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)"
+}
+
+pkg_install() {
+    # mkdir -p $HOME/.local/opt
+    mkdir -p "$(dirname $pkg_src)"
+
+    # mv ./pgqsl* "$HOME/.local/opt/postgres-v10.13"
+    mv ./"p"* "$pkg_src"
+}
+
+pkg_link() {
+    # rm -f "$HOME/.local/opt/postgres"
+    rm -f "$pkg_dst"
+    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"
+    ln -s "$pkg_src/pgAdmin 4.app" "$HOME/Applications/pgAdmin 4.app" || true
+}
+
+pkg_post_install() {
+    webi_path_add "$pkg_dst_bin"
+
+    #echo "Initializing PostgreSQL with database at $POSTGRES_DATA_DIR/"
+
+    PWFILE="$(pwd)/pwfile.tmp"
+    mkdir -p "$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
+    fi
+}
+
+pkg_done_message() {
+    # TODO show with serviceman
+    echo "Installed 'postgres' and 'psql' at $pkg_dst"
+    echo ""
+    echo "IMPORTANT!!!"
+    echo ""
+    echo "Database initialized at $POSTGRES_DATA_DIR:"
+    echo "    postgres -D $POSTGRES_DATA_DIR -p 5432"
+    echo ""
+    echo "Username and password set to 'postgres':"
+    echo "    psql 'postgres://postgres:postgres@localhost:5432/postgres'"
+    echo ""
+}
+
diff --git a/postgres/package.yash b/postgres/package.yash
new file mode 100644 (file)
index 0000000..488bd94
--- /dev/null
@@ -0,0 +1,34 @@
+# title: Postgres
+# homepage: https://www.postgresql.org/
+# tagline: PostgreSQL: The World's Most Advanced Open Source Relational Database
+# description: |
+#   Postgres is the all-in-one database for beginners and experts alike. It handles SQL, 'NoSQL', JSON, HSTORE, Full-Text Search, Messages Queues and more. Best bang for buck.
+# examples: |
+#
+#   Initialize a database with a password
+#
+#   ```bash
+#   echo "postgres" > /tmp/pwfile
+#   mkdir -p $HOME/.local/share/postgres/var/
+#
+#   initdb -D $HOME/.local/share/postgres/var/ \
+#       --username postgres --pwfile "/tmp/pwfile" \
+#       --auth-local=password --auth-host=password
+#
+#   rm /tmp/pwfile
+#   ```
+#
+#   Start the postgres server
+#
+#   ```bash
+#   postgres -D $HOME/.local/share/var/postgres -p 5432
+#   ```
+#
+#   Connect with the psql client
+#
+#   ```bash
+#   psql 'postgres://postgres:postgres@localhost:5432/postgres'
+#   ```
+#
+
+END
diff --git a/postgres/releases.js b/postgres/releases.js
new file mode 100644 (file)
index 0000000..87b7964
--- /dev/null
@@ -0,0 +1,49 @@
+'use strict';
+
+module.exports = async function () {
+  // TODO scape some combination of
+  // - https://www.enterprisedb.com/download-postgresql-binaries
+  // - https://www.enterprisedb.com/downloads/postgres-postgresql-downloads
+  //      - https://www.postgresql.org/download/
+  //      - https://www.postgresql.org/download/linux/debian/
+  return {
+    releases: [
+      {
+        name: 'postgresql-10.12-1-linux-binaries.tar.gz',
+        version: '10.12',
+        lts: false,
+        channel: 'stable',
+        date: '',
+        os: 'linux',
+        arch: 'amd64',
+        ext: 'tar',
+        download: ''
+      },
+      {
+        name: 'postgresql-10.13-1-osx-binaries.zip',
+        version: '10.13',
+        lts: false,
+        channel: 'stable',
+        date: '',
+        os: 'macos',
+        arch: 'amd64',
+        ext: 'zip',
+        download: ''
+      }
+    ].map(function (rel) {
+      rel.download =
+        'https://get.enterprisedb.com/postgresql/' +
+        rel.name +
+        '?ls=Crossover&type=Crossover';
+      return rel;
+    }),
+    download: ''
+  };
+};
+
+if (module === require.main) {
+  module.exports(require('@root/request')).then(function (all) {
+    all = require('../_webi/normalize.js')(all);
+    console.info(JSON.stringify(all));
+  });
+}
diff --git a/postgresql/install.sh b/postgresql/install.sh
new file mode 100644 (file)
index 0000000..68b2e2b
--- /dev/null
@@ -0,0 +1,9 @@
+# title: PostgreSQL (Postgres alias)
+# homepage: https://webinstall.dev/postgres
+# tagline: Alias for https://webinstall.dev/postgres
+# alias: postgres
+# description: |
+#   See https://webinstall.dev/postgres
+
+echo "'postgresql' is an alias for 'postgres'"
+curl -fsSL https://webinstall.dev/postgres@${WEBI_VERSION:-} | bash