3 # When the system boots, systemd-resolved seems to recreate /run/systemd/resolve,
4 # or something, because the bindmounts to that directory do not always exist
5 # for units starting up at the same time. Anyways, removing and creating that
6 # directory definitely has the effect of deleting the bindmount, so
7 # here I solve for that ever happening.
9 if ! test "$BASH_VERSION"; then echo "error: shell is not bash" >&2; exit 1; fi
10 shopt -s inherit_errexit
2>/dev
/null ||
: # ignore fail in bash < 4.4
12 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" exit status: $?, PIPESTATUS: ${PIPESTATUS[*]}" >&2' ERR
14 if (( $# == 0 )); then
15 echo error
: expected service argument
>&2
19 [[ $EUID == 0 ]] ||
exec sudo
-E "${BASH_SOURCE[0]}" "$@"
25 pid
=$
(systemctl show
--property MainPID
--value $unit 2>/dev
/null ||
:)
28 if ! nsenter
-t $pid -m timeout
20 mountpoint
/run
/systemd
/resolve
&>/dev
/null
; then
29 echo mail bind restart of
$unit
30 timeout
60 systemctl restart
$unit ||
: