forked from ungleich-public/cdist
Merge pull request 'add optional file parameter to allow for use in a loop without object_id clashes' (#334) from stephan/cdist:master into master
Reviewed-on: ungleich-public/cdist#334
This commit is contained in:
commit
1edc4d0a60
2 changed files with 23 additions and 2 deletions
|
@ -37,6 +37,12 @@ state
|
|||
source
|
||||
forwarded to :strong:`__file` type
|
||||
|
||||
file
|
||||
forwarded to :strong:`__file` type
|
||||
This can be used if multiple users need to have a dotfile updated,
|
||||
which will result in duplicate object id errors. When using the
|
||||
file parameter the object id can be some unique value.
|
||||
|
||||
MESSAGES
|
||||
--------
|
||||
|
||||
|
@ -61,6 +67,15 @@ EXAMPLES
|
|||
# Install default xmonad config for user 'eve'. Parent directory is created automatically.
|
||||
__dot_file .xmonad/xmonad.hs --user eve --state exists --source "$__files/xmonad.hs"
|
||||
|
||||
# install .vimrc for root and some users
|
||||
for user in root userx usery userz; do
|
||||
__dot_file "${user}_dot_vimrc" \
|
||||
--user $user \
|
||||
--file .vimrc \
|
||||
--state exists \
|
||||
--source "$__files/$user/.vimrc"
|
||||
done
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
|
||||
|
|
|
@ -20,13 +20,19 @@ user="$(cat "${__object}/parameter/user")"
|
|||
home="$(cat "${__object}/explorer/home")"
|
||||
primary_group="$(cat "${__object}/explorer/primary_group")"
|
||||
dirmode="$(cat "${__object}/parameter/dirmode")"
|
||||
if [ -f "${__object}/parameter/file" ]; then
|
||||
file="$(cat "${__object}/parameter/file")"
|
||||
else
|
||||
file="${__object_id}"
|
||||
fi
|
||||
|
||||
|
||||
# Create parent directory. Type __directory has flag 'parents', but it
|
||||
# will leave us with root-owned directory in user home, which is not
|
||||
# acceptable. So we create parent directories one-by-one. XXX: maybe
|
||||
# it should be fixed in '__directory'?
|
||||
set --
|
||||
subpath=${__object_id}
|
||||
subpath=${file}
|
||||
while subpath="$(dirname "${subpath}")" ; do
|
||||
[ "${subpath}" = . ] && break
|
||||
set -- "${subpath}" "$@"
|
||||
|
@ -64,4 +70,4 @@ if [ "${source}" = "-" ] ; then
|
|||
fi
|
||||
unset source
|
||||
|
||||
__file "${home}/${__object_id}" --owner "$user" --group "$primary_group" "$@"
|
||||
__file "${home}/${file}" --owner "$user" --group "$primary_group" "$@"
|
||||
|
|
Loading…
Reference in a new issue