Compare commits

..

1 commit

Author SHA1 Message Date
Simon Walter
a072dc9367 __directory to support --source path 2024-05-07 17:08:04 +02:00
7 changed files with 75 additions and 16 deletions

View 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

View file

@ -41,6 +41,9 @@ mode
owner
User to chown to.
source
If provided, the contents of this path will be copied to the directory.
BOOLEAN PARAMETERS
------------------

View 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

View file

@ -2,3 +2,4 @@ state
group
mode
owner
source

View file

@ -34,12 +34,3 @@ case "$os" in
echo "echo \"$timezone_should\" > /etc/timezone"
;;
esac
case "$os" in
openwrt)
cat <<EOF
uci set system.@system[0].timezone="$timezone_should"
uci commit
EOF
;;
esac

View file

@ -53,10 +53,7 @@ case "$os" in
--file /etc/sysconfig/clock \
--delimiter '=' \
--value "\"$timezone\""
;;
openwrt)
: # Uses gencode-remote
;;
;;
*)
echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2
echo "Please contribute an implementation for it if you can." >&2

View file

@ -1,9 +1,6 @@
Changelog
---------
next:
* Type __timezone: Add support for OpenWRT (Nico Schottelius)
7.0.1:
* Core: Remove double definition of scan parser (Nico Schottelius)
* Type __apt_mark: Narrow down grep for hold packages (marcoduif)