Coder Social home page Coder Social logo

hassio-addons / addon-terminal Goto Github PK

View Code? Open in Web Editor NEW
18.0 8.0 9.0 301 KB

Terminal - Community Hass.io Add-on for Home Assistant

Home Page: https://addons.community

License: MIT License

Shell 78.42% Dockerfile 21.58%
hass hassio home-automation homeassistant terminal shell home-assistant webterminal hassio-addons

addon-terminal's Introduction

Community Hass.io Add-ons: Terminal

GitHub Release Project Stage License

GitLab CI Project Maintenance GitHub Activity

Bountysource Discord Community Forum

Buy me a coffee

This add-on allows you to log in to your Hass.io Home Assistant instance using a web terminal.

Deprecation warning

This add-on is in a deprecated state!

This add-on is now deprecated and has been replaced by a different addon: "SSH & Web Terminal"

This new add-on combines the SSH and Terminal add-ons into one single powerful solution, contains the latest upgrades and updates, and provide much more tools.

Please upgrade asap since this add-on won't receive any updates or upgrades anymore.

About

This add-on allows you to log in to your Hass.io Home Assistant instance using a web terminal. Giving you to access your Home Assistant configuration file and folder, and also includes a command-line tool to do things like restart, update, and check your instance.

Terminal in the Home Assistant Frontend

Features

  • Access your terminal right from the web!
  • Add-able to your Home Assistant interface.
  • Compatible if Hass.io was installed via the generic Linux installer.
  • Persists custom SSH client settings & keys between add-on restarts
  • Have Alpine packages installed on start. This will allow you to install your favorite tools, which will be available every single time you log in.
  • Execute custom commands on start automatically so that you can customize the shell to your likings.
  • ZSH as its default shell. Easier to use for the beginner, more advanced for the more experienced user. It even comes preloaded with "Oh My ZSH", with some plugins enabled as well.
  • Contains a sensible set of tools right out of the box: curl, Wget, RSync, GIT, Nmap, Mosquitto client, MariaDB/MySQL client, Awake (“wake on lan”), Nano, Vim, tmux, and a bunch commonly used networking tools.

Installation

