[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".
|
# 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; }
|
test -x "${networkctl_bin}" || { echo error; exit 0; }
|
||||||
|
|
||||||
if test -f "${__object}/parameter/name"
|
if test -f "${__object:?}/parameter/name"
|
||||||
then
|
then
|
||||||
name=$(cat "${__object}/parameter/name")
|
name=$(cat "${__object:?}/parameter/name")
|
||||||
else
|
else
|
||||||
name=$__object_id
|
name=${__object_id:?}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if "${networkctl_bin}" --no-pager --no-legend list "${name}" >/dev/null 2>&1
|
if "${networkctl_bin}" --no-pager --no-legend list "${name}" >/dev/null 2>&1
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
CONFIG_FILE_PATH='/etc/systemd/network'
|
CONFIG_FILE_PATH='/etc/systemd/network'
|
||||||
|
|
||||||
networkctl_bin=$(cat "${__object}/explorer/networkctl_bin")
|
networkctl_bin=$(cat "${__object:?}/explorer/networkctl_bin")
|
||||||
|
|
||||||
test -n "${networkctl_bin}" || {
|
test -n "${networkctl_bin}" || {
|
||||||
printf 'This system is not supported by this type (%s).' "${__type##*/}" >&2
|
printf 'This system is not supported by this type (%s).' "${__type##*/}" >&2
|
||||||
|
@ -32,19 +32,19 @@ test -n "${networkctl_bin}" || {
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
read -r state_is
|
read -r state_is
|
||||||
read -r config_is || true
|
read -r config_is || true
|
||||||
} <"${__object}/explorer/state"
|
} <"${__object:?}/explorer/state"
|
||||||
|
|
||||||
if test -f "${__object}/parameter/name"
|
if test -f "${__object:?}/parameter/name"
|
||||||
then
|
then
|
||||||
name=$(cat "${__object}/parameter/name")
|
name=$(cat "${__object:?}/parameter/name")
|
||||||
else
|
else
|
||||||
name=$__object_id
|
name=${__object_id:?}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
priority=$(cat "${__object}/parameter/priority")
|
priority=$(cat "${__object:?}/parameter/priority")
|
||||||
state_should=$(cat "${__object}/parameter/state")
|
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"
|
if test -f "${__object:?}/parameter/auto-reload"
|
||||||
then
|
then
|
||||||
|
@ -56,18 +56,18 @@ fi
|
||||||
gen_conf() {
|
gen_conf() {
|
||||||
echo '[Match]'
|
echo '[Match]'
|
||||||
|
|
||||||
if test -s "${__object}/parameter/match"
|
if test -s "${__object:?}/parameter/match"
|
||||||
then
|
then
|
||||||
cat "${__object}/parameter/match"
|
cat "${__object:?}/parameter/match"
|
||||||
else
|
else
|
||||||
# By default match against the interface name
|
# By default match against the interface name
|
||||||
printf 'Name=%s\n' "${name}"
|
printf 'Name=%s\n' "${name}"
|
||||||
fi
|
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
|
| sort -t . -k 1
|
||||||
} | while read -r _option
|
} | while read -r _option
|
||||||
do
|
do
|
||||||
|
|
Loading…
Reference in a new issue