From f9cf2c203cd2fb4913a36c73c672018b1954147b Mon Sep 17 00:00:00 2001
From: Sinisa Veseli <sveseli@aps.anl.gov>
Date: Mon, 29 Jun 2015 16:41:15 +0000
Subject: [PATCH] update web portal config to include system user addition

---
 sbin/dm_configure_web_portal.sh | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/sbin/dm_configure_web_portal.sh b/sbin/dm_configure_web_portal.sh
index 70a13aa0..efa49c4e 100755
--- a/sbin/dm_configure_web_portal.sh
+++ b/sbin/dm_configure_web_portal.sh
@@ -37,7 +37,10 @@ else
     echo "Deployment config file $deployConfigFile not found, using defaults"
 fi
 
+DM_INSTALL_DIR=${DM_INSTALL_DIR:=$DM_ROOT_DIR/..}
+DM_SYSTEM_PASSWORD_FILE=${DM_INSTALL_DIR}/etc/${DM_SYSTEM_USER}.system.passwd
 DM_HOST_ARCH=`uname | tr [A-Z] [a-z]`-`uname -m`
+
 GLASSFISH_DIR=$DM_SUPPORT_DIR/glassfish/$DM_HOST_ARCH
 JAVA_HOME=$DM_SUPPORT_DIR/java/$DM_HOST_ARCH
 
@@ -54,7 +57,7 @@ DM_DOMAIN=domain1
 
 # copy db driver
 echo "Copying db driver"
-rsync -ar $DM_ROOT_DIR/src/java/DmWebPortal/lib/postgresql-9.3-1102.jdbc41.jar $GLASSFISH_DIR/glassfish/domains/${DM_DOMAIN}/lib/ext
+rsync -ar $DM_ROOT_DIR/src/java/DmWebPortal/lib/postgresql*.jdbc41.jar $GLASSFISH_DIR/glassfish/domains/${DM_DOMAIN}/lib/ext
 
 # Check password from file
 passwordFile=$DM_INSTALL_DIR/etc/$DM_DB_NAME.db.passwd
@@ -79,3 +82,19 @@ $ASADMIN_CMD create-jdbc-resource --connectionpoolid ${DM_DB_POOL} ${DM_DATA_SOU
 echo "Testing connection"
 $ASADMIN_CMD ping-connection-pool $DM_DB_POOL || exit 1
 
+# Get system account password
+if [ ! -f "$DM_SYSTEM_PASSWORD_FILE" ]; then
+    sttyOrig=`stty -g`
+    stty -echo
+    read -p "Enter system password for the $DM_SYSTEM_USER user: " DM_SYSTEM_PASSWORD
+    echo
+    stty $sttyOrig
+    echo $DM_SYSTEM_PASSWORD > $DM_SYSTEM_PASSWORD_FILE
+    chmod 600 $DM_SYSTEM_PASSWORD_FILE
+
+    # Add dm system user to the DB
+    echo "Adding $DM_SYSTEM_USER system user to the database"
+    dm-add-user --username=$DM_SYSTEM_USER --first-name=System --last-name=Account --password-file=$DM_SYSTEM_PASSWORD_FILE || exit 1
+    dm-add-user-system-role --username=$DM_SYSTEM_USER --role-name=Administrator || exit 1
+fi
+
-- 
GitLab