shellcheck fixes

This commit is contained in:
Darko Poljak 2017-09-29 19:34:52 +02:00
parent 309315910e
commit 775d3dfc2c
26 changed files with 47 additions and 34 deletions

View file

@ -18,7 +18,7 @@
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
#
name="$__object_id"
# name="$__object_id"
__package software-properties-common

View file

@ -19,7 +19,7 @@
#
set -- "/${__object_id}"
for param in "$__object/parameter/*"; do
for param in $__object/parameter/*; do
case "$param" in
source)
source="$(cat "$__object/parameter/source")"

View file

@ -84,7 +84,7 @@ echo "{"
# parameters we define ourself
printf ' "data_dir": "%s"\n' "$data_dir"
for param in "$__object/parameter/*"; do
for param in $__object/parameter/*; do
case "$param" in
state|user|group|json-config) continue ;;
ca-file-source|cert-file-source|key-file-source)

View file

@ -50,7 +50,7 @@ fi
echo "{"
printf ' "check": {\n'
printf ' "name": "%s"\n' "$name"
for param in "$__object/parameter/*"; do
for param in $__object/parameter/*; do
case "$param" in
state|name) continue ;;
*)

View file

@ -42,7 +42,7 @@ fi
echo "{"
printf ' "service": {\n'
printf ' "name": "%s"\n' "$name"
for param in "$__object/parameter/*"; do
for param in $__object/parameter/*; do
case "$param" in
state|name|check-interval) continue ;;
check-script)

View file

@ -75,7 +75,7 @@ require="__directory/etc/consul-template" \
# Generate hcl config file
(
for param in "$__object/parameter/*"; do
for param in $__object/parameter/*; do
case "$param" in
auth-password|state|ssl-*|syslog-*|version|vault-token|vault-ssl*) continue ;;
auth-username)

View file

@ -38,7 +38,7 @@ fi
# Generate hcl config file
(
printf 'template {\n'
for param in "$__object/parameter/*"; do
for param in $__object/parameter/*; do
case "$param" in
source-file)
source="$(cat "$__object/parameter/$param")"

View file

@ -35,7 +35,7 @@ fi
echo "{"
printf ' "watches": [{\n'
printf ' "type": "%s"\n' "$watch_type"
for param in "$__object/parameter/*"; do
for param in $__object/parameter/*; do
case "$param" in
state) continue ;;
filter-*)

View file

@ -29,7 +29,7 @@ state="$(cat "$__object/parameter/state")"
echo "{"
printf ' "watches": [{\n'
printf ' "type": "%s"\n' "$watch_type"
for param in "$__object/parameter/*"; do
for param in $__object/parameter/*; do
case "$param" in
state) continue ;;
*)

View file

@ -29,7 +29,7 @@ state="$(cat "$__object/parameter/state")"
echo "{"
printf ' "watches": [{\n'
printf ' "type": "%s"\n' "$watch_type"
for param in "$__object/parameter/*"; do
for param in $__object/parameter/*; do
case "$param" in
state) continue ;;
*)

View file

@ -29,7 +29,7 @@ state="$(cat "$__object/parameter/state")"
echo "{"
printf ' "watches": [{\n'
printf ' "type": "%s"\n' "$watch_type"
for param in "$__object/parameter/*"; do
for param in $__object/parameter/*; do
case "$param" in
state) continue ;;
*)

View file

@ -29,7 +29,7 @@ state="$(cat "$__object/parameter/state")"
echo "{"
printf ' "watches": [{\n'
printf ' "type": "%s"\n' "$watch_type"
for param in "$__object/parameter/*"; do
for param in $__object/parameter/*; do
case "$param" in
state) continue ;;
*)

View file

@ -29,7 +29,7 @@ state="$(cat "$__object/parameter/state")"
echo "{"
printf ' "watches": [{\n'
printf ' "type": "%s"\n' "$watch_type"
for param in $(ls "$__object/parameter/"); do
for param in $__object/parameter/*; do
case "$param" in
state) continue ;;
passingonly)

View file

@ -29,7 +29,7 @@ state="$(cat "$__object/parameter/state")"
echo "{"
printf ' "watches": [{\n'
printf ' "type": "%s"\n' "$watch_type"
for param in "$__object/parameter/*"; do
for param in $__object/parameter/*; do
case "$param" in
state) continue ;;
*)

View file

@ -19,7 +19,7 @@
#
#
name="$__object_id"
# name="$__object_id"
state_should="$(cat "$__object/parameter/state")"
state_is="$(cat "$__object/explorer/rule")"

View file

@ -25,7 +25,9 @@ mkdir "$__object/files"
# get current UUID's from target_host
$__remote_exec "$__target_host" blkid > "$__object/files/blkid"
for object in $(find "$__global/object/__install_mount" -type d -name "$__cdist_object_marker"); do
find "$__global/object/__install_mount" -type d -name "$__cdist_object_marker" |
while IFS= read -r object
do
device="$(cat "$object/parameter/device")"
dir="$(cat "$object/parameter/dir")"
type="$(cat "$object/parameter/type")"

View file

@ -19,13 +19,18 @@
#
# set defaults
if [ -f "$__object/parameter/device" ]; then
device="(cat "$__object/parameter/device")"
else
# if [ -f "$__object/parameter/device" ]; then
# device="(cat "$__object/parameter/device")"
# else
# device="/$__object_id"
# echo "$device" > "$__object/parameter/device"
# fi
# type="(cat "$__object/parameter/type")"
# options="(cat "$__object/parameter/options")"
if [ ! -f "$__object/parameter/device" ]; then
device="/$__object_id"
echo "$device" > "$__object/parameter/device"
fi
type="(cat "$__object/parameter/type")"
options="(cat "$__object/parameter/options")"

View file

@ -20,7 +20,9 @@
get_type_from_mkfs() {
_device="$1"
for mkfs_object in $(find "$__global/object/__install_mkfs" -type d -name "$__cdist_object_marker"); do
find "$__global/object/__install_mkfs" -type d -name "$__cdist_object_marker" |
while IFS= read -r mkfs_object
do
mkfs_device="$(cat "$mkfs_object/parameter/device")"
if [ "$_device" = "$mkfs_device" ]; then
cat "$mkfs_object/parameter/type"

View file

@ -59,7 +59,9 @@ size_to_mb() {
get_objects() {
objects_file=$(mktemp)
for object in $(find "$__global/object/__install_partition_msdos" -type d -name "$__cdist_object_marker"); do
find "$__global/object/__install_partition_msdos" -type d -name "$__cdist_object_marker" |
while IFS= read -r object
do
object_device="$(cat "$object/parameter/device")"
object_minor="$(cat "$object/parameter/minor")"
echo "$object_device $object_minor $object" >> "$objects_file"

View file

@ -19,5 +19,6 @@
#
# set defaults
options="$(cat "$__object/parameter/options" 2>/dev/null \
|| echo "" | tee "$__object/parameter/options")"
# options="$(cat "$__object/parameter/options" 2>/dev/null \
# || echo "" | tee "$__object/parameter/options")"
cat "$__object/parameter/options" 2>/dev/null 1>/dev/null || echo "" > "$__object/parameter/options"

View file

@ -19,5 +19,6 @@
#
# set defaults
target="$(cat "$__object/parameter/target" 2>/dev/null \
|| echo "/target" | tee "$__object/parameter/target")"
# target="$(cat "$__object/parameter/target" 2>/dev/null \
# || echo "/target" | tee "$__object/parameter/target")"
cat "$__object/parameter/target" 2>/dev/null 1>/dev/null || echo "/target" > "$__object/parameter/target"

View file

@ -44,7 +44,7 @@ for property in *; do
done
ver="$(cat "$__global/explorer/os_version")"
if "$(echo "$ver" | grep -q '^10\.' )"; then # Version is 10.x
if echo "$ver" | grep -q '^10\.'; then # Version is 10.x
__jail_freebsd10 "$@"
else
__jail_freebsd9 "$@"

View file

@ -34,7 +34,7 @@ case "$state_should" in
if [ ! -f "$__object/parameter/$boolean" ]; then
boolean="no${boolean}"
fi
upper=$(echo $boolean | tr '[a-z]' '[A-Z]')
upper=$(echo $boolean | tr '[:lower:]' '[:upper:]')
booleans="$booleans $upper"
done

View file

@ -29,7 +29,7 @@ fi
set --
if [ -f "$__object/parameter/rsync-opts" ]; then
while read opts; do
while read -r opts; do
set -- "$@" "--$opts"
done < "$__object/parameter/rsync-opts"
fi

View file

@ -78,7 +78,7 @@ if [ -s "$__object/explorer/entry" ]; then
# Note that the files have to be sorted for comparison with `comm`.
sort "$__object/explorer/entry" > "$__object/files/is"
comm -13 "$__object/files/should" "$__object/files/is" | {
while read entry; do
while read -r entry; do
remove_line "$file" "$entry"
done
}

View file

@ -61,7 +61,7 @@ _cksum() {
echo "$1" | cksum | cut -d' ' -f 1
}
while read key; do
while read -r key; do
type_and_key="$(echo "$key" | tr ' ' '\n' | awk '/^(ssh|ecdsa)-[^ ]+/ { printf $1" "; getline; printf $1 }')"
object_id="$(_cksum "$file")-$(_cksum "$type_and_key")"
set -- "$object_id"