Skip to content

Commit 93ca1b6

Browse files
authored
Merge pull request #282 from github/krayon-remove-readlink
Removing readlink as it doesn't work and *nix have readlink usually
2 parents 6f00d54 + d2a566f commit 93ca1b6

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

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

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ for f in "$GHE_BACKUP_CONFIG" "$GHE_BACKUP_ROOT/backup.config" \
143143
fi
144144
done
145145

146+
# If we don't have a readlink command, error out
147+
! type readlink 1>/dev/null 2>&1 && {
148+
echo "Error: readlink not found. Please install readlink and ensure it is in your PATH." 1>&2
149+
exit 1
150+
}
151+
146152
GHE_RESTORE_IN_PROGRESS=$(readlink -fm "${GHE_DATA_DIR}/in-progress-restore")
147153
GHE_BACKUP_IN_PROGRESS=$(readlink -fm "${GHE_DATA_DIR}/in-progress-backup")
148154

@@ -294,10 +300,9 @@ if [ -z "$GHE_DATA_DIR" ]; then
294300
fi
295301

296302
# Convert the data directory path to an absolute path, basing any relative
297-
# paths on the backup-utils root, and using readlink, if available, to
298-
# canonicalize the path.
303+
# paths on the backup-utils root, and use readlink to canonicalize the path.
299304
if [ "${GHE_DATA_DIR:0:1}" != "/" ]; then
300-
GHE_DATA_DIR="$(cd "$GHE_BACKUP_ROOT" && readlink -m "$GHE_DATA_DIR" 2>/dev/null || echo "$GHE_BACKUP_ROOT/$GHE_DATA_DIR")"
305+
GHE_DATA_DIR="$(cd "$GHE_BACKUP_ROOT" && readlink -m "$GHE_DATA_DIR")"
301306
fi
302307
export GHE_DATA_DIR
303308

@@ -401,17 +406,6 @@ ghe_remote_version_config() {
401406
###############################################################################
402407
### Utility functions
403408

404-
# If we don't have a readlink command, parse ls -l output.
405-
if ! type readlink 1>/dev/null 2>&1; then
406-
readlink() {
407-
if [ -x "$1" ]; then
408-
ls -ld "$1" | sed 's/.*-> //'
409-
else
410-
return 1
411-
fi
412-
}
413-
fi
414-
415409
# Run ghe-host-check and establish the version of the remote GitHub instance in
416410
# the exported GHE_REMOTE_VERSION variable. If the remote version has already
417411
# been established then don't perform the host check again. Utilities in share/github-backup-utils

0 commit comments

Comments
 (0)