The installation of this add-on is pretty straightforward and not different in comparison to installing any other Hass.io add-on.

  1. Add our Hass.io add-ons repository to your Hass.io instance.
  2. Install the "Terminal" add-on.
  3. Start the "Terminal" add-on
  4. Check the logs of the "Terminal" add-on to see if everything went well.
  5. Surf to your Hass.io instance and use port 7681 (e.g. http://hassio.local:7681).

NOTE: Do not add this repository to Hass.io, please use: https://github.com/hassio-addons/repository.

Docker status

Docker Architecture Docker Version Docker Layers Docker Pulls Anchore Image Overview

Docker Architecture Docker Version Docker Layers Docker Pulls Anchore Image Overview

Docker Architecture Docker Version Docker Layers Docker Pulls Anchore Image Overview

Docker Architecture Docker Version Docker Layers Docker Pulls Anchore Image Overview

Configuration

Note: Remember to restart the add-on when the configuration is changed.

Example add-on configuration:

{
  "log_level": "info",
  "username": "hassio",
  "password": "changeme",
  "ssl": true,
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem",
  "packages": [
    "python",
    "python-dev",
    "py-pip",
    "build-base"
  ],
  "init_commands": [
    "pip install virtualenv",
    "pip install yamllint"
  ]
}

Note: This is just an example, don't copy and past it! Create your own!

Option: log_level

The log_level option controls the level of log output by the addon and can be changed to be more or less verbose, which might be useful when you are dealing with an unknown issue. Possible values are:

  • trace: Show every detail, like all called internal functions.
  • debug: Shows detailed debug information.
  • info: Normal (usually) interesting events.
  • warning: Exceptional occurrences that are not errors.
  • error: Runtime errors that do not require immediate action.
  • fatal: Something went terribly wrong. Add-on becomes unusable.

Please note that each level automatically includes log messages from a more severe level, e.g., debug also shows info messages. By default, the log_level is set to info, which is the recommended setting unless you are troubleshooting.

Using trace or debug log levels puts the terminal daemon into debug mode.

Option: username

This option allows you to enable authentication on accessing the terminal. It is only used for the authentication; you will be the root user after you have authenticated. Using root as the username is possible, but not recommended. Leaving it empty would disable the possibility of authentication completely.

Note: If you set an username, password becomes mandatory as well.

Option: password

Sets the password to authenticate with. Leaving it empty would disable the possibility to authenticate completely.

Note: If you set a password, username becomes mandatory as well.

Option: ssl

Enables/Disables SSL (HTTPS) on the web terminal. Set it true to enable it, false otherwise.

Option: certfile

The certificate file to use for SSL.

Note: The file MUST be stored in /ssl/, which is default for Hass.io

Option: keyfile

The private key file to use for SSL.

Note: The file MUST be stored in /ssl/, which is default for Hass.io

Option: packages

Allows you to specify additional Alpine packages to be installed in your shell environment (e.g., Python, Joe, Irssi).

Note: Adding many packages will result in a longer start-up time for the add-on.

Option: init_commands

Customize your terminal environment even more with the init_commands option. Add one or more shell commands to the list, and they will be executed every single time this add-on starts.

Embedding into Home Assistant

It is possible to embed the terminal directly into Home Assistant, allowing you to access your terminal through the Home Assistant frontend.

Home Assistant provides the panel_iframe component, for these purposes.

Example configuration:

panel_iframe:
  terminal:
    title: Terminal
    icon: mdi:console
    url: https://addres.to.your.hass.io:7681

Known issues and limitations

The following error may occur in your add-on log:

ERR: lws_context_init_server_ssl: SSL_CTX_load_verify_locations unhappy

This error can be safely ignored; the add-on will function properly.

Changelog & Releases

This repository keeps a change log using GitHub's releases functionality. The format of the log is based on Keep a Changelog.

Releases are based on Semantic Versioning, and use the format of MAJOR.MINOR.PATCH. In a nutshell, the version will be incremented based on the following:

  • MAJOR: Incompatible or major changes.
  • MINOR: Backwards-compatible new features and enhancements.
  • PATCH: Backwards-compatible bugfixes and package updates.

Support

Got questions?

You have several options to get them answered:

You could also open an issue here GitHub.

Contributing

This is an active open-source project. We are always open to people who want to use the code or contribute to it.

We have set up a separate document containing our contribution guidelines.

Thank you for being involved! 😍

Authors & contributors

The original setup of this repository is by Franck Nijhof.

For a full list of all authors and contributors, check the contributor's page.

We have got some Hass.io add-ons for you

Want some more functionality to your Hass.io Home Assistant instance?

We have created multiple add-ons for Hass.io. For a full list, check out our GitHub Repository.

License

MIT License

Copyright (c) 2017 Franck Nijhof

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

addon-terminal's People

Contributors

bastula avatar frenck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

addon-terminal's Issues

Raspberry Pi3 reseting when installing from local addons

I would like to add a external usb hard drive to my home assistant to expand the SMB share. I am attempting to install this addon under my local addons for Home assistant 0.60 running on a Raspberry Pi using the hassio image. I have found that this can't be done directly via SSH, but I have come across this forum thread which describes modifying the config.json file of this addon to grant access to the attached block device, allowing me to mount it.

I have git cloned the repo, added the described lines in the config, and uploaded to my local addons folder. When I go into the hassio store and try to install the addon, my device appears to reset. I have attempted to install this multiple times without success. I can not find anything in the logs either that explains what issue is being encountered.

SSL Error - but still working as expected

Problem/Motivation

I wanted to enable SSL - i have a cert from Geotrust, and i use it for all other services on HASS

Expected behavior

No issues in the logfile regarding SSL Certificate

Actual behavior

I get this error in the logfile

INFO: Starting the ttyd daemon
[2018/04/19 10:48:04:5775] ERR: lws_context_init_server_ssl: SSL_CTX_load_verify_locations unhappy
[2018/04/19 10:48:04:5814] ERR: Unable to load SSL Client certs file from (null) -- client ssl isn't going to work

Then when this error is reproduced then it seems like the Terminal is somehow stuck restarting the terminal module will make it work again.

Steps to reproduce

Restart the service - it will fire everytime, and when i remove the SSL it stops but iFrame with SSL/NON SSL is not good in chrome etc.

Directory `/addons` does not appear mapped

Problem/Motivation

Installation of HASSIO using generic LINUX installation; access to homeassistant container using docker CLI docker exec -it homeassistant bash provides visibility into /addons, /config and other directories; updates copied from host (VM) to /config are represented when accessing homeassistant using terminal addon; do not see changes to directory /addons

Expected behavior

Expected to see /addons populated with directories/files copied using docker cp

Actual behavior

Saw files copied using docker cp for the /config directory, but not the /addons directory.

Steps to reproduce

Install hassio on LINUX host (VM); add-on terminal; connect to homeassistant; inspect /config and /addons for content; make changes to /config and /addons using docker CLI from host; utilize terminal to inspect directories; see changes reflected in /config, but not /addons.

Proposed changes

(If you have a proposed change, workaround or fix, describe the rationale behind it)

Terminal did not start on hassio

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] 10-hassio: applying... 
[fix-attrs.d] 10-hassio: exited 0.
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-banner.sh: executing... 
-----------------------------------------------------------
 Hass.io Add-on: Terminal v2.3.0
 Terminal access to your Home Assistant instance via the web
 From: Community Hass.io Add-ons
 By: Franck Nijhof <[email protected]>
