File tree Expand file tree Collapse file tree 4 files changed +23
-6
lines changed
share/github-backup-utils Expand file tree Collapse file tree 4 files changed +23
-6
lines changed Original file line number Diff line number Diff line change @@ -24,8 +24,14 @@ port=$(ssh_port_part "$host")
2424hostname=$( ssh_host_part " $host " )
2525
2626set +e
27- output=$( echo " cat \" $GHE_REMOTE_METADATA_FILE \" 2>/dev/null || exit 101 " | ghe-ssh -o BatchMode=no $options $host -- /bin/sh 2>&1 )
27+ output=$( echo " ghe-negotiate-version backup-utils $BACKUP_UTILS_VERSION " | ghe-ssh -o BatchMode=no $options $host -- /bin/sh 2>&1 )
2828rc=$?
29+ if [ $rc = 127 ]; then
30+ # ghe-negotiate-version not found, fallback to reading version file
31+ legacy_version_output=" 1"
32+ output=$( echo " cat \" $GHE_REMOTE_METADATA_FILE \" 2>/dev/null || exit 101" | ghe-ssh -o BatchMode=no $options $host -- /bin/sh 2>&1 )
33+ rc=$?
34+ fi
2935set -e
3036
3137if [ $rc -ne 0 ]; then
@@ -55,9 +61,14 @@ if [ $rc -ne 0 ]; then
5561 exit $rc
5662fi
5763
58- version=$( echo " $output " | grep version | cut -d' "' -f4)
64+ if [ -z " $legacy_version_output " ]; then
65+ version=$( echo " $output " | sed -n ' s/GitHub Enterprise version \(.*\)/\1/p' )
66+ else
67+ version=$( echo " $output " | grep version | cut -d' "' -f4)
68+ fi
69+
5970if [ -z " $version " ]; then
60- echo " Error: failed to parse version from $GHE_REMOTE_METADATA_FILE on '$host ' or this isn't a GitHub appliance." 1>&2
71+ echo " Error: failed to parse version on '$host ' or this isn't a GitHub appliance." 1>&2
6172 exit 2
6273fi
6374
Original file line number Diff line number Diff line change 1515# scripts source us in according to the instructions above.
1616GHE_BACKUP_ROOT=" $( pwd) "
1717
18+ # Get the version from the version file.
19+ BACKUP_UTILS_VERSION=" $( cat share/github-backup-utils/version) "
20+
1821# Add the bin and share/github-backup-utils dirs to PATH
1922PATH=" $GHE_BACKUP_ROOT /bin:$GHE_BACKUP_ROOT /share/github-backup-utils:$PATH "
2023
@@ -109,8 +112,9 @@ GHE_SNAPSHOT_DIR="$GHE_DATA_DIR"/"$GHE_SNAPSHOT_TIMESTAMP"
109112# allows the location to be overridden in tests.
110113: ${GHE_REMOTE_LICENSE_FILE:= " $GHE_REMOTE_DATA_DIR /enterprise/enterprise.ghl" }
111114
112- # The location of the metadata file on the remote side. This is always
113- # "/data/enterprise/chef_metadata.json" for GitHub instances. Use of this variable
115+ # The legacy location of the metadata file on the remote side. Only used if
116+ # the newer "ghe-negotiate-version" script cannot be found or fails. This was
117+ # "/data/enterprise/metadata.json" for GitHub instances. Use of this variable
114118# allows the location to be overridden in tests.
115119: ${GHE_REMOTE_METADATA_FILE:= " $GHE_REMOTE_DATA_DIR /enterprise/chef_metadata.json" }
116120
Original file line number Diff line number Diff line change 1+ 2.0.1
Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ GHE_REMOTE_DATA_DIR="$TRASHDIR/remote"
1212export GHE_DATA_DIR GHE_REMOTE_DATA_DIR
1313
1414# Source in the config script
15- . " $ROOTDIR /share/github-backup-utils/ghe-backup-config"
15+ cd " $ROOTDIR "
16+ . " share/github-backup-utils/ghe-backup-config"
1617
1718begin_test " ghe-backup-config ssh_host_part"
1819(
You can’t perform that action at this time.
0 commit comments