forked from ungleich-public/cdist
Merge branch '__git_permissions' of https://github.com/contradict/cdist
This commit is contained in:
commit
55f2ea6b9f
5 changed files with 36 additions and 5 deletions
5
cdist/conf/type/__git/explorer/group
Normal file
5
cdist/conf/type/__git/explorer/group
Normal file
|
@ -0,0 +1,5 @@
|
|||
#!/bin/sh
|
||||
|
||||
destination="/$__object_id/.git"
|
||||
|
||||
stat --print "%G" ${destination} 2>/dev/null
|
5
cdist/conf/type/__git/explorer/owner
Normal file
5
cdist/conf/type/__git/explorer/owner
Normal file
|
@ -0,0 +1,5 @@
|
|||
#!/bin/sh
|
||||
|
||||
destination="/$__object_id/.git"
|
||||
|
||||
stat --print "%U" ${destination} 2>/dev/null
|
|
@ -20,6 +20,9 @@
|
|||
#
|
||||
|
||||
state_is="$(cat "$__object/explorer/state")"
|
||||
owner_is="$(cat "$__object/explorer/owner")"
|
||||
group_is="$(cat "$__object/explorer/group")"
|
||||
|
||||
state_should=present
|
||||
[ -f "$__object/parameter/state" ] && state_should="$(cat "$__object/parameter/state")"
|
||||
|
||||
|
@ -30,11 +33,31 @@ source="$(cat "$__object/parameter/source")"
|
|||
|
||||
destination="/$__object_id"
|
||||
|
||||
[ "$state_should" = "$state_is" ] && exit 0
|
||||
owner=""
|
||||
[ -f "$__object/parameter/owner" ] && owner="$(cat "$__object/parameter/owner")"
|
||||
group=""
|
||||
[ -f "$__object/parameter/group" ] && group="$(cat "$__object/parameter/group")"
|
||||
mode=""
|
||||
[ -f "$__object/parameter/mode" ] && mode="$(cat "$__object/parameter/mode")"
|
||||
|
||||
[ "$state_should" = "$state_is" -a \
|
||||
"$owner" = "$owner_is" -a \
|
||||
"$group" = "$group_is" -a \
|
||||
-n "$mode" ] && exit 0
|
||||
|
||||
case $state_should in
|
||||
present)
|
||||
|
||||
if [ "$state_should" != "$state_is" ]; then
|
||||
echo git clone --quiet --branch "$branch" "$source" "$destination"
|
||||
fi
|
||||
if [ \( -n ${owner} -a "$owner_is" != "$owner" \) -o \
|
||||
\( -n ${group} -a "$group_is" != "$group" \) ]; then
|
||||
echo chown -R ${owner}:${group} ${destination}
|
||||
fi
|
||||
if [ -n ${mode} ]; then
|
||||
echo chmod -R ${mode} ${destination}
|
||||
fi
|
||||
;;
|
||||
# Handled in manifest
|
||||
absent)
|
||||
|
|
|
@ -26,9 +26,6 @@ __package git --state present
|
|||
state_should=present
|
||||
[ -f "$__object/parameter/state" ] && state_should="$(cat "$__object/parameter/state")"
|
||||
|
||||
[ -f "$__object/parameter/owner" ] && dirparams="$dirparams --owner $(cat "$__object/parameter/owner")"
|
||||
[ -f "$__object/parameter/group" ] && dirparams="$dirparams --group $(cat "$__object/parameter/group")"
|
||||
|
||||
# Let __directory handle removal of git repos
|
||||
|
||||
case "$state_should" in
|
||||
|
|
|
@ -2,3 +2,4 @@ state
|
|||
branch
|
||||
group
|
||||
owner
|
||||
mode
|
||||
|
|
Loading…
Reference in a new issue