|
|
@ -1,7 +1,7 @@ |
|
|
|
#!/bin/sh |
|
|
|
#!/bin/sh |
|
|
|
# |
|
|
|
# |
|
|
|
# 2011-2012 Nico Schottelius (nico-cdist at schottelius.org) |
|
|
|
# 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. |
|
|
|
# This file is part of cdist. |
|
|
|
# |
|
|
|
# |
|
|
@ -18,9 +18,6 @@ |
|
|
|
# You should have received a copy of the GNU General Public License |
|
|
|
# You should have received a copy of the GNU General Public License |
|
|
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>. |
|
|
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>. |
|
|
|
# |
|
|
|
# |
|
|
|
# |
|
|
|
|
|
|
|
# Mostly a wrapper for ln |
|
|
|
|
|
|
|
# |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
destination="/$__object_id" |
|
|
|
destination="/$__object_id" |
|
|
|
|
|
|
|
|
|
|
@ -50,20 +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 |
|
|
|
|
|
|
|
# our destination is a symlink but points to the wrong source, |
|
|
|
|
|
|
|
# delete it |
|
|
|
|
|
|
|
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 |
|
|
|
;; |
|
|
|
;; |
|
|
|
*) |
|
|
|
*) |
|
|
|