2021-07-07 17:47:22 +00:00
|
|
|
#!/bin/sh -e
|
|
|
|
|
|
|
|
if [ -f "$__object/parameter/file" ]
|
|
|
|
then
|
|
|
|
file="$( cat "$__object/parameter/file" )"
|
|
|
|
else
|
|
|
|
file="/$__object_id"
|
|
|
|
fi
|
|
|
|
|
|
|
|
script="$( cat "$__object/parameter/script" )"
|
|
|
|
|
|
|
|
if [ "$script" = '-' ]
|
|
|
|
then
|
|
|
|
script="$( cat "$__object/stdin" )"
|
|
|
|
elif
|
|
|
|
[ -f "$script" ]
|
|
|
|
then
|
|
|
|
script="$( cat "$script" )"
|
|
|
|
fi
|
|
|
|
|
|
|
|
file_from_target="$__object/explorer/file"
|
|
|
|
|
|
|
|
sed_cmd='sed'
|
|
|
|
|
|
|
|
if [ -f "$__object/parameter/regexp-extended" ]
|
|
|
|
then
|
|
|
|
sed_cmd="$sed_cmd --regexp-extended"
|
|
|
|
fi
|
|
|
|
|
2021-07-07 18:28:00 +00:00
|
|
|
if echo "$script" \
|
2021-07-07 17:47:22 +00:00
|
|
|
| "$sed_cmd" -f - "$file_from_target" \
|
|
|
|
| diff "$file_from_target" - \
|
|
|
|
> /dev/null
|
|
|
|
then
|
2021-07-07 18:28:00 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# shellcheck disable=SC2016
|
|
|
|
echo 'tmp="$( mktemp )"'
|
2021-07-07 17:47:22 +00:00
|
|
|
|
2021-07-07 18:28:00 +00:00
|
|
|
echo "$sed_cmd -f - '$file' > \"\$tmp\" << EOF"
|
2021-07-07 17:47:22 +00:00
|
|
|
|
2021-07-07 18:28:00 +00:00
|
|
|
echo "$script"
|
2021-07-07 17:47:22 +00:00
|
|
|
|
2021-07-07 18:28:00 +00:00
|
|
|
echo 'EOF'
|
2021-07-07 17:47:22 +00:00
|
|
|
|
2021-07-07 18:28:00 +00:00
|
|
|
echo "cp \"\$tmp\" '$file'"
|
2021-07-07 18:23:25 +00:00
|
|
|
|
2021-07-07 18:28:00 +00:00
|
|
|
# shellcheck disable=SC2016
|
|
|
|
echo 'rm -f "$tmp"'
|
2021-07-07 18:23:25 +00:00
|
|
|
|
2021-07-07 18:28:00 +00:00
|
|
|
echo 'change' >> "$__messages_out"
|
|
|
|
|
|
|
|
if [ -f "$__object/parameter/onchange" ]
|
|
|
|
then
|
|
|
|
cat "$__object/parameter/onchange"
|
2021-07-07 17:47:22 +00:00
|
|
|
fi
|