2020-06-14 08:07:18 +00:00
|
|
|
#!/bin/sh -e
|
|
|
|
|
2021-06-22 13:36:30 +00:00
|
|
|
if [ -f "$__object/parameter/destination" ]
|
|
|
|
then
|
|
|
|
dst="$( cat "$__object/parameter/destination" )"
|
|
|
|
else
|
|
|
|
dst="/$__object_id"
|
|
|
|
fi
|
2020-06-14 08:07:18 +00:00
|
|
|
|
2020-06-20 22:13:30 +00:00
|
|
|
if [ ! -f "$dst" ]
|
|
|
|
then
|
|
|
|
echo 'absent'
|
|
|
|
exit 0
|
|
|
|
fi
|
2020-06-14 08:07:18 +00:00
|
|
|
|
2021-04-11 20:05:48 +00:00
|
|
|
if [ ! -f "$__object/parameter/sum" ]
|
|
|
|
then
|
|
|
|
echo 'present'
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2020-06-20 22:13:30 +00:00
|
|
|
sum_should="$( cat "$__object/parameter/sum" )"
|
2020-06-14 08:07:18 +00:00
|
|
|
|
2021-06-22 13:36:30 +00:00
|
|
|
if echo "$sum_should" | grep -Fq ':'
|
2020-06-14 08:07:18 +00:00
|
|
|
then
|
2021-06-22 13:36:30 +00:00
|
|
|
sum_should="$( echo "$sum_should" | cut -d : -f 2 )"
|
|
|
|
fi
|
2020-06-20 22:13:30 +00:00
|
|
|
|
2021-06-22 13:36:30 +00:00
|
|
|
sum_cmd="$( "$__type_explorer/remote_cmd_sum" )"
|
2020-06-20 22:13:30 +00:00
|
|
|
|
2021-07-01 11:42:10 +00:00
|
|
|
# shellcheck disable=SC2059
|
2021-06-22 13:36:30 +00:00
|
|
|
sum_is="$( eval "$( printf "$sum_cmd" "'$dst'" )" )"
|
2020-06-20 22:13:30 +00:00
|
|
|
|
|
|
|
if [ -z "$sum_is" ]
|
|
|
|
then
|
2021-06-22 13:36:30 +00:00
|
|
|
echo 'existing destination checksum failed' >&2
|
2020-06-20 22:13:30 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$sum_is" = "$sum_should" ]
|
|
|
|
then
|
|
|
|
echo 'present'
|
2020-06-14 08:07:18 +00:00
|
|
|
else
|
2020-06-20 22:13:30 +00:00
|
|
|
echo 'mismatch'
|
2020-06-14 08:07:18 +00:00
|
|
|
fi
|