Merge pull request #424 from darko-poljak/fix-bashisms

Fix bashisms
This commit is contained in:
Nico Schottelius 2016-03-31 12:41:48 +02:00
commit 7fe4e20f53
14 changed files with 30 additions and 17 deletions

View file

@ -1,3 +1,4 @@
#!/bin/sh
# #
# 2015 Nico Schottelius (nico-cdist at schottelius.org) # 2015 Nico Schottelius (nico-cdist at schottelius.org)
# #

View file

@ -1,3 +1,4 @@
#!/bin/sh
# #
# 2015 Nico Schottelius (nico-cdist at schottelius.org) # 2015 Nico Schottelius (nico-cdist at schottelius.org)
# #

View file

@ -1,3 +1,5 @@
#!/bin/sh
if grep -q "^__file/etc/iptables.d/" "$__messages_in"; then if grep -q "^__file/etc/iptables.d/" "$__messages_in"; then
echo /etc/init.d/iptables restart echo /etc/init.d/iptables restart
fi fi

View file

@ -1,3 +1,4 @@
#!/bin/sh
# #
# 2013 Nico Schottelius (nico-cdist at schottelius.org) # 2013 Nico Schottelius (nico-cdist at schottelius.org)
# #

View file

@ -1,3 +1,4 @@
#!/bin/sh
# #
# 2013 Nico Schottelius (nico-cdist at schottelius.org) # 2013 Nico Schottelius (nico-cdist at schottelius.org)
# #

View file

@ -1,3 +1,5 @@
#!/bin/sh
export key="$(cat "$__object/parameter/key" 2>/dev/null \ export key="$(cat "$__object/parameter/key" 2>/dev/null \
|| echo "$__object_id")" || echo "$__object_id")"
export state="$(cat "$__object/parameter/state")" export state="$(cat "$__object/parameter/state")"

View file

@ -1,3 +1,5 @@
#!/bin/sh
#
# 2013 Nico Schottelius (nico-cdist at schottelius.org) # 2013 Nico Schottelius (nico-cdist at schottelius.org)
# #
# This file is part of cdist. # This file is part of cdist.

View file

@ -42,7 +42,7 @@ case "$ptype" in
zypper search --match-exact --installed-only --type "$ptype" "$name" | grep -E '^i' | cut -d " " -f 3 || true zypper search --match-exact --installed-only --type "$ptype" "$name" | grep -E '^i' | cut -d " " -f 3 || true
;; ;;
*) *)
echo "unknown ptype in __package_zypper explorer" &>2 echo "unknown ptype in __package_zypper explorer" >&2
exit 1 exit 1
;; ;;
esac esac

View file

