Merge branch '__clean_path_add_path_param' into 'master'

[__clean_path] add --path parameter

See merge request ungleich-public/cdist!889
This commit is contained in:
poljakowski 2020-06-10 10:44:20 +02:00
commit b22e09e1af
4 changed files with 22 additions and 3 deletions

View file

@ -18,7 +18,12 @@
# along with cdist. If not, see <http://www.gnu.org/licenses/>. # along with cdist. If not, see <http://www.gnu.org/licenses/>.
# #
path="/$__object_id" if [ -f "$__object/parameter/path" ]
then
path="$( cat "$__object/parameter/path" )"
else
path="/$__object_id"
fi
[ ! -d "$path" ] && exit 0 [ ! -d "$path" ] && exit 0

View file

@ -20,7 +20,12 @@
[ ! -s "$__object/explorer/list" ] && exit 0 [ ! -s "$__object/explorer/list" ] && exit 0
path="/$__object_id" if [ -f "$__object/parameter/path" ]
then
path="$( cat "$__object/parameter/path" )"
else
path="/$__object_id"
fi
pattern="$( cat "$__object/parameter/pattern" )" pattern="$( cat "$__object/parameter/pattern" )"

View file

@ -10,7 +10,7 @@ DESCRIPTION
----------- -----------
Remove files and directories which match the pattern. Remove files and directories which match the pattern.
Provided path (as __object_id) must be a directory. Provided path must be a directory.
Patterns are passed to ``find``'s ``-regex`` - see ``find(1)`` for more details. Patterns are passed to ``find``'s ``-regex`` - see ``find(1)`` for more details.
@ -29,6 +29,9 @@ pattern
OPTIONAL PARAMETERS OPTIONAL PARAMETERS
------------------- -------------------
path
Path which will be cleaned. Defaults to ``$__object_id``.
exclude exclude
Pattern of files which are excluded from removal. Pattern of files which are excluded from removal.
@ -46,6 +49,11 @@ EXAMPLES
--exclude '.+\(charset\.conf\|security\.conf\)' \ --exclude '.+\(charset\.conf\|security\.conf\)' \
--onchange 'service apache2 restart' --onchange 'service apache2 restart'
__clean_path apache2-conf-enabled \
--path /etc/apache2/conf-enabled \
--pattern '.+' \
--exclude '.+\(charset\.conf\|security\.conf\)' \
--onchange 'service apache2 restart'
AUTHORS AUTHORS
------- -------

View file

@ -1,2 +1,3 @@
exclude exclude
onchange onchange
path