From 9147458c3a380666d34f9579f5f3da2a57261adf Mon Sep 17 00:00:00 2001 From: John Zhao Date: Mon, 16 Apr 2018 12:20:31 +0800 Subject: [PATCH] Add checksum tools --- tools/README.md | 8 ++++++ tools/checksum/md5sum.sh | 57 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100755 tools/checksum/md5sum.sh diff --git a/tools/README.md b/tools/README.md index 95a475d..f250ccc 100644 --- a/tools/README.md +++ b/tools/README.md @@ -70,3 +70,11 @@ python tools/analytics/imu_analytics.py -i mynteye.bag ```bash python tools/analytics/stamp_analytics.py -i mynteye.bag ``` + +--- + +## Checksum + +```bash +./tools/checksum/md5sum.sh +``` diff --git a/tools/checksum/md5sum.sh b/tools/checksum/md5sum.sh new file mode 100755 index 0000000..697de2a --- /dev/null +++ b/tools/checksum/md5sum.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash + +BASE_DIR=$(cd "$(dirname "$0")" && pwd) +ROOT_DIR=$(realpath "$BASE_DIR/../..") +SCRIPTS_DIR="$ROOT_DIR/scripts" + +source "$SCRIPTS_DIR/common/echo.sh" +source "$SCRIPTS_DIR/common/host.sh" + +if [ "$HOST_OS" = "Linux" ]; then + MD5SUM="md5sum" +elif [ "$HOST_OS" = "Mac" ]; then + MD5SUM="md5 -q" +else # unexpected + _echo_e "Unknown host os :(" + exit 1 +fi + +_get_size() { +PYTHON_ARG="$1" python - <" + exit 1 +fi + +if [ -d "$1" ]; then + find "$1" -type f | while read -r f; do + _print_info "$f" + done +else + _print_info "$1" +fi