sync repo.
This commit is contained in:
@@ -14,9 +14,9 @@ function check_command {
|
||||
type -P "$1" &> /dev/null || bail "Unable to find $1, please install it and run this script again"
|
||||
}
|
||||
|
||||
# Log an debug message to the console if BITBUCKET_VERBOSE_BACKUP=true
|
||||
# Log an debug message to the console if CONFLUENCE_VERBOSE_BACKUP=true
|
||||
function debug {
|
||||
if [ "${BITBUCKET_VERBOSE_BACKUP}" = "true" ]; then
|
||||
if [ "${CONFLUENCE_VERBOSE_BACKUP}" = "true" ]; then
|
||||
print "$(script_ctx)[$(hostname)] DEBUG: $*"
|
||||
fi
|
||||
}
|
||||
@@ -25,14 +25,12 @@ function debug {
|
||||
function error {
|
||||
# Set the following to have log statements print contextual information
|
||||
echo "$(script_ctx)[$(hostname)] ERROR: $*" 1>&2
|
||||
hc_announce "[$(hostname)] ERROR: $*" "red" 1
|
||||
}
|
||||
|
||||
# Log an info message to the console and publish it to Hipchat
|
||||
function info {
|
||||
# Set the following to have log statements print contextual information
|
||||
print "$(script_ctx)[$(hostname)] INFO: $*"
|
||||
hc_announce "[$(hostname)] INFO: $*" "gray"
|
||||
}
|
||||
|
||||
# Checks if a variable is zero length, if so it prints the supplied error message and bails
|
||||
@@ -124,7 +122,7 @@ function print_stack_trace {
|
||||
|
||||
# Log then execute the provided command
|
||||
function run {
|
||||
if [ "${BITBUCKET_VERBOSE_BACKUP}" = "true" ]; then
|
||||
if [ "${CONFLUENCE_VERBOSE_BACKUP}" = "true" ]; then
|
||||
local cmdline=
|
||||
for arg in "$@"; do
|
||||
case "${arg}" in
|
||||
@@ -152,45 +150,13 @@ function run {
|
||||
# Log a success message to the console and publish it to Hipchat
|
||||
function success {
|
||||
print "[$(hostname)] SUCC: $*"
|
||||
hc_announce "[$(hostname)] SUCC: $*" "green"
|
||||
}
|
||||
|
||||
# -------------------------------------------------------------------------------------
|
||||
# Internal methods
|
||||
# -------------------------------------------------------------------------------------
|
||||
|
||||
# Publish a message to Hipchat using the REST API
|
||||
#
|
||||
# $1: string: message
|
||||
# $2: string: color (yellow/green/red/purple/gray/random)
|
||||
# $3: integer: notify (0/1)
|
||||
#
|
||||
function hc_announce {
|
||||
if [ -z "${HIPCHAT_ROOM}" ]; then
|
||||
return 0
|
||||
fi
|
||||
if [ -z "${HIPCHAT_TOKEN}" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
print "ERROR: HipChat notification message is missing."
|
||||
return 1
|
||||
fi
|
||||
|
||||
local hc_color="gray"
|
||||
if [ -n "$2" ]; then
|
||||
hc_color=$2
|
||||
fi
|
||||
local hc_notify="false"
|
||||
if [ "1" = "$3" ]; then
|
||||
hc_notify="true"
|
||||
fi
|
||||
|
||||
local hc_message=$(echo "$1" | sed -e 's|"|\\\"|g')
|
||||
local hipchat_payload="{\"message\":\"${hc_message}\",\"color\":\"${hc_color}\",\"notify\":\"${hc_notify}\"}"
|
||||
local hipchat_url="${HIPCHAT_URL}/v2/room/${HIPCHAT_ROOM}/notification?auth_token=${HIPCHAT_TOKEN}"
|
||||
! curl ${CURL_OPTIONS} -X POST -H "Content-Type: application/json" -d "${hipchat_payload}" "${hipchat_url}"
|
||||
true
|
||||
:
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user