diff --git a/.github/wiki/script-auto-config-linux.sh b/.github/wiki/script-auto-config-linux.sh new file mode 100644 index 0000000..fa9879e --- /dev/null +++ b/.github/wiki/script-auto-config-linux.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Enable SSH Server +if command -v systemctl &> /dev/null; then + sudo systemctl enable --now sshd +else + echo "Systemctl not found. Please enable SSH manually." +fi + +# Configure sudoers +echo "Configuring sudoers..." +echo -e "\n# Allow your user to execute specific commands without a password" | sudo tee -a /etc/sudoers +echo "$(whoami) ALL=(ALL) NOPASSWD: /sbin/shutdown, /sbin/init, /usr/bin/systemctl, /usr/sbin/pm-suspend, /usr/bin/awk, /usr/sbin/grub-reboot, /usr/sbin/grub2-reboot" | sudo tee -a /etc/sudoers + +# Firewall Configuration +if command -v ufw &> /dev/null; then + echo "Configuring firewall..." + sudo ufw allow 22 +else + echo "UFW not found. Please configure the firewall manually." +fi + +echo "You can now add your computer to HomeAssistant." diff --git a/.github/wiki/script-auto-config-windows.ps1 b/.github/wiki/script-auto-config-windows.ps1 new file mode 100644 index 0000000..afb163f --- /dev/null +++ b/.github/wiki/script-auto-config-windows.ps1 @@ -0,0 +1,30 @@ +# Install OpenSSH Components +Write-Host "Installing OpenSSH Components..." + +# Check if OpenSSH is installed +$opensshInstalled = Get-WindowsOptionalFeature -Online | Where-Object FeatureName -eq "OpenSSH.Client" +$opensshServerInstalled = Get-WindowsOptionalFeature -Online | Where-Object FeatureName -eq "OpenSSH.Server" + +# Install OpenSSH Client and Server if not installed +if (!$opensshInstalled) { + Write-Host "Installing OpenSSH Client..." + Add-WindowsCapability -Online -Name OpenSSH.Client +} + +if (!$opensshServerInstalled) { + Write-Host "Installing OpenSSH Server..." + Add-WindowsCapability -Online -Name OpenSSH.Server +} + +# Start and set OpenSSH Server to Automatic +Write-Host "Configuring OpenSSH Server..." +Set-Service -Name sshd -StartupType Automatic +Start-Service sshd + +# Confirm the Firewall rule is configured. It should be created automatically by setup. Run the following to verify +if (!(Get-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -ErrorAction SilentlyContinue | Select-Object Name, Enabled)) { + Write-Output "Firewall Rule 'OpenSSH-Server-In-TCP' does not exist, creating it..." + New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 +} else { + Write-Output "Firewall rule 'OpenSSH-Server-In-TCP' has been created and exists." +} \ No newline at end of file diff --git a/.images/example1.png b/.images/example1.png index ef2c5c5..692ca82 100644 Binary files a/.images/example1.png and b/.images/example1.png differ diff --git a/HOWTO.md b/HOWTO.md deleted file mode 100644 index 555d932..0000000 --- a/HOWTO.md +++ /dev/null @@ -1,148 +0,0 @@ -# Quick documentation - -## `send_magic_packet` - -### Description - -Send a 'magic packet' to wake up a device with 'Wake-On-LAN' capabilities. - -### Fields - -- `mac` - - **Name:** MAC address - - **Description:** MAC address of the device to wake up. - - **Required:** true - - **Example:** "aa:bb:cc:dd:ee:ff" - - **Input:** text - -- `broadcast_address` - - **Name:** Broadcast address - - **Description:** Broadcast IP where to send the magic packet. - - **Example:** 192.168.255.255 - - **Input:** text - -- `broadcast_port` - - **Name:** Broadcast port - - **Description:** Port where to send the magic packet. - - **Default:** 9 - - **Input:** number - - **Min:** 1 - - **Max:** 65535 - -## `restart_to_windows_from_linux` - -### Description - -Restart the computer to Windows when running Linux using Grub. - -### Target - -- **Device Integration:** easy_computer_manage - -## `restart_to_linux_from_windows` - -### Description - -Restart the computer to Linux when running Windows. - -### Target - -- **Device Integration:** easy_computer_manage - -## `start_computer_to_windows` - -### Description - -Start the computer directly to Windows (boots to Linux, set grub reboot, then boots to Windows). - -### Target - -- **Device Integration:** easy_computer_manage - -## `put_computer_to_sleep` - -### Description - -Put the computer to sleep. - -### Target - -- **Device Integration:** easy_computer_manage - -## `restart_computer` - -### Description - -Restart the computer. - -### Target - -- **Device Integration:** easy_computer_manage - -## `change_monitors_config` - -### Description - -Change monitors config. - -### Target - -- **Device Integration:** easy_computer_manage - -### Fields - -- `monitors_config` - - **Name:** Monitors config - - **Description:** Monitors config. - - **Required:** true - - **Selector:** object (yaml) - - **Example:** - ```yaml - # Tip: You can use the command `gnome-monitor-config list` or `xrandr` to your monitors names and resolutions. - HDMI-1: - enabled: true - primary: true - position: [ 0, 0 ] - mode: 3840x2160@120.000 - transform: normal - scale: 2 - ``` - - - **Example for Node-RED(JSON):** - ```json - // Example of the data expression of a service call node in Node-RED. - { - "monitors_config": { - "HDMI-1": { - "enabled": true, - "primary": true, - "position": [0, 0], - "mode": "3840x2160@120.000", - "transform": "normal", - "scale": 2 - } - } - } - ``` - -## `steam_big_picture` - -### Description - -Start/stop Steam in Big Picture mode or go back to Steam desktop UI. - -### Target - -- **Device Integration:** easy_computer_manage - -### Fields - -- `action` - - **Name:** Action - - **Description:** Action to perform. - - **Required:** true - - **Selector:** select - - **Options:** - - **start**: Start Steam in Big Picture mode. - - **stop**: Stop Steam in Big Picture mode. - - **exit**: Go back to Steam desktop UI. \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index 5f59400..0000000 --- a/README.md +++ /dev/null @@ -1,69 +0,0 @@ -# 🖧 Easy Computer Manager - -[![hacs_badge](https://img.shields.io/badge/HACS-Custom-41BDF5.svg?style=for-the-badge)](https://github.com/hacs/integration) - -![img.png](.images/example1.png) - -## 🐧 Configure Linux-running computer to be managed by Home Assistant. - -### Enable the SSH server - -Make sure to have a working SSH-server on your computer. I have only tested this integration with OpenSSH but YMMV. - -On most system it can be enabled with the following commands : - -```bash -sudo systemctl enable --now sshd -``` - -### Configure sudoers - -We need to allow your user account to run specific sudo command without asking for the password so HomeAssistant can run -them. -To do this, we need to edit sudoers file, run the following command ``visudo`` in a terminal and append the following -the to end of the file : - -``` -# Allow your user user to execute shutdown, init, systemctl, pm-suspend, awk, grub-reboot, and grub2-reboot without a password -username ALL=(ALL) NOPASSWD: /sbin/shutdown, /sbin/init, /usr/bin/systemctl, /usr/sbin/pm-suspend, /usr/bin/awk, /usr/sbin/grub-reboot, /usr/sbin/grub2-reboot -``` - -*Note : It might be necessary to allow port 22 (ssh) in your firewall.* - -**⚠️ Be sure to replace username with your username.** - -## 🪟 Configure Windows-running computer to be managed by Home Assistant. - -To install the OpenSSH components: - -1. Open Settings, select Apps, then select Optional Features. -2. Scan the list to see if the OpenSSH is already installed. If not, at the top of the page, select Add a feature, - then: - Find OpenSSH Client, then select Install (optional) - Find OpenSSH Server, then select Install -3. Once setup completes, return to Apps and Optional Features and confirm OpenSSH is listed. -4. Open the Services desktop app. (Select Start, type services.msc in the search box, and then select the Service app or - press ENTER.) -5. In the details pane, double-click OpenSSH SSH Server. -6. On the General tab, from the Startup type drop-down menu, select Automatic. -7. To start the service, select Start. - -*Instructions -from [Microsoft](https://learn.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse)* - -*Note : It might be necessary to allow port 22 (ssh) in the Windows firewall altough it should be done automatically if -following the instructions from above.* - -## 🖧 Configure dual-boot (Windows/Linux) computer to be managed by Home Assistant. - -To configure dual-boot computer, you need to configure both Windows and Linux, for this look at the 2 sections above. -You will need to have the same username and password on both Windows and Linux. - -*Note : Be sure to enable the checkbox "Dual boot system" when adding your PC to home assistant.* - -## 🔑 Why not use SSH keys? - -Well, simply because it would require the user to do some extra steps. Using the password, it's almost plug and play but -compromise the security a bit. -_In the future, the option to use SSH keys might be added depending on user feedback._ -