Fix frontend spelling of shouldManage (#898)

This commit is contained in:
Matt
2023-08-21 13:47:28 -07:00
committed by GitHub
parent fd8f16b615
commit 2f2396fe57
4 changed files with 15 additions and 10 deletions

View File

@@ -41,7 +41,7 @@ public class NetworkConfig {
@JsonIgnore public static final String NM_IFACE_STRING = "${interface}";
@JsonIgnore public static final String NM_IP_STRING = "${ipaddr}";
public String networkManagerIface = "Wired\\ connection\\ 1";
public String networkManagerIface = "Wired connection 1";
public String physicalInterface = "eth0";
public String setStaticCommand =
"nmcli con mod ${interface} ipv4.addresses ${ipaddr}/8 ipv4.method \"manual\" ipv6.method \"disabled\"";
@@ -88,6 +88,11 @@ public class NetworkConfig {
}
}
@JsonIgnore
public String getEscapedIfaceName() {
return "\"" + networkManagerIface + "\"";
}
@JsonGetter("shouldManage")
public boolean shouldManage() {
return this.shouldManage || Platform.isLinux();

View File

@@ -99,7 +99,7 @@ public class NetworkManager {
// set nmcli back to DHCP, and re-run dhclient -- this ought to grab a new IP address
shell.executeBashCommand(
config.setDHCPcommand.replace(
NetworkConfig.NM_IFACE_STRING, config.networkManagerIface));
NetworkConfig.NM_IFACE_STRING, config.getEscapedIfaceName()));
shell.executeBashCommand("dhclient " + config.physicalInterface, false);
} catch (Exception e) {
logger.error("Exception while setting DHCP!");
@@ -111,7 +111,7 @@ public class NetworkManager {
shell.executeBashCommand(
config
.setStaticCommand
.replace(NetworkConfig.NM_IFACE_STRING, config.networkManagerIface)
.replace(NetworkConfig.NM_IFACE_STRING, config.getEscapedIfaceName())
.replace(NetworkConfig.NM_IP_STRING, config.staticIp));
if (Platform.isRaspberryPi()) {
@@ -119,17 +119,17 @@ public class NetworkManager {
// integral in my testing (Matt)
shell.executeBashCommand(
"sh -c 'nmcli con down "
+ config.networkManagerIface
+ config.getEscapedIfaceName()
+ "; nmcli con up "
+ config.networkManagerIface
+ config.getEscapedIfaceName()
+ "'");
} else {
// for now just bring down /up -- more testing needed on beelink et al
shell.executeBashCommand(
"sh -c 'nmcli con down "
+ config.networkManagerIface
+ config.getEscapedIfaceName()
+ "; nmcli con up "
+ config.networkManagerIface
+ config.getEscapedIfaceName()
+ "'");
}
} catch (Exception e) {