-----------------------------------------------------------
[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing... 
Log level is set to INFO
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] 02-updates.sh: executing... 
INFO: You are running the latest version of this add-on
[cont-init.d] 02-updates.sh: exited 0.
[cont-init.d] 03-version-requirements.sh: executing... 
Version 103 is not a valid version.Error: "No Major.Minor.Patch elements found"FATAL: You Supervisor version is: 103
FATAL: This add-on requires: >=0.81.0
FATAL: Please consider upgrading.
[cont-init.d] 03-version-requirements.sh: exited 1.
[cont-finish.d] executing container finish scripts...
[cont-finish.d] 99-message.sh: executing... 
-----------------------------------------------------------
                Oops! Something went wrong.
 
 We are so sorry, but something went terribly wrong when
 starting or running this add-on.
 
 Be sure to check the log above, line by line, for hints.
-----------------------------------------------------------
[cont-finish.d] 99-message.sh: exited 0.
[cont-finish.d] done.
[s6-finish] syncing disks.
[s6-finish] sending all processes the TERM signal.

Protocol adaptive 'WebUI' button

Problem/Motivation

The Open Web UI button in Terminal doesn’t open the https:// page when I have SSL set to true. Can the button be adaptive?

Expected behavior

Whenever I click the 'Open Web UI' button, the terminal is opened correctly.

Actual behavior

It currently does not work when SSL is set to true.

Steps to reproduce

  • Install add-on
  • Enable SSL
  • Click the 'Open Web UI' button

Proposed changes

Change the 'webui' configuration parameter to adapt the SSL/proto setting.

Related forum post

https://community.home-assistant.io/t/repository-community-hass-io-add-ons/24705/115?u=frenck

Reproduceable Segmentation fault (Pi3/ standard hassio installation)

Problem/Motivation

Segmentation fault after some seconds of usage (reproduceable).

Logs

Environment: Hassio on Pi3

