forked from xapi-project/xen-api
/
host-bugreport-upload
executable file
·34 lines (27 loc) · 1.08 KB
/
host-bugreport-upload
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
#
# Copyright (c) Citrix Systems 2008. All rights reserved.
#
# Upload a bugreport to the support website
DEFAULT_BASE_URL="ftp://support.xensource.com/uploads/"
# If the user supplies a bare filename without a URI scheme,
# we ignore it -- if they _really_ want to upload named files
# to our support server, they can specify the URI scheme.
FILENAME=$(echo ${INPUT_URL} | sed -ne 's,^.*://.*/,,p')
BASE_URL=$(echo ${INPUT_URL} | sed -ne 's,\(^[^:]*://[^/]*\)\(/\([^/]*/\)*\)*[^/]*$,\1/\3,p')
# If no override is provided then use this default:
if [ -z "$FILENAME" ]; then
# Build the remote filename
now=$(date --utc +"%Y:%m:%dT%H:%M:%SZ")
. @INVENTORY@
FILENAME=${INSTALLATION_UUID}-${now}
fi
[ ! -z "${BASE_URL}" ] || BASE_URL="${DEFAULT_BASE_URL}"
URL="${BASE_URL}${FILENAME}"
export http_proxy=$PROXY
export ftp_proxy=$PROXY
logger "Uploading xen-bugtool"
url_file=$(mktemp --suffix="host-bugreport-upload")
printf 'url = "%s"' $URL > $url_file
/usr/sbin/xen-bugtool --output=tar --outfd 1 --yestoall --silent 2>/dev/null | curl --config $url_file -T - 2>&1
rm -f $url_file