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

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

added Postgres Bootstrap script for streamlining setup

(cherry picked from commit 775078cb15c645a73945aa9a61c6764afb3c0a50)


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

Branch: refs/heads/2.0.x
Commit: dac22b09ad5c6ec614fe8ad2c8ef9cf18c82e321
Parents: 1c07e5a
Author: Dewayne Richardson <de...@apache.org>
Authored: Tue May 2 11:01:42 2017 -0600
Committer: Eric Friedrich <fr...@apache.org>
Committed: Wed May 31 10:08:57 2017 -0400

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


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/dac22b09/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'"