read cnf/jra xml with xmllint

This commit is contained in:
Jakobus Schürz 2022-07-04 15:27:49 +02:00
parent c8c6922b1f
commit f09584485f

View file

@ -1121,9 +1121,12 @@ function getdbcreds_jra () {
;;
esac
DB_URL="$(grep -oPm1 "(?<=<url>)[^<]+" ${DB_FILE})"
DB_USER="$(grep -oPm1 "(?<=<username>)[^<]+" ${DB_FILE})"
DB_PWD="$(grep -oPm1 "(?<=<password>)[^<]+" ${DB_FILE})"
#DB_URL="$(grep -oPm1 "(?<=<url>)[^<]+" ${DB_FILE})"
#DB_USER="$(grep -oPm1 "(?<=<username>)[^<]+" ${DB_FILE})"
#DB_PWD="$(grep -oPm1 "(?<=<password>)[^<]+" ${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 "(?<=<property name=\"hibernate.connection.url\">)[^<]+" ${DB_FILE})"
DB_USER="$(grep -oPm1 "(?<=<property name=\"hibernate.connection.username\">)[^<]+" ${DB_FILE})"
DB_PWD="$(grep -oPm1 "(?<=<property name=\"hibernate.connection.password\">)[^<]+" ${DB_FILE})"
# DB_URL="$(grep -oPm1 "(?<=<property name=\"hibernate.connection.url\">)[^<]+" ${DB_FILE})"
# DB_USER="$(grep -oPm1 "(?<=<property name=\"hibernate.connection.username\">)[^<]+" ${DB_FILE})"
# DB_PWD="$(grep -oPm1 "(?<=<property name=\"hibernate.connection.password\">)[^<]+" ${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