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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -25,7 +25,9 @@ mkdir "$__object/files"
# get current UUID's from target_host # get current UUID's from target_host
$__remote_exec "$__target_host" blkid > "$__object/files/blkid" $__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")" device="$(cat "$object/parameter/device")"
dir="$(cat "$object/parameter/dir")" dir="$(cat "$object/parameter/dir")"
type="$(cat "$object/parameter/type")" type="$(cat "$object/parameter/type")"

View file

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

View file

@ -20,7 +20,9 @@
get_type_from_mkfs() { get_type_from_mkfs() {
_device="$1" _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")" mkfs_device="$(cat "$mkfs_object/parameter/device")"
if [ "$_device" = "$mkfs_device" ]; then if [ "$_device" = "$mkfs_device" ]; then
cat "$mkfs_object/parameter/type" cat "$mkfs_object/parameter/type"

View file

@ -59,7 +59,9 @@ size_to_mb() {
get_objects() { get_objects() {
objects_file=$(mktemp) 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_device="$(cat "$object/parameter/device")"
object_minor="$(cat "$object/parameter/minor")" object_minor="$(cat "$object/parameter/minor")"
echo "$object_device $object_minor $object" >> "$objects_file" echo "$object_device $object_minor $object" >> "$objects_file"

View file

@ -19,5 +19,6 @@
# #
# set defaults # set defaults
options="$(cat "$__object/parameter/options" 2>/dev/null \ # options="$(cat "$__object/parameter/options" 2>/dev/null \
|| echo "" | tee "$__object/parameter/options")" # || 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 # set defaults
target="$(cat "$__object/parameter/target" 2>/dev/null \ # target="$(cat "$__object/parameter/target" 2>/dev/null \
|| echo "/target" | tee "$__object/parameter/target")" # || 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 done
ver="$(cat "$__global/explorer/os_version")" 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 "$@" __jail_freebsd10 "$@"
else else
__jail_freebsd9 "$@" __jail_freebsd9 "$@"

View file

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

View file

@ -29,7 +29,7 @@ fi
set -- set --
if [ -f "$__object/parameter/rsync-opts" ]; then if [ -f "$__object/parameter/rsync-opts" ]; then
while read opts; do while read -r opts; do
set -- "$@" "--$opts" set -- "$@" "--$opts"
done < "$__object/parameter/rsync-opts" done < "$__object/parameter/rsync-opts"
fi 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`. # Note that the files have to be sorted for comparison with `comm`.
sort "$__object/explorer/entry" > "$__object/files/is" sort "$__object/explorer/entry" > "$__object/files/is"
comm -13 "$__object/files/should" "$__object/files/is" | { comm -13 "$__object/files/should" "$__object/files/is" | {
while read entry; do while read -r entry; do
remove_line "$file" "$entry" remove_line "$file" "$entry"
done done
} }

View file

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