core-ssh:~# hassio host hardware
"serial": [],
"input": [],
"disk": [],
"audio": {
"0": {
"name": "bcm2835 - bcm2835 ALSA",
"type": "ALSA",
"devices": {
"0": "digital audio playback",
"1": "digital audio playback"

Terminal Log (Debug Mode):
starting version 3.2.2
[ADD-ON] Ensuring configuration requirements are met
[ADD-ON] Linking common directories into the home folder
[ADD-ON] [DEBUG] Linking common directory addons
[ADD-ON] [DEBUG] Linking common directory backup
[ADD-ON] [DEBUG] Linking common directory config
[ADD-ON] [DEBUG] Linking common directory share
[ADD-ON] [DEBUG] Linking common directory ssl
[ADD-ON] Configuring shell to persist history
[ADD-ON] [DEBUG] No custom init commands configured
[ADD-ON] Starting terminal server
[2017/08/25 15:37:02:1351] NOTICE: ttyd 1.3.2 (libwebsockets 2.2.0)
[2017/08/25 15:37:02:1352] NOTICE: tty configuration:
[2017/08/25 15:37:02:1352] NOTICE: start command: tmux new -A -s ttyd zsh
[2017/08/25 15:37:02:1352] NOTICE: reconnect timeout: 30s
[2017/08/25 15:37:02:1352] NOTICE: close signal: SIGHUP (1)
[2017/08/25 15:37:02:1352] NOTICE: Initial logging level 7
[2017/08/25 15:37:02:1353] NOTICE: Libwebsockets version: 2.2.0 [email protected]
[2017/08/25 15:37:02:1353] NOTICE: IPV6 not compiled in
[2017/08/25 15:37:02:1353] NOTICE: libev support not compiled in
[2017/08/25 15:37:02:1353] NOTICE: libuv support not compiled in
[2017/08/25 15:37:02:1354] NOTICE: Threads: 1 each 1048576 fds
[2017/08/25 15:37:02:1578] NOTICE: mem: platform fd map: 4194304 bytes
[2017/08/25 15:37:02:1581] NOTICE: Compiled with OpenSSL support
[2017/08/25 15:37:02:1581] NOTICE: SSL disabled: no LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT
[2017/08/25 15:37:02:1582] NOTICE: Creating Vhost 'default' port 7681, 2 protocols, IPv6 off
[2017/08/25 15:37:02:1583] NOTICE: Listening on port 7681
[2017/08/25 15:37:02:1583] NOTICE: mem: per-conn: 448 bytes + protocol rx buf
[2017/08/25 15:37:02:1583] NOTICE: canonical_hostname = a0d7b954-terminal
[2017/08/25 15:37:02:1584] NOTICE: listening on port 7681
[2017/08/25 15:37:39:7955] NOTICE: HTTP / - 172.30.32.1 (homeassistant)
[2017/08/25 15:37:39:8332] NOTICE: HTTP /auth_token.js - 172.30.32.1 (homeassistant)
[2017/08/25 15:37:39:8438] NOTICE: WS /ws - 172.30.32.1 (homeassistant), clients: 1
[2017/08/25 15:37:39:8488] NOTICE: started process, pid: 39
/run.sh: line 375: 37 Segmentation fault (core dumped) ttyd -d 7 --reconnect 30 --port 7681 tmux new -A -s ttyd zsh

Nothing unusual on homeassistant & supervisor log

Terminal does not start, with SSL enabled

Problem/Motivation

Terminal will not load/start

Expected behavior

Terminal starts normally

Actual behavior

After starting the add on, refreshing logs shows repeating "INFO: Starting the ttyd daemon"

Steps to reproduce

Start Terminal addon, refresh logs

Proposed changes

(If you have a proposed change, workaround or fix,
describe the rationale behind it)

Persist '~/.ssh/known_hosts' file

Problem/Motivation

Currently, the known_hosts file is not persistent. This might cause an annoying warning when connecting to an SSH host after a reboot.

Expected behavior

To persist the known_hosts file between restarts of the add-on

Actual behavior

The file is missing after a restart and created upon connecting to another SSH server.

Steps to reproduce

  • Connect to an SSH host
  • Accept the host key of the remote server
  • Restart plugin
  • Connect to the server again.
    -> The question occurs again...

Proposed changes

On boot:

  • Create an empty known_hosts file in the data directory
  • Symlink the UserKnownHosts SSH file to the one in the data directory

Rewrite add-on onto the S6 process supervisor

Problem/Motivation

This account currently uses a large run.sh script that bootstraps the whole add-on.
Our new base images actually contain the S6 process supervisor, which allows us the split all kinds of different add-on responsibilities in an amazing way.

Additionally, the new base images are equipped with an extensive Bash function library full of tools towards Home Assistant add-ons on S6. This will greatly reduce the amount of code and improve stability overall.

Terminal Add-on crashes after 15-20 seconds of use

Problem/Motivation

The terminal add-on allows login and a few commands and then stops functioning and can not be used again until restarted.

Expected behaviour

I expected Terminal to continue to operate.

Actual behaviour

Terminal loads, interacting with Terminal works for 20 or so seconds (simple things like ls-la, top, uptime commands all works) and then it stops working.

Steps to reproduce

Very new a clean implementation of hassio (as of 30th January 2018).

Proposed changes

(If you have a proposed change, workaround or fix,
describe the rationale behind it)

log file from restart to crash.

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] 10-hassio: applying... 
[fix-attrs.d] 10-hassio: exited 0.
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-banner.sh: executing... 
-----------------------------------------------------------
 Hass.io Add-on: Terminal v2.2.1
 Terminal access to your Home Assistant instance via the web
 From: Community Hass.io Add-ons
 By: Franck Nijhof <[email protected]>
-----------------------------------------------------------
[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing... 
Log level is set to INFO
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] 02-updates.sh: executing... 
INFO: You are running the latest version of this add-on
[cont-init.d] 02-updates.sh: exited 0.
[cont-init.d] 03-version-requirements.sh: executing... 
INFO: Supervisor version requirements checks passed.
[cont-init.d] 03-version-requirements.sh: exited 0.
[cont-init.d] 10-requirements.sh: executing... 
[cont-init.d] 10-requirements.sh: exited 0.
[cont-init.d] 30-link-common-dirs.sh: executing... 
[cont-init.d] 30-link-common-dirs.sh: exited 0.
[cont-init.d] 40-zsh.sh: executing... 
[cont-init.d] 40-zsh.sh: exited 0.
[cont-init.d] 50-user-ssh-folder.sh: executing... 
[cont-init.d] 50-user-ssh-folder.sh: exited 0.
[cont-init.d] 80-user-packages.sh: executing... 
[cont-init.d] 80-user-packages.sh: exited 0.
[cont-init.d] 81-user-scripts.sh: executing... 
[cont-init.d] 81-user-scripts.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
starting version 3.2.4
[services.d] done.
INFO: Starting the ttyd daemon
INFO: Starting the ttyd daemon
[2018/02/01 10:49:06:8219] ERR: ERROR on binding fd 6 to port 7681 (-1 98)
[2018/02/01 10:49:06:8220] ERR: init server failed
[2018/02/01 10:49:06:8220] ERR: Failed to create default vhost
[2018/02/01 10:49:06:8220] ERR: libwebsockets init failed

Add CodeClimate

Problem/Motivation

Add CodeClimate.com to this repository in order to protect the code quality of this add-on.

ERR: lws_context_init_server_ssl: SSL_CTX_load_verify_locations unhappy

Problem/Motivation

The following error is displayed in the logs of the add-on:

ERR: lws_context_init_server_ssl: SSL_CTX_load_verify_locations unhappy

The add-on, however, functions perfectly.

Proposed changes

Find out of this error can be fixed or suppressed.
At least add it to the documentation as a known error.

Access to /dev/mem and gpio

Problem/Motivation

I'm was trying to use this addon to run a python script to listen to RF signals using rpi-rf module . I'm able to install rpi-rf but when I try to run the script to listen to RF codes I get the following error:

python3 /share/rfreceive.py
Traceback (most recent call last):
File "/share/rfreceive.py", line 28, in <module>
rfdevice.enable_rx()
File "/usr/lib/python3.6/site-packages/rpi_rf/rpi_rf.py", line 167, in enable_rx
GPIO.setup(self.gpio, GPIO.IN)
RuntimeError: No access to /dev/mem. Try running as root!

For what I could tell, the problem here is that this addon is not set to access /dev/mem and gpio information.

Expected behavior

Ability to access signals received in a gpio.

Actual behavior

Unable to access /dev/mem and signals sent to a receiver connected to a gpio.

Steps to reproduce

Start terminal with the following config:
{
"log_level": "info",
"username": "",
"password": "",
"ssl": false,
"certfile": "fullchain.pem",
"keyfile": "privkey.pem",
"packages": [
"python3",
"python3-dev",
"build-base",
"musl-dev",
"gcc"
],
"init_commands": ["pip3 install rpi-rf"]
}
In terminal, run python3 /share/rpi-rf_receive.py which contains the code found here

Proposed changes

According to https://home-assistant.io/developers/hassio/addon_config/, the gpio key needs to be set and also read/write access to /dev/mem and SYS_RAWIO privilege.

Add CircleCI

Problem/Motivation

In order to keep up the quality of the repository/add-on, we need to have some continuous integration in place.

Expected behavior

To trigger a CirlceCI job on each push & PR to assure everything is still in working order.
PR's SHOULD NOT be mergeable when the build fails.

Actual behavior

Currently, there is no CI present.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.