__directory to support --source path
This commit is contained in:
parent
3e82b0085b
commit
a072dc9367
4 changed files with 74 additions and 0 deletions
32
cdist/conf/type/__directory/gencode-local
Normal file
32
cdist/conf/type/__directory/gencode-local
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2022 Simon Walter (simon at explicit dot technology)
|
||||||
|
#
|
||||||
|
# This file is part of cdist.
|
||||||
|
#
|
||||||
|
# cdist is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# cdist is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
|
||||||
|
destination="/$__object_id"
|
||||||
|
|
||||||
|
if [ -f "$__object/parameter/source" ]; then
|
||||||
|
source="$(cat $__object/parameter/source)"
|
||||||
|
# -rp is compatible with both scp and rsync default __remote_copy
|
||||||
|
# However, the default rsync has a --backup switch which will fill up disk
|
||||||
|
# especially with large number of files.
|
||||||
|
cat << DONE
|
||||||
|
$__remote_exec $__target_host "mkdir -p $destination"
|
||||||
|
$__remote_copy -rp "$source" "${__target_host}:$destination"
|
||||||
|
DONE
|
||||||
|
fi
|
|
@ -41,6 +41,9 @@ mode
|
||||||
owner
|
owner
|
||||||
User to chown to.
|
User to chown to.
|
||||||
|
|
||||||
|
source
|
||||||
|
If provided, the contents of this path will be copied to the directory.
|
||||||
|
|
||||||
|
|
||||||
BOOLEAN PARAMETERS
|
BOOLEAN PARAMETERS
|
||||||
------------------
|
------------------
|
||||||
|
|
38
cdist/conf/type/__directory/manifest
Normal file
38
cdist/conf/type/__directory/manifest
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2022 Simon Walter (simon at explicit dot technology)
|
||||||
|
#
|
||||||
|
# This file is part of cdist.
|
||||||
|
#
|
||||||
|
# cdist is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# cdist is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
|
||||||
|
# FIXME: What does cdist use for unit testing?
|
||||||
|
# FIXME: Output to stderr is no longer visible by default. Is there a correct
|
||||||
|
# way to do this?
|
||||||
|
|
||||||
|
if [ -f "$__object/parameter/source" ]; then
|
||||||
|
export source="$(cat "$__object/parameter/source")"
|
||||||
|
if [ -d "$source" ]; then
|
||||||
|
if [ "$(ls "$source" | wc -w)" -gt 0 ]; then
|
||||||
|
echo "Copying files from (--source): $source" >&2
|
||||||
|
# See gencode-local
|
||||||
|
else
|
||||||
|
echo "No files in (--source): $source" >&2
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Directory (--source) not found: $source" >&2
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
|
@ -2,3 +2,4 @@ state
|
||||||
group
|
group
|
||||||
mode
|
mode
|
||||||
owner
|
owner
|
||||||
|
source
|
||||||
|
|
Loading…
Reference in a new issue