Skip to content

Commit

Permalink
Fix frontend spelling of shouldManage (#898)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcm001 committed Aug 21, 2023
1 parent fd8f16b commit 2f2396f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
4 changes: 2 additions & 2 deletions photon-client/src/components/settings/NetworkingCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const saveGeneralSettings = () => {
The NetworkTables Server Address is not set or is invalid. NetworkTables is unable to connect.
</v-banner>
<cv-radio
v-show="useSettingsStore().network.shouldMange"
v-show="useSettingsStore().network.shouldManage"
v-model="useSettingsStore().network.connectionType"
label="IP Assignment Mode"
tooltip="DHCP will make the radio (router) automatically assign an IP address; this may result in an IP address that changes across reboots. Static IP assignment means that you pick the IP address and it won't change."
Expand All @@ -121,7 +121,7 @@ const saveGeneralSettings = () => {
:rules="[v => isValidIPv4(v) || 'Invalid IPv4 address']"
/>
<cv-input
v-show="useSettingsStore().network.shouldMange"
v-show="useSettingsStore().network.shouldManage"
v-model="useSettingsStore().network.hostname"
label="Hostname"
:input-cols="12-3"
Expand Down
2 changes: 1 addition & 1 deletion photon-client/src/types/SettingTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface NetworkSettings {
staticIp: string,
hostname: string,
runNTServer: boolean
shouldMange: boolean,
shouldManage: boolean,
networkManagerIface?: string,
physicalInterface?: string,
setStaticCommand?: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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\"";
Expand Down Expand Up @@ -88,6 +88,11 @@ public Map<String, Object> toHashMap() {
}
}

@JsonIgnore
public String getEscapedIfaceName() {
return "\"" + networkManagerIface + "\"";
}

@JsonGetter("shouldManage")
public boolean shouldManage() {
return this.shouldManage || Platform.isLinux();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void initialize(boolean shouldManage) {
// 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!");
Expand All @@ -111,25 +111,25 @@ public void initialize(boolean shouldManage) {
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()) {
// Pi's need to manually have their interface adjusted?? and the 5 second sleep is
// 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) {
Expand Down

0 comments on commit 2f2396f

Please sign in to comment.