@ -42,11 +42,10 @@ contains_element() {
MATCH=0 MATCH=0
target=$1 target=$1
keys="${@:2}" shift
for key in "$@"; do
for key in ${keys}; do if [ "${key}" = "${target}" ]; then
if [ "${key}" == "${target}" ]; then
MATCH=1 MATCH=1
return 0 return 0
fi fi
@ -58,14 +57,14 @@ if [ "${file}" ]; then
__file "${sec_path}/plain_file_${file}"\ __file "${sec_path}/plain_file_${file}"\
--state exists --mode 666 --state exists --mode 666
if [ "${state}" == "present" ]; then if [ "${state}" = "present" ]; then
require="__file/${sec_path}/plain_file_${file}" __key_value ${file}_${key}\ require="__file/${sec_path}/plain_file_${file}" __key_value ${file}_${key}\
--file ${sec_path}/plain_file_${file} --key ${key} --value ${value} --delimiter ' = ' --file ${sec_path}/plain_file_${file} --key ${key} --value ${value} --delimiter ' = '
exit 0 exit 0
elif [ "${state}" == "absent" ]; then elif [ "${state}" = "absent" ]; then
require="__file/${sec_path}/plain_file_${file}" __key_value ${file}_${key}\ require="__file/${sec_path}/plain_file_${file}" __key_value ${file}_${key}\
--state absent --state absent
exit 0 exit 0
@ -76,7 +75,7 @@ if [ "${file}" ]; then
fi fi
fi fi
if [ "${section}" == "options" ]; then if [ "${section}" = "options" ]; then
__file "${sec_path}/${section}"\ __file "${sec_path}/${section}"\
--state exists --mode 666 --source - << eof --state exists --mode 666 --source - << eof
@ -87,10 +86,10 @@ eof
contains_element "${key}" "${boolean_option_keys}" contains_element "${key}" "${boolean_option_keys}"
if [ "${MATCH}" -eq 1 ]; then if [ "${MATCH}" -eq 1 ]; then
if [ "${value}" == "on" ]; then if [ "${value}" = "on" ]; then
require="__file/${sec_path}/${section}" __line ${key}_${value}\ require="__file/${sec_path}/${section}" __line ${key}_${value}\
--file ${sec_path}/${section} --line ${key} --file ${sec_path}/${section} --line ${key}
elif [ "${value}" == "off" ]; then elif [ "${value}" = "off" ]; then
require="__file/${sec_path}/${section}" __line ${key}_${value}\ require="__file/${sec_path}/${section}" __line ${key}_${value}\
--file ${sec_path}/${section} --line ${key} --state absent --file ${sec_path}/${section} --line ${key} --state absent
fi fi
@ -111,7 +110,7 @@ else
--state exists --mode 666 --source - << eof --state exists --mode 666 --source - << eof
[${section}] [${section}]
eof eof
if [ "${state}" == "present" ]; then if [ "${state}" = "present" ]; then
#check if key is valid #check if key is valid
contains_element "${key}" "${allowed_repo_keys}" contains_element "${key}" "${allowed_repo_keys}"
@ -122,7 +121,7 @@ eof
require="__file/${sec_path}/repo_${section}" __key_value ${section}_${key}\ require="__file/${sec_path}/repo_${section}" __key_value ${section}_${key}\
--file ${sec_path}/repo_${section} --key ${key} --value ${value} --delimiter ' = ' --file ${sec_path}/repo_${section} --key ${key} --value ${value} --delimiter ' = '
elif [ "${state}" == "absent" ]; then elif [ "${state}" = "absent" ]; then
require="__file/${sec_path}/repo_${section}" __key_value ${section}_${key}\ require="__file/${sec_path}/repo_${section}" __key_value ${section}_${key}\
--state absent --state absent

View file

@ -22,7 +22,7 @@ state=$(cat $__object/parameter/state 2>/dev/null)
path="/etc/" path="/etc/"
if [ "${state}" == "present" ]; then if [ "${state}" = "present" ]; then
__file /etc/pacman.conf\ __file /etc/pacman.conf\
--owner root --group root --mode 644 --source $__type/files/pacman.conf.cdist --owner root --group root --mode 644 --source $__type/files/pacman.conf.cdist
@ -35,7 +35,7 @@ if [ "${state}" == "present" ]; then
__file /etc/pacman.d/plain_file_empty_placeholder\ __file /etc/pacman.d/plain_file_empty_placeholder\
--owner root --group root --mode 644 --owner root --group root --mode 644
elif [ "${state}" == "absent" ]; then elif [ "${state}" = "absent" ]; then
__file /etc/pacman.conf\ __file /etc/pacman.conf\
--owner root --group root --mode 644 --source $__type/files/pacman.conf.pacman --owner root --group root --mode 644 --source $__type/files/pacman.conf.pacman

View file

@ -1,3 +1,5 @@
#!/bin/sh
#
################################################################################ ################################################################################
# State: absent is handled by manifest - we need only to do stuff if image is # State: absent is handled by manifest - we need only to do stuff if image is
# not existing and state != absent # not existing and state != absent

View file

@ -1,3 +1,5 @@
#!/bin/sh
#
################################################################################ ################################################################################
# Default settings # Default settings
# #

View file

@ -28,7 +28,7 @@ init=$("$__explorer/init")
target_runlevel="$(cat "$__object/parameter/target_runlevel")" target_runlevel="$(cat "$__object/parameter/target_runlevel")"
name="$__object_id" name="$__object_id"
if [ "$init" == 'systemd' ]; then if [ "$init" = 'systemd' ]; then
# this handles ALL linux distros with systemd # this handles ALL linux distros with systemd
# e.g. archlinux, gentoo, new RHEL and SLES versions # e.g. archlinux, gentoo, new RHEL and SLES versions
state=$(systemctl is-enabled "$name" >/dev/null 2>&1 \ state=$(systemctl is-enabled "$name" >/dev/null 2>&1 \

View file

@ -34,7 +34,7 @@ name="$__object_id"
case "$state_should" in case "$state_should" in
present) present)
if [ "$init" == 'systemd' ]; then if [ "$init" = 'systemd' ]; then
# this handles ALL linux distros with systemd # this handles ALL linux distros with systemd
# e.g. archlinux, gentoo in some cases, new RHEL and SLES versions # e.g. archlinux, gentoo in some cases, new RHEL and SLES versions
echo "systemctl -q enable \"$name\"" echo "systemctl -q enable \"$name\""
@ -85,7 +85,7 @@ case "$state_should" in
;; ;;
absent) absent)
if [ "$init" == 'systemd' ]; then if [ "$init" = 'systemd' ]; then
# this handles ALL linux distros with systemd # this handles ALL linux distros with systemd
# e.g. archlinux, gentoo in some cases, new RHEL and SLES versions # e.g. archlinux, gentoo in some cases, new RHEL and SLES versions
echo "systemctl -q disable \"$name\"" echo "systemctl -q disable \"$name\""