Skip to content
Snippets Groups Projects
Commit 543accab authored by Jouke Witteveen's avatar Jouke Witteveen
Browse files

Bring connections into a uniform code style

Also, make sure that netctl does not wait for the interface of a wireguard
connection, since that interface will be created by netctl itself.
parent 8e5d89ad
No related branches found
No related tags found
No related merge requests found
......@@ -11,7 +11,7 @@ bond_up() {
return 1
fi
interface_add bond "$Interface" "$MACAddress" "" ${Mode:+mode "$Mode"}
interface_add bond "$Interface" "$MACAddress" "" ${Mode:+mode "$Mode"} || return
bring_interface_up "$Interface"
for slave in "${BindsToInterfaces[@]}"; do
ip link set dev "$slave" master "$Interface"
......
......@@ -15,7 +15,7 @@ bridge_up() {
report_error "Setting a MAC address on existing bridge interface '$Interface' is unsupported"
fi
else
interface_add bridge "$Interface" "$MACAddress"
interface_add bridge "$Interface" "$MACAddress" || return
fi
for member in "${BindsToInterfaces[@]}"; do
......
......@@ -11,7 +11,7 @@ dummy_up() {
return 1
fi
interface_add dummy "$Interface" "$MACAddress"
interface_add dummy "$Interface" "$MACAddress" || return
bring_interface_up "$Interface"
ip_set
}
......
......@@ -6,8 +6,7 @@ macvlan_up() {
if [[ ${#BindsToInterfaces[@]} -ne 1 ]]; then
report_error "No unique physical device for MACVLAN interface '$Interface' specified"
return 1
fi
if is_interface "$Interface"; then
elif is_interface "$Interface"; then
report_error "Interface '$Interface' already exists"
return 1
elif [[ $Mode != @(bridge|passthru|private|vepa) ]]; then
......@@ -15,7 +14,7 @@ macvlan_up() {
return 1
else
bring_interface_up "$BindsToInterfaces"
interface_add macvlan "$Interface" "$MACAddress" "$BindsToInterfaces" mode "$Mode" || return 1
interface_add macvlan "$Interface" "$MACAddress" "$BindsToInterfaces" mode "$Mode" || return
fi
ethernet_up
}
......@@ -25,4 +24,5 @@ macvlan_down() {
interface_delete "$Interface"
}
# vim: ft=sh ts=4 et sw=4:
......@@ -26,3 +26,6 @@ ppp_down() {
Interface=$interface pppoe_down
}
# vim: ft=sh ts=4 et sw=4:
......@@ -7,6 +7,7 @@ BindsToInterfaces=("${BindsToInterfaces[@]}")
tunnel_up() {
local family="-4"
if is_interface "$Interface"; then
report_error "Interface '$Interface' already exists"
return 1
......
......@@ -6,8 +6,7 @@ vlan_up() {
if [[ ${#BindsToInterfaces[@]} -ne 1 ]]; then
report_error "No unique physical device for VLAN interface '$Interface' specified"
return 1
fi
if is_interface "$Interface"; then
elif is_interface "$Interface"; then
report_error "Interface '$Interface' already exists"
return 1
elif [[ $VLANID != +([[:digit:]]) ]]; then
......@@ -15,7 +14,7 @@ vlan_up() {
return 1
else
bring_interface_up "$BindsToInterfaces"
interface_add vlan "$Interface" "$MACAddress" "$BindsToInterfaces" id "$VLANID"
interface_add vlan "$Interface" "$MACAddress" "$BindsToInterfaces" id "$VLANID" || return
fi
ethernet_up
......
......@@ -2,17 +2,17 @@
. "$SUBR_DIR/ip"
# Make sure BindsToInterfaces is set
BindsToInterfaces=("${BindsToInterfaces[@]}")
wireguard_up() {
if is_interface "$Interface"; then
report_error "Interface '$Interface' already exists"
return 1
fi
if ! interface_add wireguard "$Interface" "$MACAddress"; then
report_error "Your kernel may not support WireGuard."
return 1
fi
# Treat $MACAddress as in other connections, but it has no effect here
interface_add wireguard "$Interface" "$MACAddress" || return
wg setconf "$Interface" "${WGConfigFile:-/etc/wireguard/$Interface.conf}"
bring_interface_up "$Interface"
ip_set
......@@ -23,4 +23,5 @@ wireguard_down() {
interface_delete "$Interface"
}
# vim: ft=sh ts=4 et sw=4:
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment