Skip to content

Commit 2cde554

Browse files
[oadp-1.1] detect sha256sum is working else use shasum (#807)
* detect sha256sum is working else use shasum * use variable Co-authored-by: Tiger Kaovilai <[email protected]> Co-authored-by: Tiger Kaovilai <[email protected]>
1 parent e5196ab commit 2cde554

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

docs/scripts/dc-restic-post-restore.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
#!/bin/bash
22
set -e
33

4+
# if sha256sum exists, use it to check the integrity of the file
5+
if command -v sha256sum >/dev/null 2>&1; then
6+
CHECKSUM_CMD="sha256sum"
7+
else
8+
CHECKSUM_CMD="shasum -a 256"
9+
fi
10+
411
label_name () {
512
if [ "${#1}" -le "63" ]; then
613
echo $1
714
return
815
fi
9-
sha=$(echo -n $1|sha256sum)
16+
sha=$(echo -n $1|$CHECKSUM_CMD)
1017
echo "${1:0:57}${sha:0:6}"
1118
}
1219

0 commit comments

Comments
 (0)