Last Updated or created 2024-04-03
This is my short log about (re)starting booting machines.
configuration.yaml
#WOL to start a machine
- platform: wake_on_lan
name: "wakeserver"
mac: ec:be:5f:ee:11:78
#SHELL command to remote start reboot2windows script (multiboot machine)
shell_command:
ssh_reboottowindows: ssh -i /config/ssh/id_ed25519 -o 'StrictHostKeyChecking=no' root@192.168.1.2 '/root/reboot2windows'
shell_command:
ssh_haltlinux: ssh -i /config/ssh/id_ed25519 -o 'StrictHostKeyChecking=no' root@192.168.1.2 'halt -p'
reboot2windows linux script (on the remote server)
#!/bin/bash #place in /root/ #chmod +x /root/reboot2windows PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin WINDOWS_TITLE=`grep -i "^menuentry 'Windows" /boot/grub/grub.cfg|head -n 1|cut -d"'" -f2` grub-reboot "$WINDOWS_TITLE" reboot
install https://iotlink.gitlab.io/ on your windows instance
scripts.yaml (with a helper button rebootwindows2linux, shutdownwindows)
#Reboot windows, linux is the default
windows2linux:
alias: rebootwinserver
sequence:
- service: mqtt.publish
metadata: {}
data:
qos: 0
retain: false
topic: iotlink/workgroup/winserver/commands/reboot
mode: single
shutdownwindows:
alias: shutdownwinserver
sequence:
- service: mqtt.publish
metadata: {}
data:
qos: 0
retain: false
topic: iotlink/workgroup/winserver/commands/shutdown
mode: single
automation rebootlinux2windows
(using a helper button rebootlinux2windows)
alias: rebootlinux2windows
description: ""
trigger:
- platform: state
entity_id:
- input_button.rebootlinux2windows
condition: []
action:
- service: shell_command.ssh_reboottowindows
data: {}
mode: single
Configuring ssh keys
Open HA terminal
cd ssh-keygen (enter) (enter) (enter) (enter) mkdir -p config/ssh cp ~/.ssh/id* config/ssh/