forked from ungleich-public/cdist
[__download] add --download (local|remote), update manual
This commit is contained in:
parent
26dfdf37c2
commit
85614aabd6
7 changed files with 65 additions and 12 deletions
19
cdist/conf/type/__download/explorer/remote_cmd
Executable file
19
cdist/conf/type/__download/explorer/remote_cmd
Executable file
|
@ -0,0 +1,19 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
if [ -f "$__object/parameter/cmd-get" ]
|
||||
then
|
||||
cmd="$( cat "$__object/parameter/cmd-get" )"
|
||||
|
||||
elif command -v curl > /dev/null
|
||||
then
|
||||
cmd="curl -o - '%s'"
|
||||
|
||||
elif command -v fetch > /dev/null
|
||||
then
|
||||
cmd="fetch -o - '%s'"
|
||||
|
||||
else
|
||||
cmd="wget -O - '%s'"
|
||||
fi
|
||||
|
||||
echo "$cmd"
|
|
@ -1,8 +1,10 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
download="$( cat "$__object/parameter/download" )"
|
||||
|
||||
state_is="$( cat "$__object/explorer/state" )"
|
||||
|
||||
if [ "$state_is" = 'present' ]
|
||||
if [ "$download" != 'local' ] || [ "$state_is" = 'present' ]
|
||||
then
|
||||
exit 0
|
||||
fi
|
||||
|
|
|
@ -1,7 +1,25 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
if [ -f "$__object/parameter/onchange" ] \
|
||||
&& grep -Fq "$__object_id:downloaded" "$__messages_in"
|
||||
download="$( cat "$__object/parameter/download" )"
|
||||
|
||||
state_is="$( cat "$__object/explorer/state" )"
|
||||
|
||||
if [ "$download" = 'remote' ] && [ "$state_is" != 'present' ]
|
||||
then
|
||||
cmd="$( cat "$__object/explorer/remote_cmd" )"
|
||||
|
||||
url="$( cat "$__object/parameter/url" )"
|
||||
|
||||
dst="/$__object_id"
|
||||
|
||||
printf "$cmd > %s\n" \
|
||||
"$url" \
|
||||
"$dst"
|
||||
|
||||
echo 'downloaded' > "$__messages_out"
|
||||
fi
|
||||
|
||||
if [ -f "$__object/parameter/onchange" ] && [ "$state" != "present" ]
|
||||
then
|
||||
cat "$__object/parameter/onchange"
|
||||
fi
|
||||
|
|
|
@ -3,26 +3,28 @@ cdist-type__download(7)
|
|||
|
||||
NAME
|
||||
----
|
||||
cdist-type__download - Download file to local storage and copy it to target host
|
||||
cdist-type__download - Download a file
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
You must use persistent storage in target host for destination file
|
||||
(``$__object_id``) because it will be used for checksum calculation
|
||||
in order to decide if file must be (re-)downloaded.
|
||||
Persistent storage for destination file in target host must be used
|
||||
(``$__object_id``) because it will be used for checksum calculation in
|
||||
order to decide if file must be (re-)downloaded.
|
||||
|
||||
By default type will try to use following locally installed utilities
|
||||
for downloading (in order): ``wget``, ``curl`` or ``fetch``.
|
||||
By default type will try to use ``wget``, ``curl`` or ``fetch`` for
|
||||
downloading. If ``--download remote`` type will fallback to (and
|
||||
install) ``wget``.
|
||||
|
||||
Environment variables like ``{http,https,ftp}_proxy`` etc can be used on
|
||||
cdist execution (``http_proxy=foo cdist config ...``).
|
||||
If ``--download local`` (default), then environment variables like
|
||||
``{http,https,ftp}_proxy`` etc can be used on cdist execution
|
||||
(``http_proxy=foo cdist config ...``).
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
url
|
||||
URL from which to download the file.
|
||||
File's URL.
|
||||
|
||||
sum
|
||||
Checksum of file going to be downloaded.
|
||||
|
@ -35,6 +37,10 @@ onchange
|
|||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
download
|
||||
If ``local`` (default), then download file to local storage and copy
|
||||
it to target host. If ``remote``, then download happens in target.
|
||||
|
||||
cmd-get
|
||||
Command used for downloading.
|
||||
Command must output to ``stdout``.
|
||||
|
|
6
cdist/conf/type/__download/manifest
Executable file
6
cdist/conf/type/__download/manifest
Executable file
|
@ -0,0 +1,6 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
if grep -Eq '^wget' "$__object/explorer/remote_cmd"
|
||||
then
|
||||
__package wget
|
||||
fi
|
1
cdist/conf/type/__download/parameter/default/download
Normal file
1
cdist/conf/type/__download/parameter/default/download
Normal file
|
@ -0,0 +1 @@
|
|||
local
|
|
@ -1,3 +1,4 @@
|
|||
cmd-get
|
||||
cmd-sum
|
||||
download
|
||||
onchange
|
||||
|
|
Loading…
Reference in a new issue