Skip to content

Commit 99d0233

Browse files
committed
Merge pull request #198 from github/revert-190-snh/working-dir
Revert "Don't change working directory when loading in ghe-backup-config"
2 parents f774235 + 25b7d6d commit 99d0233

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+98
-58
lines changed

bin/ghe-backup

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
set -e
99

1010
# Bring in the backup configuration
11-
. $( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config
11+
cd $(dirname "$0")/..
12+
. share/github-backup-utils/ghe-backup-config
1213

1314
# Used to record failed backup steps
1415
failures=

bin/ghe-host-check

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
#/ provided, the $GHE_HOSTNAME configured in backup.config is assumed.
55
set -e
66

7-
# Bring in the backup configuration
8-
. $( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config
7+
# Bring in the backup configuration.
8+
cd $(dirname "$0")/..
9+
. share/github-backup-utils/ghe-backup-config
910

1011
# Use the host provided on the command line if provided, or fallback on the
1112
# $GHE_HOSTNAME configured in backup.config when not present.
@@ -37,7 +38,7 @@ if [ $rc -ne 0 ]; then
3738
case $rc in
3839
255)
3940
if echo "$output" | grep -i "port 22: connection refused\|port 22: no route to host\|ssh_exchange_identification: Connection closed by remote host\|Connection timed out during banner exchange" >/dev/null; then
40-
exec "$(basename $0)" "$hostname:122"
41+
exec "bin/$(basename $0)" "$hostname:122"
4142
fi
4243

4344
echo "$output" 1>&2
@@ -50,7 +51,7 @@ if [ $rc -ne 0 ]; then
5051
;;
5152
1)
5253
if [ "${port:-22}" -eq 22 ] && echo "$output" | grep "use port 122" >/dev/null; then
53-
exec "$(basename $0)" "$hostname:122"
54+
exec "bin/$(basename $0)" "$hostname:122"
5455
else
5556
echo "$output" 1>&2
5657
fi

bin/ghe-restore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@
2121
#/ <https://enterprise.github.com/help/articles/adding-an-ssh-key-for-shell-access>
2222
set -e
2323

24-
# Bring in the backup configuration
25-
. $( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config
24+
# Bring in the backup configuration.
25+
cd $(dirname "$0")/..
26+
. share/github-backup-utils/ghe-backup-config
2627

2728
# Parse arguments
2829
restore_settings=false

share/github-backup-utils/ghe-backup-alambic-cluster

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
set -e
88

99
# Bring in the backup configuration
10-
. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config
10+
cd $(dirname "$0")/../..
11+
. share/github-backup-utils/ghe-backup-config
1112

1213
# Set up remote host and root backup snapshot directory based on config
1314
host="$GHE_HOSTNAME"

share/github-backup-utils/ghe-backup-config

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,18 @@
55
# This file is sourced by the various utilities under bin and share/github-backup-utils to
66
# load in backup configuration and ensure things are configured properly.
77
#
8-
# All commands in share/github-backup-utils/ should start with the following:
8+
# All commands should start with the following:
99
#
10-
# . $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config
11-
#
12-
# And all commands in bin/ should start with the following:
13-
#
14-
# . $( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config
10+
# cd $(dirname "$0")/../..
11+
# . share/github-backup-utils/ghe-backup-config
1512
#
1613

17-
# Assume this script lives in share/github-backup-utils/ when setting the root
18-
GHE_BACKUP_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )"
14+
# Assume the current directory is the root. This should be fine so long as all
15+
# scripts source us in according to the instructions above.
16+
GHE_BACKUP_ROOT="$(pwd)"
1917

2018
# Get the version from the version file.
21-
BACKUP_UTILS_VERSION="$(cat $GHE_BACKUP_ROOT/share/github-backup-utils/version)"
19+
BACKUP_UTILS_VERSION="$(cat share/github-backup-utils/version)"
2220

2321
# Add the bin and share/github-backup-utils dirs to PATH
2422
PATH="$GHE_BACKUP_ROOT/bin:$GHE_BACKUP_ROOT/share/github-backup-utils:$PATH"

share/github-backup-utils/ghe-backup-es-audit-log

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
set -e
88

99
# Bring in the backup configuration
10-
. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config
10+
cd $(dirname "$0")/../..
11+
. share/github-backup-utils/ghe-backup-config
1112

1213
# Set up remote host and root elastic backup directory based on config
1314
host="$GHE_HOSTNAME"

share/github-backup-utils/ghe-backup-es-hookshot

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
set -e
88

99
# Bring in the backup configuration
10-
. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config
10+
cd $(dirname "$0")/../..
11+
. share/github-backup-utils/ghe-backup-config
1112

1213
# Set up remote host and root elastic backup directory based on config
1314
host="$GHE_HOSTNAME"

share/github-backup-utils/ghe-backup-es-rsync

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
set -e
88

99
# Bring in the backup configuration
10-
. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config
10+
cd $(dirname "$0")/../..
11+
. share/github-backup-utils/ghe-backup-config
1112

1213
# Set up remote host and root elastic backup directory based on config
1314
host="$GHE_HOSTNAME"

share/github-backup-utils/ghe-backup-es-tarball

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
set -e
88

99
# Bring in the backup configuration
10-
. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config
10+
cd $(dirname "$0")/../..
11+
. share/github-backup-utils/ghe-backup-config
1112

1213
# Snapshot all Elasticsearch data or fake it when no /data/elasticsearch
1314
# directory exists.

share/github-backup-utils/ghe-backup-pages-cluster

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
set -e
88

99
# Bring in the backup configuration
10-
. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config
10+
cd $(dirname "$0")/../..
11+
. share/github-backup-utils/ghe-backup-config
1112

1213
# Set up remote host and root backup snapshot directory based on config
1314
host="$GHE_HOSTNAME"

0 commit comments

Comments
 (0)