This commit is contained in:
Nico Schottelius 2014-03-26 11:15:36 +01:00
commit 73b54aab09
2 changed files with 18 additions and 14 deletions

View file

@ -1,6 +1,6 @@
#!/bin/sh
#
# 2012 Steven Armstrong (steven-cdist at armstrong.cc)
# 2012-2014 Steven Armstrong (steven-cdist at armstrong.cc)
#
# This file is part of cdist.
#
@ -34,8 +34,13 @@ case "$type" in
symbolic)
cd "$destination_dir"
source_is=$(ls -l "$destination" | sed 's/.*-> //g')
if [ -h "$destination" -a "$source_is" = "$source" ]; then
echo present
if [ -h "$destination" ]; then
# ignore trailing slashes for comparison
if [ "${source_is%/}" = "${source%/}" ]; then
echo present
else
echo wrongsource
fi
else
echo absent
fi

View file

@ -1,7 +1,7 @@
#!/bin/sh
#
# 2011-2012 Nico Schottelius (nico-cdist at schottelius.org)
# 2013 Steven Armstrong (steven-cdist at armstrong.cc)
# 2013-2014 Steven Armstrong (steven-cdist at armstrong.cc)
#
# This file is part of cdist.
#
@ -18,9 +18,6 @@
# You should have received a copy of the GNU General Public License
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
#
#
# Mostly a wrapper for ln
#
destination="/$__object_id"
@ -50,20 +47,22 @@ case "$state_should" in
present)
if [ "$file_type" = "directory" ]; then
# our destination is currently a directory, delete it
cat << DONE
rm -rf "$destination"
DONE
printf 'rm -rf "%s" &&\n' "$destination"
else
if [ "$state_is" = "wrongsource" ]; then
# our destination is a symlink but points to the wrong source,
# delete it
printf 'rm -f "%s" &&\n' "$destination"
fi
fi
# create our link
cat << DONE
ln ${lnopt} -f "$source" "$destination"
DONE
printf 'ln %s -f "%s" "%s"\n' "$lnopt" "$source" "$destination"
;;
absent)
# only delete if it is a sym/hard link
if [ "$file_type" = "symlink" -o "$file_type" = "hardlink" ]; then
echo rm -f \"$destination\"
printf 'rm -f "%s"\n' "$destination"
fi
;;
*)