Skip to content

Commit

Permalink
Merge pull request #110 from Pack3tL0ss/dev
Browse files Browse the repository at this point in the history
show tl and tp options, tty size when launching fix menu_actions
  • Loading branch information
Pack3tL0ss authored Feb 7, 2021
2 parents 17eebf3 + e9cbad6 commit e3b6f99
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 103 deletions.
2 changes: 1 addition & 1 deletion .static.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This file should not be modified. Static variables/paths used throughout ConsolePi
# Versioning = YYYY.Major.Patch/Minor
---
CONSOLEPI_VER: 2021-1.0
CONSOLEPI_VER: 2021-1.1
INSTALLER_VER: 54
CFG_FILE_VER: 9
CONFIG_FILE_YAML: /etc/ConsolePi/ConsolePi.yaml
Expand Down
98 changes: 25 additions & 73 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ wget -q https://raw.githubusercontent.com/Pack3tL0ss/ConsolePi/master/installer/
# What's New

Prior Changes can be found in the - [ChangeLog](changelog.md)
### Feb 2021 (v2021-1.1)
- Fix: dhcpcd.exit-hook had an issue that impacted shared vpn on wired, a previously undocumented feature.
- Fix: menu item mapping, when a refresh resulted in an additional adapter being added.
- Enhancement: Expose previously hidden 'tl' and 'tp' menu items.
- Enhancement: Display current tty size when connecting to a serial or TELNET device.
>Handy when connecting to a device that needs the terminal adjusted to use the full display size.
### Jan 2021 (v2021-1.0)
**DHCP based Automation Enhancements**
- Fix an issue that was overlooked, where AutoHotSpot is *not* selected and wired-dhcp is.
Expand All @@ -92,7 +99,7 @@ Prior Changes can be found in the - [ChangeLog](changelog.md)
## **Feature Summary Image**
![consolepi-menu image](https://raw.githubusercontent.com/Pack3tL0ss/ConsolePi/master/readme_content/ConsolePi_features.jpg)

## **Serial Console Server**
## Serial Console Server
This is the core feature of ConsolePi. Connect USB to serial adapters to ConsolePi (or use the onboard UART(s)), then access the devices on those adapters via the ConsolePi. Supports TELNET directly to the adapter, or connect to ConsolePi via SSH or BlueTooth and select the adapter from `consolepi-menu`. The menu will show connection options for any locally connected adapters, as well as connections to any remote ConsolePis discovered via Cluster/sync. The menu has a lot of other features beyond connecting to local adapters, as shown in the image above.

- When connecting to the ConsolePi via bluetooth, default behavior is to auto-login and launch a limited function menu. Given this user is automatically logged in, the user has limited rights, hence the limited function menu (allows access to locally attached adapters).
Expand All @@ -103,22 +110,23 @@ For guidance on USB to serial adapters check out the sh#t list [here](adapters.m

> There are some lame adapters that don't burn a serial # to the chip, this makes assigning a unique name/TELNET port more challenging). The link above is a page where we note what chipsets are solid and which ones are a PITA.
## **AutoHotSpot**
## AutoHotSpot

Script runs at boot (can be made to check on interval via Cron if desired). Looks for pre-defined SSIDs, if those SSIDs are not available then it automatically goes into hotspot mode and broadcasts its own SSID. In HotSpot mode user traffic is NAT'd to the wired interface if the wired interface is up.

When ConsolePi enters hotspot mode, it first determines if the wired port is up and has an IP. If the wired port is *not* connected, then the hotspot distributes DHCP, but does not provide a "Default Gateway" to clients. This allows a user to dual connect without having to remove a route to a gateway that can't get anywhere. I commonly use a second USB WLAN adapter to connect to ConsolePi, while remaining connected to the internet via a different SSID on my primary adapter.

> If a domain is provided to the wired port via DHCP, and the hotspot is enabled ConsolePi will distribute that same domain via DHCP to clients.
## **Automatic OpenVPN Tunnel**
## Automatic OpenVPN Tunnel

When an interface receives an IP address ConsolePi will Automatically connect to an OpenVPN server under the following conditions:
- It's configured to use the OpenVPN feature, and the ConsolePi.ovpn file exists (an example is provided during install)
- ConsolePi is not on the users home network (determined by the 'domain' handed out by DHCP)
- The internet is reachable via the interface. (Checked by pinging a configurable common internet reachable destination)
- When wired DHCP fallback is enabled and `ovpn_share: true` is set in the optional `OVERRIDES:` section of ConsolePi.yaml. The vpn connection will be shared with any devices connected to the wired interface (the automation will add the NAT rules).

## **Automatic PushBullet Notification**
## Automatic PushBullet Notification

*(Requires a PushBullet Account, API key, and the app / browser extension.)*

Expand All @@ -132,7 +140,7 @@ An additional message is sent once a tunnel is established if the Automatic Open

Each Time a Notification is triggered **all** interface IPs are sent in the message along with the ConsolePi's default gateway(s).

## **Automatic Wired DHCP Fallback**
## Automatic Wired DHCP Fallback

**Use with caution**

Expand All @@ -142,11 +150,11 @@ This is useful when configuring factory-default devices, or on an isolated stagi

This function also:
- Configures traffic from the wired interface to NAT out of the WLAN interface if the WLAN has an internet connection. (The reverse of Auto-HotSpot)
- Optionally Configure wired traffic to share access to the OpenVPN tunnel if established (via Auto-OpenVPN)
- Optionally, with `ovpn_share: true` set in the optional `OVERRIDES:` section of ConsolePi.yaml wired devices will share access to the OpenVPN tunnel if established (via Auto-OpenVPN).

> The [ZTP Orchestration](readme_content/ztp.md) feature will enable wired fallback to static/DHCP Server when you run `consolepi-ztp`. `consolepi-ztp -end` restores everything to pre-ZTP state. You do not need to enable it if ZTP is your only need for it `consolepi-ztp` will handle that.
## **ConsolePi Cluster / Cloud Sync**
## ConsolePi Cluster / Cloud Sync

The Cluster feature allows you to have multiple ConsolePis connected to the network, or to each other (i.e. first ConsolePi in hotspot mode, the others connected as clients to that hotspot). A connection to any one of the ConsolePis in the Cluster will provide options to connect to any local serial adapters, as well as those connected to the other ConsolePis in the cluster (via the `consolepi-menu` command).

Expand Down Expand Up @@ -212,73 +220,16 @@ The Power Control Function allows you to control power to external outlets. Con
> The power sub-menu **currently** only appears in the menu on the ConsolePi where the outlets are defined (Menu does not display outlets defined on remote ConsolePis). The auto-power-on when connecting to an adapter linked to an outlet works for both local and remote connections (establishing a connection to an adapter on a remote ConsolePi (clustering / cloud-sync function) via another ConsolePis menu)
### The Power Control Menu
*Defined Outlets will show up in the Power Menu. Note: These menu captures lack color, see the [Feature Summary Image](#feature-summary-image) to see what these sub-menus like in a terminal with ASCII colors.*
```bash
===========================================================

enter item # to toggle power state on outlet
enter c + item # i.e. "c2" to cycle power on outlet

1. [ON] bsmtpi_outlet (BsmtPi Port:bsmtpi_outlet)
2. [ON] garage_fan (GarageFan Port:garage_fan)
3. [OFF] 8320s (labpower1 Port:2)
4. [OFF] 5900_LAB_ToR (labpower1 Port:6)
5. [OFF] 6300Ms (labpower1 Port:8)
6. [OFF] r2-ToR_2930M (labpower2 Port:1)
7. [OFF] Nortel (labpower2 Port:2)
8. [OFF] sdbranch_9004s (labpower2 Port:3)
9. [OFF] 6200F (labpower2 Port:4)
10. [OFF] 6300M_CL6 (labpower2 Port:5)
11. [OFF] Legacy (labpower2 Port:6)
12. [OFF] C3750 (labpower2 Port:7)
13. [OFF] 5400s (labpower2 Port:8)

all on: Turn all outlets ON
all off: Turn all outlets OFF
cycle all: Cycle all outlets ON·OFF·ON

L. Show Connected Linked Devices
d. [dli] Web Power Switch Menu
b. Back
r. Refresh
x. Exit

========================================================================
>>
```
*Defined Outlets will show up in the Power Menu*

![consolepi-menu image](/readme_content/powermenu.png)


### Additional Controls for Digital Loggers
*You may have an 8 port digital-loggers web power switch, with only some of those ports linked to devices. Any Outlets linked to devices will show up in the Power Menu, All of the Ports for the DLI (regardless of linkage) will show up in the dli menu*
*You may have an 8 port digital-loggers web power switch, with only some of those ports linked to devices. Any Outlets linked to devices will show up in the Power Menu, **All** of the Ports for the DLI (regardless of linkage) will show up in the dli menu*

![consolepi-menu image](/readme_content/dlimenu.png)

```bash
===========================================================================================
--------------------------------- DLI Web Power Switch ----------------------------------
===========================================================================================
enter item # to toggle power state on outlet
enter c + item # i.e. "c2" to cycle power on outlet
enter r + item # i.e. "r2" to rename the outlet
--- labpower1 ---- ------ labpower2 ------- ------- stagepower --------
------------------ ------------------------ ---------------------------
1. [OFF] VACANT1 11. [OFF] P1: r2-ToR_2930M 21. [OFF] P1: DigiSR_3800SR
2. [OFF] 8320s 12. [OFF] P2: Nortel 22. [OFF] P2: VACANT2
3. [OFF] 7210 13. [OFF] P3: sdbranch_9004s 23. [OFF] P3: 2530-24
4. [OFF] 3800_L1sw 14. [OFF] P4: 6200F 24. [ON] P4: 2510-24
5. [OFF] MSR930 BCM50 15. [OFF] P5: 6300M_CL6 25. [OFF] P5: VACANT5
6. [OFF] 5900_LAB_ToR 16. [OFF] P6: Legacy 26. [OFF] P6: VACANT6
7. [OFF] 3810-Access 17. [OFF] P7: C3750 27. [OFF] P7: VACANT7
8. [OFF] 6300Ms 18. [OFF] P8: 5400s 28. [OFF] P8: VACANT8
9. ALL ON 19. ALL ON 29. ALL [on|off]. i.e. "29 off"
30. Cycle ALL
b. Back
r. Refresh
x. Exit
===========================================================================================
>>
```
### Outlet Linkages

Example Outlet Linkage. In this case the switch "rw-6200T-sw" has 2 ports linked. Both are on a dli web power switch. One of the ports is for this switch, the other is for the up-stream switch that serves this rack. When connecting to the switch, ConsolePi will ensure the linked outlets are powered ON. *ConsolePi does **not** power-off the outlets when you disconnect.*
Expand Down Expand Up @@ -723,7 +674,8 @@ The Use Cases
The Configuration file is validated and created during the install. Settings can be modified post-install via the configuration file `/etc/ConsolePi.yaml` (Some Changes will require consolepi-upgrade to be ran to take effect). See ConsolePi.yaml.example for an example of the available options.
### consolepi-menu sorting and connection settings
When you assign a friendly alias to an adapter for predictability via the `rn` (rename) option in `consolepi-menu` or via `consolepi-addconsole` an alias (udev rule) is created for that adapter and ser2net.conf is updated with a pointer to that alias using the next available TELNET port in the 7xxx range which includes the desired serial settings. The `consolepi-menu` parses the ser2net.conf to retrieve the serial settings for each device, but it also uses this file to determine the order the adapters appear in the menu. The menu is sorted by TELNET port#. So if you want re-arrange the order devices show up you just need to re-arrange the port #s used in ser2net.conf for the devices.
When you assign a friendly alias to an adapter for predictability via the `rn` (rename) option in `consolepi-menu` or via `consolepi-addconsole` an alias (udev rule) is created for that adapter and ser2net.conf is updated with a pointer to that alias using the next available TELNET port in the 7xxx range which includes the desired serial settings. The `consolepi-menu` parses the ser2net.conf to retrieve the serial settings for each device, but it also uses this file to determine the order the adapters appear in the menu. The menu is sorted by TELNET port#. So if you want re-arrange the order devices show up you just need to re-arrange the port #s mapped in `/etc/ser2net.conf` for the devices. Just ensure each device is mapped to a unique port (no duplicate ports).
> You can use the `tp` option in `consolepi-menu` to display the TELNET ports mapped to each device. Re-arranging them still needs to be done manually by editing `/etc/ser2net.conf`
### Configuring Manual Host Entries
The Manual Host Entries Feature allows you to manually define other SSH or TELNET endpoints that you want to appear in the menu. These entries will appear in the `rs` remote shell menu by default, but can also show-up in the main menu if `show_in_main: true`. Manual host entries support [power outlet bindings](readme_content/power.md#power-control-setup) as well. To configure this feature simply populate the optional `HOSTS:` section of `ConsolePi.yaml`. Using the following structure:
Expand All @@ -732,7 +684,7 @@ The Manual Host Entries Feature allows you to manually define other SSH or TELNE
HOSTS:
mm1(serial):
address: 10.0.30.60:7001
method: telnet
method: telnet # This field is now optional defaults to ssh if not specified.
show_in_main: true
group: WLAN
mc1(ssh):
Expand Down
Binary file added readme_content/dlimenu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified readme_content/menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions readme_content/power.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ POWER:
cloud_lab:
address: 10.0.230.10
type: tasmota
no_all: true
gpio_outlet1:
address: 4
linked_devs: ofc-2930F-sw
Expand Down Expand Up @@ -72,6 +73,7 @@ POWER: <-- required section header
type: [required, valid values = GPIO, tasmota, dli]
address: [required, GPIO pin (BCM numbering) if type is "GPIO" OR ip address/fqdn if type is "tasmota" or "dli"]
noff: [optional (bool) applies to GPIO default is true] ... indicates if outlet is normally off (true) or normally on (false)
no_all: [optional (bool)] ... indicates this outlet should *not* be included in 'all <on|off|cycle>' operations.
relays: [required and only applies to espHome outlets] ... This is the `name` of the relay being controlled (see espHome section below)
username: [required for dli] username used to access the dli
password: [required for dli] password used to access the dli - use quotes if special characters such as `:` are in the password.
Expand All @@ -88,7 +90,7 @@ POWER: <-- required section header
> *A 'normally off' outlet will revert to powered off if ConsolePi is powered-off, disconnected, or rebooted, inversely a 'normally on' outlet will revert to a powered-on state if ConsolePi is powered-off, disconnected, or rebooted.* The default is 'normally off', use `noff: false` for 'normally on' outlets.

![GPIO Pin Layout](readme_content/pin_layout.svg)
![GPIO Pin Layout](pin_layout.svg)

#### espHome Flashed WiFi Smart Outlets
- You'll need a WiFi smart outlet running espHome. There are plenty of resources online to help with that.
Expand Down Expand Up @@ -118,6 +120,10 @@ repeat as needed for multiple outlets.
Then the `POWER:` section of your `ConsolePi.yaml` would include something like this:
```
POWER:
cloud_lab:
address: 10.0.230.10
type: tasmota
no_all: true
outlet1:
address: outlet1.example.com
type: esphome
Expand All @@ -132,7 +138,7 @@ POWER:
AP-SERU: relay1
Orange6: [relay2, relay3]
```
The example above highlights a couple of scenarios. A multi-port power-strip, and a single port device. With espHome there is a "relays:" key in the config where the relays are defined. The values should match what was configured in the yaml used to compile the binary flashed to the device, for example this is a snippet from the config used to build the binary for powerstrip1 above:
The example above highlights the following. Outlet `cloud_lab` has the `no_all` key set to `true`, it will be excluded from any `all` operations available in the menu (`all on`, `all off`, `cycle all`). It also highlights A multi-port power-strip, and a single port device. With espHome there is a `relays:` key in the config where the relays are defined. The values should match what was configured in the yaml used to compile the binary flashed to the device, for example this is a snippet from the config used to build the binary for powerstrip1 above:
```
### THIS IS NOT AN EXAMPLE FOR ConsolePi.yaml, This is an example for espHome, more details found on espHome's site
switch:
Expand Down
Binary file added readme_content/powermenu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit e3b6f99

Please sign in to comment.