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,13 +28,11 @@
|
|||
# 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")
|
||||
|
||||
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
|
||||
|
@ -44,4 +42,8 @@ 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