networkctl: introduce verb mask and unmask
Suggested in https://github.com/systemd/systemd/pull/29928#discussion_r1386626565
This commit is contained in:
@@ -28,6 +28,16 @@ Name=test
|
||||
EOF
|
||||
|
||||
# Test files
|
||||
|
||||
networkctl mask --runtime "donotexist.network"
|
||||
assert_eq "$(readlink /run/systemd/network/donotexist.network)" "/dev/null"
|
||||
networkctl unmask "donotexist.network" # unmask should work even without --runtime
|
||||
[[ ! -e /run/systemd/network/donotexist.network ]]
|
||||
|
||||
touch /usr/lib/systemd/network/donotexist.network
|
||||
(! networkctl unmask "donotexist.network")
|
||||
rm /usr/lib/systemd/network/donotexist.network
|
||||
|
||||
networkctl cat "$NETWORK_NAME" | tail -n +2 | cmp - "/usr/lib/systemd/network/$NETWORK_NAME"
|
||||
|
||||
cat >new <<EOF
|
||||
@@ -36,11 +46,20 @@ Name=test2
|
||||
EOF
|
||||
|
||||
EDITOR='mv new' script -ec 'networkctl edit --runtime "$NETWORK_NAME"' /dev/null
|
||||
(! networkctl mask --runtime "$NETWORK_NAME")
|
||||
printf '%s\n' '[Match]' 'Name=test2' | cmp - "/run/systemd/network/$NETWORK_NAME"
|
||||
|
||||
networkctl mask "$NETWORK_NAME"
|
||||
assert_eq "$(readlink "/etc/systemd/network/$NETWORK_NAME")" "/dev/null"
|
||||
(! networkctl edit "$NETWORK_NAME")
|
||||
(! networkctl edit --runtime "$NETWORK_NAME")
|
||||
(! networkctl cat "$NETWORK_NAME")
|
||||
networkctl unmask "$NETWORK_NAME"
|
||||
|
||||
EDITOR='true' script -ec 'networkctl edit "$NETWORK_NAME"' /dev/null
|
||||
printf '%s\n' '[Match]' 'Name=test2' | cmp - "/etc/systemd/network/$NETWORK_NAME"
|
||||
|
||||
(! networkctl mask "$NETWORK_NAME")
|
||||
(! EDITOR='true' script -ec 'networkctl edit --runtime "$NETWORK_NAME"' /dev/null)
|
||||
|
||||
cat >"+4" <<EOF
|
||||
|
||||
Reference in New Issue
Block a user