Skip to content

Commit f774235

Browse files
committed
Merge pull request #197 from github/snh/home-dir-config
Check home directory for configuration file
2 parents d32a6f0 + e01cee1 commit f774235

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ BACKUP_UTILS_VERSION="$(cat $GHE_BACKUP_ROOT/share/github-backup-utils/version)"
2323
# Add the bin and share/github-backup-utils dirs to PATH
2424
PATH="$GHE_BACKUP_ROOT/bin:$GHE_BACKUP_ROOT/share/github-backup-utils:$PATH"
2525

26-
# The backup config file. This may be set in the environment.
27-
: ${GHE_BACKUP_CONFIG:="$GHE_BACKUP_ROOT/backup.config"}
28-
2926
# Parse out -v (verbose) argument
3027
if [ "$1" = "-v" ]; then
3128
GHE_VERBOSE=true
@@ -45,10 +42,11 @@ fi
4542
# backup.config value when set.
4643
GHE_HOSTNAME_PRESERVE="$GHE_HOSTNAME"
4744

48-
# Source in the backup config file from the local working copy location first
49-
# and then falling back to the system location.
45+
# Source in the backup config file from the copy specified in the environment
46+
# first and then fall back to the backup-utils root, home directory and system.
5047
config_found=false
51-
for f in "$GHE_BACKUP_CONFIG" "/etc/github-backup-utils/backup.config"; do
48+
for f in "$GHE_BACKUP_CONFIG" "$GHE_BACKUP_ROOT/backup.config" \
49+
"$HOME/.github-backup-utils/backup.config" "/etc/github-backup-utils/backup.config"; do
5250
if [ -f "$f" ]; then
5351
GHE_BACKUP_CONFIG="$f"
5452
. "$GHE_BACKUP_CONFIG"
@@ -60,7 +58,9 @@ done
6058
# Check that the config file exists before we source it in.
6159
if ! $config_found; then
6260
echo "Error: No backup configuration file found. Tried:" 1>&2
63-
echo " - $GHE_BACKUP_CONFIG" 1>&2
61+
[ -n "$GHE_BACKUP_CONFIG" ] && echo " - $GHE_BACKUP_CONFIG" 1>&2
62+
echo " - $GHE_BACKUP_ROOT/backup.config" 1>&2
63+
echo " - $HOME/.github-backup-utils/backup.config" 1>&2
6464
echo " - /etc/github-backup-utils/backup.config" 1>&2
6565
exit 2
6666
fi

0 commit comments

Comments
 (0)