node_ssh.go: add node hostname to offline-SSID

This commit is contained in:
Oliver Gerlich 2019-07-01 15:23:47 +02:00
parent 8751d401d3
commit 4d030892b5
1 changed files with 52 additions and 29 deletions

View File

@ -45,6 +45,7 @@ func (n *Node) SSHUpdate(sshmgmt *ssh.Manager) bool {
}
}()
// update settings for 2.4GHz (802.11g) radio
result, err := ssh.Run(n.Address, client, `
if [ "$(uci get wireless.radio0.hwmode | grep -c g)" -ne 0 ]; then
echo "radio0";
@ -56,7 +57,8 @@ func (n *Node) SSHUpdate(sshmgmt *ssh.Manager) bool {
}
radio := ssh.SSHResultToString(result)
ch := GetChannel(n.Wireless.Channel24)
if radio != "" && ch != nil {
if radio != "" {
if ch != nil {
if n.Wireless.TxPower24 != n.WirelessRespondd.TxPower24 {
ssh.Execute(n.Address, client, fmt.Sprintf(`
uci set wireless.%s.txpower='%d';
@ -75,6 +77,17 @@ func (n *Node) SSHUpdate(sshmgmt *ssh.Manager) bool {
}
}
if n.Hostname != n.HostnameRespondd {
ssh.Execute(n.Address, client, fmt.Sprintf(`
uci set wireless.priv_%s.ssid='offline-%s';
uci commit wireless;`,
n.Hostname))
runWifi = true
}
}
// update settings for 5GHz (802.11a) radio
result, err = ssh.Run(n.Address, client, `
if [ "$(uci get wireless.radio0.hwmode | grep -c a)" -ne 0 ]; then
echo "radio0";
@ -86,7 +99,8 @@ func (n *Node) SSHUpdate(sshmgmt *ssh.Manager) bool {
}
radio = ssh.SSHResultToString(result)
ch = GetChannel(n.Wireless.Channel5)
if radio != "" && ch != nil {
if radio != "" {
if ch != nil {
if n.Wireless.TxPower5 != n.WirelessRespondd.TxPower5 {
ssh.Execute(n.Address, client, fmt.Sprintf(`
uci set wireless.%s.txpower='%d';
@ -104,5 +118,14 @@ func (n *Node) SSHUpdate(sshmgmt *ssh.Manager) bool {
runWifi = true
}
}
if n.Hostname != n.HostnameRespondd {
ssh.Execute(n.Address, client, fmt.Sprintf(`
uci set wireless.priv_%s.ssid='offline-%s';
uci commit wireless;`,
n.Hostname))
runWifi = true
}
}
return true
}