forked from ungleich-public/cdist
__git respects --owner and --group, add --mode
After checkout, chown and chmod as specified. If already present, but not possessing correct permissions, run chown and chmod as needed.
This commit is contained in:
parent
1d933dd5d3
commit
3ff7621984
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")"
|
state_is="$(cat "$__object/explorer/state")"
|
||||||
|
owner_is="$(cat "$__object/explorer/owner")"
|
||||||
|
group_is="$(cat "$__object/explorer/group")"
|
||||||
|
|
||||||
state_should=present
|
state_should=present
|
||||||
[ -f "$__object/parameter/state" ] && state_should="$(cat "$__object/parameter/state")"
|
[ -f "$__object/parameter/state" ] && state_should="$(cat "$__object/parameter/state")"
|
||||||
|
|
||||||
|
@ -30,11 +33,31 @@ source="$(cat "$__object/parameter/source")"
|
||||||
|
|
||||||
destination="/$__object_id"
|
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
|
case $state_should in
|
||||||
present)
|
present)
|
||||||
echo git clone --quiet --branch "$branch" "$source" "$destination"
|
|
||||||
|
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
|
# Handled in manifest
|
||||||
absent)
|
absent)
|
||||||
|
|
|
@ -26,9 +26,6 @@ __package git --state present
|
||||||
state_should=present
|
state_should=present
|
||||||
[ -f "$__object/parameter/state" ] && state_should="$(cat "$__object/parameter/state")"
|
[ -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
|
# Let __directory handle removal of git repos
|
||||||
|
|
||||||
case "$state_should" in
|
case "$state_should" in
|
||||||
|
|
|
@ -2,3 +2,4 @@ state
|
||||||
branch
|
branch
|
||||||
group
|
group
|
||||||
owner
|
owner
|
||||||
|
mode
|
||||||
|
|
Loading…
Reference in a new issue