Implement Nico's suggestions
Modified behavior of cksum explorer to print nothing if the file doesn't exist Modified gencode-local to reflect cksum's new behavior Modified gencode-remote to check states explicitly and error on invalid state.
This commit is contained in:
parent
5f435c1be7
commit
6afec72232
3 changed files with 16 additions and 16 deletions
|
@ -34,8 +34,6 @@ PFCONF="${TMP:-"/etc/pf.conf"}"
|
|||
|
||||
if [ -f "${PFCONF}" ]; then # The pf config file exists, find its cksum.
|
||||
cksum -o 1 ${PFCONF} | cut -d= -f2 | awk '{print $1}'
|
||||
else # the pf config file doesn't exist
|
||||
echo NOTEXIST
|
||||
fi
|
||||
|
||||
# Debug
|
||||
|
|
|
@ -59,7 +59,7 @@ case $uname in
|
|||
;;
|
||||
esac
|
||||
|
||||
if [ ! "${cksum}" = "NOTEXIST" ]; then
|
||||
if [ -n "${cksum}" ]; then
|
||||
if [ ! "\${currentSum}" = "${cksum}" ]; then
|
||||
$__remote_copy "${source}" "$__target_host:${rcvar}.new"
|
||||
fi
|
||||
|
|
|
@ -28,20 +28,22 @@
|
|||
# Remove ${rcvar} in the case of --state absent
|
||||
|
||||
state=$(cat "$__object/parameter/state")
|
||||
|
||||
if [ ! "$state" = "absent" ]; then # There is nothing more for a *remote* script to do
|
||||
exit 0
|
||||
fi
|
||||
|
||||
rcvar=$(cat "$__object/explorer/rcvar")
|
||||
|
||||
# --state absent, so ensure that .new doesn't exist and that conf is renamed to .old
|
||||
cat <<EOF
|
||||
if [ -f "${rcvar}.new" ]; then
|
||||
rm "${rcvar}.new"
|
||||
fi
|
||||
if [ -f "${rcvar}" ]; then
|
||||
mv "${rcvar}" "${rcvar}.old"
|
||||
fi
|
||||
if [ "$state" = "present" ]; then # There is nothing more for a *remote* script to do
|
||||
exit 0
|
||||
elif [ "$state" = "absent" ]; then
|
||||
# --state absent, so ensure that .new doesn't exist and that conf is renamed to .old
|
||||
cat <<EOF
|
||||
if [ -f "${rcvar}.new" ]; then
|
||||
rm "${rcvar}.new"
|
||||
fi
|
||||
if [ -f "${rcvar}" ]; then
|
||||
mv "${rcvar}" "${rcvar}.old"
|
||||
fi
|
||||
EOF
|
||||
else
|
||||
echo "Unknown state ${state}!" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
Loading…
Reference in a new issue