# DIY IP KVM System with WEB-interface using Raspberry Pi
Stand-alone IP KVM device with web interface with various video capture options and bunch of features like keyboard/mouse control, ATX control (power/reset/ HDD load), Mass-Storage Device.
- HDMI to S-Video (not all options work, but these two have been tested) (https://www.amazon.com/dp/B012MDMWLM or https://www.amazon.com/gp/product/B01E56CV42)
On the Pi3, flash http://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2017-09-08/. As of this writing you may use the latest Stretch version, however this was the version used successfully.
On the Pi0, flash http://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2017-03-03/. You must use this version for this to work. There aren't really security implications since the Pi0 can only be accessed from a serial session on the Pi3.
Before putting the SD into the Pi0, add this to the end of /boot/config.txt:
```
dtoverlay=dwc2
enable_uart=1
```
Before putting the SD into the Pi3, create a blank file called `SSH` on the boot drive to enable SSH.
Also, if you will be connecting via Wifi, create a file in boot called `wpa_supplicant.conf` that uses unix based line feeds. To ensure that is the case, use `Notepad++` or another editor that allows you to change line feed types (bottom right), or copy the `config.txt` file and rename it. Include the following:
View the [high resolution version](https://raw.githubusercontent.com/Fmstrat/diy-ipmi/master/Resources/Diagram.png)
The detailed process is to:
- Connect the Pi3 to the relay board using this method: http://youtu.be/oaf_zQcrg7g
- Connect the Pi0 to the Pi3 using this method: https://www.thepolyglotdeveloper.com/2017/02/connect-raspberry-pi-pi-zero-usb-ttl-serial-cable/. You do not need to supply power to the Pi0, it will get power via the GPIO pins.
- Plug the easycap device and the USB TTL device into the USB ports on the Pi3
- Connect the HDMI out of your computer into the HDMI to S-Video box, and connect it to the EasyCap device via an S-Video cable
- Connect the Pi0 to the server via a microUSB to USB male cable
## Quick Install
The quick method of installation is to simply run the install script on the Pi3 as the `pi` user:
Everything will be done on the Pi3 and Pi0 automatically with the video input defaulting to s-video.
If you would like to manage multiple servers with one IPMI system, please see the [Managing multiple servers](#managing-multiple-servers) section below.
Be sure to check the bottom of this README for [Tips](#tips) and [Troubleshooting](#troubleshooting)!
## The long way
If you would like to do things step by step to understand how things work, the following instructions can be used.
To test the ability to reboot the computer via the relay board, run:
```
/opt/diy-ipmi/Pi3/rebootServer.py
```
Test this script to see if it resets the computer. If you are interested, look in the python script to see the numbers associated with which of the 8 relays you could use for multiple computers.
Next, set up the HTTP server.
```
read -s -p "Password for web IPMI console (user 'ipmi'): " IPMIPASS
echo ""
echo "ipmi:${IPMIPASS}" | sudo tee --append /var/www/ipmipasswd
sudo lighty-enable-mod fastcgi-php
echo '' | sudo tee --append /etc/lighttpd/lighttpd.conf
You should now be able to access the IPMI console at `http://<RaspberryPi3IP>/`. From here you can set up SSL and port forwarding to the device as your situation requires.
## Managing multiple servers
Multiple servers can be managed by using multile USB capture devices (one per server), multiple USB-to-Serial adapters each with their own Pi0 (one per server), and using one of the 8 relays on the relay board as the reset button. Once installed, edit `/etc/ipmi.conf`. The format should be:
```
[My first server]
TTY=/dev/ttyUSB0
VID=/dev/video0
INP=1
PIN=2
[My second server]
TTY=/dev/ttyUSB1
VID=/dev/video1
INP=1
PIN=3
```
- When hooking up multiple TV tuners and USB-to-Serial devices to Pi0s, it is recommended to use a powered USB hub.
- The `INP` field is `1` for s-video or `0` for composite. You can actually use one capture device for two servers by using both inputs.
- The `PIN` value is the pin on the relay board. The valid values are `2`, `3`, `4`, `17`, `27`, `22`, `10`, `9`.
## Tips
If you're using this on a Linux headless machine that's not running X11, it's easier to read the console if things are nice and big. Disabling the video driver is an easy way to accomplish this as it will just default to a generic NTSC or PAL signal. For instance, with an nVidia card, you could follow these directoins: https://askubuntu.com/questions/481414/install-nvidia-driver-instead-of-nouveau
To enable SSL, you need a combined PEM file which can be created by:
To reset the keyboard controller run this on the Pi3:
```
/opt/diy-ipmi/Pi3/resetPi0HID.sh
```
If you get wierd USB errors, make sure your power brick is strong enough and that you're not trying to power the HDMI to S-Video converter via the Pi3.