You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by da...@apache.org on 2017/05/09 18:30:41 UTC

[06/27] incubator-trafficcontrol git commit: added Postgres Bootstrap script for streamlining setup

added Postgres Bootstrap script for streamlining setup


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/775078cb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/775078cb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/775078cb

Branch: refs/heads/master
Commit: 775078cb15c645a73945aa9a61c6764afb3c0a50
Parents: d3bbaec
Author: Dewayne Richardson <de...@apache.org>
Authored: Tue May 2 11:01:42 2017 -0600
Committer: Dan Kirkwood <da...@gmail.com>
Committed: Tue May 9 18:28:58 2017 +0000

----------------------------------------------------------------------
 traffic_ops/install/bin/todb_bootstrap.sh | 33 ++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/775078cb/traffic_ops/install/bin/todb_bootstrap.sh
----------------------------------------------------------------------
diff --git a/traffic_ops/install/bin/todb_bootstrap.sh b/traffic_ops/install/bin/todb_bootstrap.sh
new file mode 100755
index 0000000..2de2d03
--- /dev/null
+++ b/traffic_ops/install/bin/todb_bootstrap.sh
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+
+# To bypass the password prompts for automation, please set TODB_USERNAME_PASSWORD=<yourpassword> before you invoke
+
+# Example:
+#
+#    $ TODB_USERNAME_PASSWORD=<yourpassword> ./todb_bootstrap.sh
+#
+TODB_USERNAME=traffic_ops
+TODB_NAME=traffic_ops
+
+if [[ -z $TODB_USERNAME ]]; then
+    echo "Using environment database user: $TODB_USERNAME"
+fi
+
+if [[ -z $TODB_USERNAME_PASSWORD ]]; then
+   while true; do
+    read -s -p "Please ENTER the new password for database user '$TODB_USERNAME': " password
+    echo
+    read -s -p "Please CONFIRM enter the new password for database user '$TODB_USERNAME' again: " password_confirm
+    echo
+    [ "$password" = "$password_confirm" ] && break
+    echo "Passwords do not match, please try again"
+   done
+   TODB_USERNAME_PASSWORD=$password
+else
+    echo "Using environment database password"
+fi
+echo "Setting up database role: $TODB_USERNAME"
+psql -U postgres -h localhost -c "CREATE USER $TODB_USERNAME WITH ENCRYPTED PASSWORD '$TODB_USERNAME_PASSWORD';"
+createdb $TODB_NAME --owner $TODB_USERNAME -U postgres -h localhost
+
+echo "Successfully set up database '$TODB_NAME' with role '$TODB_USERNAME'"