forked from ungleich-public/cdist
either to it all, or fail; echo and cat suck, printf ftw!
Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
parent
75c203a1f0
commit
301b4e18ff
1 changed files with 9 additions and 11 deletions
|
@ -47,24 +47,22 @@ case "$state_should" in
|
||||||
present)
|
present)
|
||||||
if [ "$file_type" = "directory" ]; then
|
if [ "$file_type" = "directory" ]; then
|
||||||
# our destination is currently a directory, delete it
|
# our destination is currently a directory, delete it
|
||||||
cat << DONE
|
printf 'rm -rf "%s" &&\n' "$destination"
|
||||||
rm -rf "$destination"
|
else
|
||||||
DONE
|
if [ "$state_is" = "wrongsource" ]; then
|
||||||
fi
|
# our destination is a symlink but points to the wrong source,
|
||||||
|
# delete it
|
||||||
if [ "$state_is" = "wrongsource" ]; then
|
printf 'rm -f "%s" &&\n' "$destination"
|
||||||
printf 'rm -f "%s"\n' "$destination"
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# create our link
|
# create our link
|
||||||
cat << DONE
|
printf 'ln %s -f "%s" "%s"\n' "$lnopt" "$source" "$destination"
|
||||||
ln ${lnopt} -f "$source" "$destination"
|
|
||||||
DONE
|
|
||||||
;;
|
;;
|
||||||
absent)
|
absent)
|
||||||
# only delete if it is a sym/hard link
|
# only delete if it is a sym/hard link
|
||||||
if [ "$file_type" = "symlink" -o "$file_type" = "hardlink" ]; then
|
if [ "$file_type" = "symlink" -o "$file_type" = "hardlink" ]; then
|
||||||
echo rm -f \"$destination\"
|
printf 'rm -f "%s"\n' "$destination"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|
Loading…
Reference in a new issue