Browse Source

new type: __sed

ander/__sed
ander 1 year ago
parent
commit
485283f2e5
No known key found for this signature in database
GPG Key ID: A2971E562D618F3
  1. 22
      cdist/conf/type/__sed/explorer/file
  2. 46
      cdist/conf/type/__sed/gencode-remote
  3. 49
      cdist/conf/type/__sed/man.rst
  4. 1
      cdist/conf/type/__sed/parameter/boolean
  5. 1
      cdist/conf/type/__sed/parameter/optional
  6. 1
      cdist/conf/type/__sed/parameter/required_multiple

22
cdist/conf/type/__sed/explorer/file vendored

@ -0,0 +1,22 @@
#!/bin/sh -e
if [ -f "$__object/parameter/file" ]
then
file="$( cat "$__object/parameter/file" )"
else
file="/$__object_id"
fi
if [ -f "$file" ]
then
if [ -s "$file" ]
then
cat "$file"
else
echo "$file is empty" >&2
exit 1
fi
else
echo "$file do not exist" >&2
exit 1
fi

46
cdist/conf/type/__sed/gencode-remote vendored

@ -0,0 +1,46 @@
#!/bin/sh -e
if [ -f "$__object/parameter/file" ]
then
file="$( cat "$__object/parameter/file" )"
else
file="/$__object_id"
fi
script="$( cat "$__object/parameter/script" )"
if [ "$script" = '-' ]
then
script="$( cat "$__object/stdin" )"
elif
[ -f "$script" ]
then
script="$( cat "$script" )"
fi
file_from_target="$__object/explorer/file"
sed_cmd='sed'
if [ -f "$__object/parameter/regexp-extended" ]
then
sed_cmd="$sed_cmd --regexp-extended"
fi
if ! echo "$script" \
| "$sed_cmd" -f - "$file_from_target" \
| diff "$file_from_target" - \
> /dev/null
then
echo 'tmp="$( mktemp )"'
echo "$sed_cmd -f - '$file' > \"\$tmp\" << EOF"
echo "$script"
echo 'EOF'
echo "cp \"\$tmp\" '$file'"
echo 'rm -f "$tmp"'
fi

49
cdist/conf/type/__sed/man.rst vendored

@ -0,0 +1,49 @@
cdist-type__sed(7)
==================
NAME
----
cdist-type__sed - Transform text files with ``sed``
DESCRIPTION
-----------
TODO
REQUIRED MULTIPLE PARAMETERS
----------------------------
script
TODO
OPTIONAL PARAMETERS
-------------------
file
TODO
BOOLEAN PARAMETERS
------------------
regexp-extended
TODO
EXAMPLES
--------
.. code-block:: sh
true
AUTHORS
-------
Ander Punnar <ander-at-kvlt-dot-ee>
COPYING
-------
Copyright \(C) 2021 Ander Punnar. 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.

1
cdist/conf/type/__sed/parameter/boolean vendored

@ -0,0 +1 @@
regexp-extended

1
cdist/conf/type/__sed/parameter/optional vendored

@ -0,0 +1 @@
file

1
cdist/conf/type/__sed/parameter/required_multiple vendored

@ -0,0 +1 @@
script
Loading…
Cancel
Save