diff --git a/mycroft/client/enclosure/__init__.py b/mycroft/client/enclosure/__init__.py index 6a3f62bcfb..1bb1c0fa3a 100644 --- a/mycroft/client/enclosure/__init__.py +++ b/mycroft/client/enclosure/__init__.py @@ -131,8 +131,6 @@ class EnclosureReader(Thread): self.ws.emit(Message("mycroft.wifi.start")) if "unit.factory-reset" in data: - self.ws.emit( - Message("enclosure.eyes.spin")) subprocess.call( 'rm ~/.mycroft/identity/identity2.json', shell=True) @@ -144,9 +142,12 @@ class EnclosureReader(Thread): subprocess.call('systemctl reboot -i', shell=True) if "unit.enable-ssh" in data: - subprocess.call('sudo touch /boot/ssh', shell=True) + #this is handled by the wifi client + self.ws.emit(Message("mycroft.enable.ssh")) self.ws.emit(Message("speak", { 'utterance': "SSH will be enabled on next boot"})) + time.sleep(4) + subprocess.call('systemctl reboot -i', shell=True) def stop(self): self.alive = False diff --git a/mycroft/client/wifisetup/main.py b/mycroft/client/wifisetup/main.py index 8060986079..8494130da1 100644 --- a/mycroft/client/wifisetup/main.py +++ b/mycroft/client/wifisetup/main.py @@ -268,6 +268,9 @@ class WiFi: # This event is similar to the above, but resets the wifi self.ws.on('mycroft.wifi.reset', self.reset) + # an event to enable SSH + self.ws.on('enclosure.enable.ssh', self.ssh) + # These events are generated by Javascript in the captive # portal. self.ws.on('mycroft.wifi.stop', self.stop) @@ -560,6 +563,13 @@ class WiFi: except Exception as e: LOG.error("Error: {0}".format(e)) + def ssh(self, event=None): + LOG.info("Enabling SSH") + try: + call('sudo touch /boot/ssh', shell=True) + except Exception as e: + LOG.error("Error: {0}".format(e)) + def main(): wifi = WiFi()