From f09584485fa101171ce39a4421c816d869af985f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Mon, 4 Jul 2022 15:27:49 +0200 Subject: [PATCH] read cnf/jra xml with xmllint --- functions.sh | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/functions.sh b/functions.sh index 89cb6da..9fd2f8e 100755 --- a/functions.sh +++ b/functions.sh @@ -1121,9 +1121,12 @@ function getdbcreds_jra () { ;; esac - DB_URL="$(grep -oPm1 "(?<=)[^<]+" ${DB_FILE})" - DB_USER="$(grep -oPm1 "(?<=)[^<]+" ${DB_FILE})" - DB_PWD="$(grep -oPm1 "(?<=)[^<]+" ${DB_FILE})" + #DB_URL="$(grep -oPm1 "(?<=)[^<]+" ${DB_FILE})" + #DB_USER="$(grep -oPm1 "(?<=)[^<]+" ${DB_FILE})" + #DB_PWD="$(grep -oPm1 "(?<=)[^<]+" ${DB_FILE})" + DB_URL="$(xmllint --xpath "jira-database-config/jdbc-datasource/url/text()" ${DB_FILE})" + DB_USER="$(xmllint --xpath "jira-database-config/jdbc-datasource/username/text()" ${DB_FILE})" + DB_PWD="$(xmllint --xpath "jira-database-config/jdbc-datasource/password/text()" ${DB_FILE})" DB_HOST="$(echo $DB_URL|sed 's@^.*//@@;s@\(^.*\):\(.*\)/\(.*\)$@\1@')" DB_PORT="$(echo $DB_URL|sed 's@^.*//@@;s@\(^.*\):\(.*\)/\(.*\)$@\2@')" DB_NAME="$(echo $DB_URL|sed 's@^.*//@@;s@\(^.*\):\(.*\)/\(.*\)$@\3@')" @@ -1147,9 +1150,12 @@ function getdbcreds_cnf () { ;; esac - DB_URL="$(grep -oPm1 "(?<=)[^<]+" ${DB_FILE})" - DB_USER="$(grep -oPm1 "(?<=)[^<]+" ${DB_FILE})" - DB_PWD="$(grep -oPm1 "(?<=)[^<]+" ${DB_FILE})" +# DB_URL="$(grep -oPm1 "(?<=)[^<]+" ${DB_FILE})" +# DB_USER="$(grep -oPm1 "(?<=)[^<]+" ${DB_FILE})" +# DB_PWD="$(grep -oPm1 "(?<=)[^<]+" ${DB_FILE})" + DB_URL="$(xmllint --xpath "confluence-configuration/properties/property[@name='hibernate.connection.url']/text()" ${DB_FILE})" + DB_USER="$(xmllint --xpath "confluence-configuration/properties/property[@name='hibernate.connection.username']/text()" ${DB_FILE})" + DB_PWD="$(xmllint --xpath "confluence-configuration/properties/property[@name='hibernate.connection.password']/text()" ${DB_FILE})" DB_HOST="$(echo $DB_URL|sed 's@^.*//@@;s@\(^.*\):\(.*\)/\(.*\)$@\1@')" DB_PORT="$(echo $DB_URL|sed 's@^.*//@@;s@\(^.*\):\(.*\)/\(.*\)$@\2@')" DB_NAME="$(echo $DB_URL|sed 's@^.*//@@;s@\(^.*\):\(.*\)/\(.*\)$@\3@')" @@ -1206,4 +1212,15 @@ urldecode() { findlocallogins() { last -F -a $(for i in $(find /var/log -maxdepth 1 -name "wtmp*"|sort -h);do echo -n "-f $i ";done)|grep -v "pts/\|reboot\|wtmp"|awk '{print $4,$5,$7}'|uniq } + +gojrahome() { + local APP_INST=/opt/atlassian/jira + cd $(awk -F "=" '/jira.home/ {gsub(/ /, "", $0); print $2}' "${APP_INST}/atlassian-jira/WEB-INF/classes/jira-application.properties") +} + +gojrashome() { + local APP_INST=/opt/atlassian/jira + local JIRA_HOME=$(awk -F "=" '/jira.home/ {gsub(/ /, "", $0); print $2}' "${APP_INST}/atlassian-jira/WEB-INF/classes/jira-application.properties") + [ -e "${JIRA_HOME}/cluster.properties" ] && cd $(awk -F "=" '/jira.shared.home/ {gsub(/ /, "", $0); print $2}' "${JIRA_HOME}/cluster.properties") || echo no shared home configured >&2 +} #EOF