forked from ungleich-public/cdist
		
	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. | if [ -f "${PFCONF}" ]; then	# The pf config file exists, find its cksum. | ||||||
| 	cksum -o 1 ${PFCONF} | cut -d= -f2 | awk '{print $1}' | 	cksum -o 1 ${PFCONF} | cut -d= -f2 | awk '{print $1}' | ||||||
| else	# the pf config file doesn't exist |  | ||||||
| 	echo NOTEXIST |  | ||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
| # Debug | # Debug | ||||||
|  |  | ||||||
|  | @ -59,7 +59,7 @@ case $uname in | ||||||
|       ;; |       ;; | ||||||
| esac | esac | ||||||
| 
 | 
 | ||||||
| if [ ! "${cksum}" = "NOTEXIST" ]; then | if [ -n "${cksum}" ]; then | ||||||
|    if [ ! "\${currentSum}" = "${cksum}" ]; then |    if [ ! "\${currentSum}" = "${cksum}" ]; then | ||||||
|       $__remote_copy "${source}" "$__target_host:${rcvar}.new" |       $__remote_copy "${source}" "$__target_host:${rcvar}.new" | ||||||
|    fi |    fi | ||||||
|  |  | ||||||
|  | @ -28,20 +28,22 @@ | ||||||
| # Remove ${rcvar} in the case of --state absent | # Remove ${rcvar} in the case of --state absent | ||||||
| 
 | 
 | ||||||
| state=$(cat "$__object/parameter/state") | 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") | rcvar=$(cat "$__object/explorer/rcvar") | ||||||
| 
 | 
 | ||||||
| # --state absent, so ensure that .new doesn't exist and that conf is renamed to .old | if [ "$state" = "present" ]; then   # There is nothing more for a *remote* script to do | ||||||
| cat <<EOF |    exit 0 | ||||||
| if [ -f "${rcvar}.new" ]; then | 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" |       rm "${rcvar}.new" | ||||||
| fi |    fi | ||||||
| if [ -f "${rcvar}" ]; then |    if [ -f "${rcvar}" ]; then | ||||||
|       mv "${rcvar}" "${rcvar}.old" |       mv "${rcvar}" "${rcvar}.old" | ||||||
| fi |    fi | ||||||
| EOF | EOF | ||||||
|  | else | ||||||
|  |    echo "Unknown state ${state}!" >&2 | ||||||
|  |    exit 1 | ||||||
|  | fi | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue