[type/__systemd_networkd_network] Error if expected environment variables are not set
This commit is contained in:
parent
34d62aed95
commit
71f5fbad14
2 changed files with 16 additions and 16 deletions
|
@ -25,15 +25,15 @@
|
|||
# In case networkctl cannot be found, the output will be "error".
|
||||
#
|
||||
|
||||
networkctl_bin=$("${__type_explorer}/networkctl_bin")
|
||||
networkctl_bin=$("${__type_explorer:?}/networkctl_bin")
|
||||
|
||||
test -x "${networkctl_bin}" || { echo error; exit 0; }
|
||||
|
||||
if test -f "${__object}/parameter/name"
|
||||
if test -f "${__object:?}/parameter/name"
|
||||
then
|
||||
name=$(cat "${__object}/parameter/name")
|
||||
name=$(cat "${__object:?}/parameter/name")
|
||||
else
|
||||
name=$__object_id
|
||||
name=${__object_id:?}
|
||||
fi
|
||||
|
||||
if "${networkctl_bin}" --no-pager --no-legend list "${name}" >/dev/null 2>&1
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
CONFIG_FILE_PATH='/etc/systemd/network'
|
||||
|
||||
networkctl_bin=$(cat "${__object}/explorer/networkctl_bin")
|
||||
networkctl_bin=$(cat "${__object:?}/explorer/networkctl_bin")
|
||||
|
||||
test -n "${networkctl_bin}" || {
|
||||
printf 'This system is not supported by this type (%s).' "${__type##*/}" >&2
|
||||
|
@ -32,19 +32,19 @@ test -n "${networkctl_bin}" || {
|
|||
# shellcheck disable=SC2034
|
||||
read -r state_is
|
||||
read -r config_is || true
|
||||
} <"${__object}/explorer/state"
|
||||
} <"${__object:?}/explorer/state"
|
||||
|
||||
if test -f "${__object}/parameter/name"
|
||||
if test -f "${__object:?}/parameter/name"
|
||||
then
|
||||
name=$(cat "${__object}/parameter/name")
|
||||
name=$(cat "${__object:?}/parameter/name")
|
||||
else
|
||||
name=$__object_id
|
||||
name=${__object_id:?}
|
||||
fi
|
||||
|
||||
priority=$(cat "${__object}/parameter/priority")
|
||||
state_should=$(cat "${__object}/parameter/state")
|
||||
priority=$(cat "${__object:?}/parameter/priority")
|
||||
state_should=$(cat "${__object:?}/parameter/state")
|
||||
|
||||
config_file=$(printf '%s/%02u-%s.network' "${CONFIG_FILE_PATH}" "${priority}" "${__object_id}")
|
||||
config_file=$(printf '%s/%02u-%s.network' "${CONFIG_FILE_PATH}" "${priority}" "${__object_id:?}")
|
||||
|
||||
if test -f "${__object:?}/parameter/auto-reload"
|
||||
then
|
||||
|
@ -56,18 +56,18 @@ fi
|
|||
gen_conf() {
|
||||
echo '[Match]'
|
||||
|
||||
if test -s "${__object}/parameter/match"
|
||||
if test -s "${__object:?}/parameter/match"
|
||||
then
|
||||
cat "${__object}/parameter/match"
|
||||
cat "${__object:?}/parameter/match"
|
||||
else
|
||||
# By default match against the interface name
|
||||
printf 'Name=%s\n' "${name}"
|
||||
fi
|
||||
|
||||
{
|
||||
grep -e '^Network\.' "${__object}/parameter/option"
|
||||
grep -e '^Network\.' "${__object:?}/parameter/option"
|
||||
|
||||
grep -v -e '^\(Match\|Network\)\.' "${__object}/parameter/option" \
|
||||
grep -v -e '^\(Match\|Network\)\.' "${__object:?}/parameter/option" \
|
||||
| sort -t . -k 1
|
||||
} | while read -r _option
|
||||
do
|
||||
|
|
Loading…
Reference in a new issue