improve getdbcreds
This commit is contained in:
parent
cdd277782e
commit
1cd015e6d9
1 changed files with 30 additions and 68 deletions
86
functions.sh
86
functions.sh
|
@ -1012,30 +1012,6 @@ get_crtime() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# jira-confluence-specific is temporary in here
|
|
||||||
#function getdbcreds_jira () {
|
|
||||||
# [ $# -eq 0 ] return 1
|
|
||||||
#
|
|
||||||
# DB_FILE=$1
|
|
||||||
#
|
|
||||||
# DB_URL="$(grep -oPm1 "(?<=<url>)[^<]+" ${DB_FILE})"
|
|
||||||
# DB_USER="$(grep -oPm1 "(?<=<username>)[^<]+" ${DB_FILE})"
|
|
||||||
# DB_PWD="$(grep -oPm1 "(?<=<password>)[^<]+" ${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@')"
|
|
||||||
#
|
|
||||||
# cat << \
|
|
||||||
# EOF
|
|
||||||
# DB_HOST: ${DB_HOST}
|
|
||||||
# DB_PORT: ${DB_PORT}
|
|
||||||
# DB_NAME: ${DB_NAME}
|
|
||||||
# DB_USER: ${DB_USER}
|
|
||||||
# DB_PWD: ${DB_PWD}
|
|
||||||
#EOF
|
|
||||||
# return 0
|
|
||||||
#}
|
|
||||||
|
|
||||||
|
|
||||||
is_btrfs_subvolume() {
|
is_btrfs_subvolume() {
|
||||||
sudo btrfs subvolume show "$1" >/dev/null
|
sudo btrfs subvolume show "$1" >/dev/null
|
||||||
|
@ -1106,27 +1082,19 @@ getusedip () {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getdbcreds_jra () {
|
function getdbcreds_jra () {
|
||||||
case $# in
|
local APP_INST=/opt/atlassian/jira
|
||||||
0)
|
local JRA_HOME=$(awk -F "=" '/jira.home/ {gsub(/ /, "", $0); print $2}' "${APP_INST}/atlassian-jira/WEB-INF/classes/jira-application.properties")
|
||||||
gojirahome
|
local DB_FILE="${JRA_HOME}/dbconfig.xml"
|
||||||
DB_FILE=dbconfig.xml
|
if [ xmllint --version >/dev/null 2>&1 ]; then
|
||||||
#cd -
|
|
||||||
;;
|
|
||||||
1)
|
|
||||||
DB_FILE=$1
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "wrong number of arguments"
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
#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_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_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_PWD="$(xmllint --xpath "jira-database-config/jdbc-datasource/password/text()" ${DB_FILE})"
|
||||||
|
else
|
||||||
|
echo "please install xmllint »apt install libxml2-utils«"
|
||||||
|
DB_URL="$(grep -oPm1 "(?<=<url>)[^<]+" ${DB_FILE})"
|
||||||
|
DB_USER="$(grep -oPm1 "(?<=<username>)[^<]+" ${DB_FILE})"
|
||||||
|
DB_PWD="$(grep -oPm1 "(?<=<password>)[^<]+" ${DB_FILE})"
|
||||||
|
fi
|
||||||
DB_HOST="$(echo $DB_URL|sed 's@^.*//@@;s@\(^.*\):\(.*\)/\(.*\)$@\1@')"
|
DB_HOST="$(echo $DB_URL|sed 's@^.*//@@;s@\(^.*\):\(.*\)/\(.*\)$@\1@')"
|
||||||
DB_PORT="$(echo $DB_URL|sed 's@^.*//@@;s@\(^.*\):\(.*\)/\(.*\)$@\2@')"
|
DB_PORT="$(echo $DB_URL|sed 's@^.*//@@;s@\(^.*\):\(.*\)/\(.*\)$@\2@')"
|
||||||
DB_NAME="$(echo $DB_URL|sed 's@^.*//@@;s@\(^.*\):\(.*\)/\(.*\)$@\3@')"
|
DB_NAME="$(echo $DB_URL|sed 's@^.*//@@;s@\(^.*\):\(.*\)/\(.*\)$@\3@')"
|
||||||
|
@ -1135,27 +1103,19 @@ function getdbcreds_jra () {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getdbcreds_cnf () {
|
function getdbcreds_cnf () {
|
||||||
case $# in
|
local APP_INST=/opt/atlassian/jira
|
||||||
0)
|
local CNF_HOME=$(awk -F "=" '/jira.home/ {gsub(/ /, "", $0); print $2}' "${APP_INST}/atlassian-jira/WEB-INF/classes/jira-application.properties")
|
||||||
gocnfhome
|
local DB_FILE="${CNF_HOME}/confluence.cfg.xml"
|
||||||
DB_FILE=confluence.cfg.xml
|
if [ xmllint --version >/dev/null 2>&1 ]; then
|
||||||
;;
|
|
||||||
1)
|
|
||||||
DB_FILE=$1
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "wrong number of arguments"
|
|
||||||
cd -
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
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="$(xmllint --xpath "confluence-configuration/properties/property[@name='hibernate.connection.url']/text()" ${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_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_PWD="$(xmllint --xpath "confluence-configuration/properties/property[@name='hibernate.connection.password']/text()" ${DB_FILE})"
|
||||||
|
else
|
||||||
|
echo "please install xmllint »apt install libxml2-utils«"
|
||||||
|
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})"
|
||||||
|
fi
|
||||||
DB_HOST="$(echo $DB_URL|sed 's@^.*//@@;s@\(^.*\):\(.*\)/\(.*\)$@\1@')"
|
DB_HOST="$(echo $DB_URL|sed 's@^.*//@@;s@\(^.*\):\(.*\)/\(.*\)$@\1@')"
|
||||||
DB_PORT="$(echo $DB_URL|sed 's@^.*//@@;s@\(^.*\):\(.*\)/\(.*\)$@\2@')"
|
DB_PORT="$(echo $DB_URL|sed 's@^.*//@@;s@\(^.*\):\(.*\)/\(.*\)$@\2@')"
|
||||||
DB_NAME="$(echo $DB_URL|sed 's@^.*//@@;s@\(^.*\):\(.*\)/\(.*\)$@\3@')"
|
DB_NAME="$(echo $DB_URL|sed 's@^.*//@@;s@\(^.*\):\(.*\)/\(.*\)$@\3@')"
|
||||||
|
@ -1163,6 +1123,8 @@ function getdbcreds_cnf () {
|
||||||
#cd -
|
#cd -
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function connectdb () {
|
function connectdb () {
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
|
@ -1220,7 +1182,7 @@ gojrahome() {
|
||||||
|
|
||||||
gojrashome() {
|
gojrashome() {
|
||||||
local APP_INST=/opt/atlassian/jira
|
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")
|
local JRA_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
|
[ -e "${JRA_HOME}/cluster.properties" ] && cd $(awk -F "=" '/jira.shared.home/ {gsub(/ /, "", $0); print $2}' "${JRA_HOME}/cluster.properties") || echo no shared home configured >&2
|
||||||
}
|
}
|
||||||
#EOF
|
#EOF
|
||||||
|
|
Loading…
Reference in a new issue