Skip to content
This repository has been archived by the owner on Oct 30, 2019. It is now read-only.

Documentation updates. #273

Merged
merged 7 commits into from
May 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
155 changes: 5 additions & 150 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ The process is straight-forward.

## Pull Requests for new scripts.
All new scripts must meet the following criteria to be considered to be reviewed:
- Stickler-Ci should report no errors. (this is an automated review process based on [shellcheck](https://github.com/koalaman/shellcheck)
- Stickler-Ci should report no errors. (this is an automated review process based on [shellcheck](https://github.com/koalaman/shellcheck))
- The Script must be tested with success locally, see [testing your code](#testing-your-code) for tips on how to test.
- Every script should have a validation at the end, see [validation](#validation) for tips.
- You **must** add [documentation](#documentation) to the /docs for the script.
- You **must** add [documentation](#documentation) to the `/docs` for the script.

### PR Naming
Create a good name for your PR, this will be used in the changelog.
Expand All @@ -38,152 +38,7 @@ A good description of what the PR does, will certanly help during the review pro
### Comments
Your PR will most likely get comments during the review process, this is _not_ to criticise your work.
But feedback on how your PR can better match our "standards", you should have a look at existing scripts in the [repo](https://github.com/home-assistant/hassbian-scripts/tree/dev/package/opt/hassbian/suites).
If some comments are unclear to you, use the thread under that comment to get clarification, or drop a line in the #devs_hassbian channel over at [Discord](https://discord.gg/c5DvZ4e). We want to help you help us getting Hassbian-scripts better.
If some comments are unclear to you, use the thread under that comment to get clarification, or drop a line in the **#devs_hassbian** channel over at [Discord](https://discord.gg/c5DvZ4e). We want to help you help us getting Hassbian-scripts better.

## Structure of the hassbian-scripts
The scripts in Hassbian-scripts are referred to as suites. These suites are bash scripts with a `.sh` file extension.
Each suite is built up of functions, and every script should have at least these functions:
- suite-show-short-info.
- This info will be printed at the start when the script runs and is also used by `hassbian-config show`.
- This will typically include a short description of the suite.
- suite-show-long-info.
- This info will be printed when running `hassbian-config show suite`.
- This will typically include a longer description of the suite, and it's features.
- suite-show-copyright-info.
- This info will be printed at the start when the script runs and is also used by `hassbian-config show suite`.
- This will typically include the name/username and a link to github of the person writing the script.
- suite-install-package and or suite-upgrade-package, this is where the magic happens, this is where you include your script.

## Special notations about install/upgrade functions
### User inputs
If your script require user inputs, they should be at the top of the function.
And if possible have an option to use `--accept (-Y)` flag, to set default values and omit the input.
Example:
```bash
function suite-install-package {
if [ "$ACCEPT" == "true" ]; then #This will be true if the suite is run with `--accept`
SUITE_USERNAME="pi"
else
echo
echo "Please take a moment to setup the suite."
echo -n "Enter a username of your choosing: "
read -r SUITE_USERNAME
if [ ! "$SUITE_USERNAME" ]; then
SUITE_USERNAME="pi" #Sets default if blank input is given.
fi
echo
fi
```

### Validation.
There are multiple ways of validating if the script was successful, these are some examples:

**Service**
This will check if there is a service with the name `shellinaboxd` running.
```bash
validation=$(pgrep -f shellinaboxd)
if [ ! -z "${validation}" ]; then
echo
echo -e "\\e[32mInstallation done..\\e[0m"
echo
echo "You can now access the web terminal here: http://$ip_address:4200"
echo "You can also add this to your Home-Assistant config in an 'panel_iframe'"
echo
else
echo
echo -e "\\e[31mInstallation failed..."
echo
return 1
fi
return 0
```

**pip package**
This will check if the pip package `cython` is installed in the virtual environment.
```bash
echo "Checking the installation..."
validation=$(sudo -u homeassistant -H /bin/bash << EOF | grep Version | awk '{print $2}'
source /srv/homeassistant/bin/activate
pip3 show cython
EOF
)
if [ ! -z "${validation}" ]; then
echo
echo -e "\\e[32mInstallation done..\\e[0m"
echo
echo "To continue have a look at https://home-assistant.io/components/tradfri/"
echo "It's recommended that you restart your Tradfri Gateway before continuing."
echo
else
echo
echo -e "\\e[31mInstallation failed..."
echo
return 1
fi
return 0
```

**Command line tool**
This will check if `psql` is a valid command.
```bash
validation=$(which psql)
if [ ! -z "${validation}" ]; then
echo
echo -e "\\e[32mInstallation done..\\e[0m"
echo
echo "No database or database user is created during this setup and will need to be created manually."
echo
echo "To continue have a look at https://home-assistant.io/components/recorder/"
echo
else
echo
echo -e "\\e[31mInstallation failed..."
echo
return 1
fi
return 0
```

**Config change**
This example will check the value, if blank it will print "Installation Failed"
```bash
validation=$(getcap /usr/bin/python3.5 | awk -F'= ' '{print $NF}')
if [ ! -z "${validation}" ]; then
echo
echo -e "\\e[32mInstallation done..\\e[0m"
echo
echo "To continue have a look at https://home-assistant.io/components/emulated_hue/"
echo
else
echo
echo -e "\\e[31mInstallation failed..."
echo
return 1
fi
return 0
```

## Testing your code
Testing the code can be done in the following steps:
1. Make sure you have the newest version from the upstream dev. branch. `sudo hassbian-config upgrade hassbian-script-dev`
2. Put your `suite.sh` file in the `/opt/hassbian/suites/` directory.
3. Run test with `sudo hassbian-config install suite` and/or `sudo hassbian-config upgrade suite`
- If you added support for `-y` test this to.

## Documentation
First create a new `suite.md` file in the /docs directory in your fork.
There can never be too much documentation, the file should have a minimum of:
- Description
- Installation and/or upgrade line/lines
- Who made the script.

It should also contains if possible:
- Log location
- Configuration location.
- Service commands (start, stop, restart, status)
- Defaults:
- username
- password
- port

When the `suite.md` is finished, add it as an link in the README.md
### More info
For more information about contributions in the different sections of the project have a look at the [contribution documentation](https://home-assistant.github.io/hassbian-scripts/contribute).
31 changes: 26 additions & 5 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,40 @@
<!--
Make sure your running an up to date version of Hassbian before reporting a problem. If not make sure to specify what version and why so we can recreate the issue in question.

You should only file an issue if you found a bug. Feature and enhancement requests should go in [#33](https://github.com/home-assistant/hassbian-scripts/issues/33) that's dedicated for this usage.
-->

**Hassbian-config version (`hassbian-config -V`):**

**Script/Suite:**
## Hassbian-config version

**Description of problem:**
<!-- You can run `hassbian-config -V` to check -->

**Expected:**
## Suite name

<!-- Name of the suite -->

## Description of problem

```text

```

## Expected result

```text

```


## Traceback/log

**Traceback/log (if applicable):**
```bash

```

**Additional info:**

```text


```
43 changes: 36 additions & 7 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,40 @@
## Description:
# Description

<!-- Fill out a description to what this PR adds/changes. -->

**Related issue (if applicable):** Fixes #<hassbian-scripts issue number goes here>

## Checklist (Required):
- [ ] The code change is tested and works locally.
- [ ] The code is compliant with [Contributing guidelines](https://github.com/home-assistant/hassbian-scripts/blob/master/.github/CONTRIBUTING.md)
## Checklist

<!--
Comment out the sections that does not apply like this comment.
For changes to documentation only, you can comment out all sections.
-->

### New suite

- [ ] The code change is tested and works locally.
- [ ] The code is compliant with [Contributing guidelines][guidelines]
- [ ] Script has validation check of the job.
- [ ] Created documentation at `/docs/suites`

### Change to existing suite

- [ ] The code change is tested and works locally.
- [ ] The code is compliant with [Contributing guidelines][guidelines]
- [ ] Updated documentation at `/docs/suites`

### New function

- [ ] The code change is tested and works locally.
- [ ] The code is compliant with [Contributing guidelines][guidelines]
- [ ] Script has validation check of the job.
- [ ] Created documentation at `/docs/cli`

### Change to existing function

- [ ] The code change is tested and works locally.
- [ ] The code is compliant with [Contributing guidelines][guidelines]
- [ ] Updated documentation at `/docs/cli`

### If pertinent:
- [ ] Script has validation check of the job.
- [ ] Created/Updated documentation at `/docs`
[guidelines]: https://github.com/home-assistant/hassbian-scripts/blob/master/.github/CONTRIBUTING.md
51 changes: 2 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,5 @@
# Hassbian-scripts

These are the scripts used in the [Hassbian][hassbian] image.
The scripts in this repository where made to be used with the Hassbian image
and the included Home Assistant instance.
The documentation for the content in this repository can be found here:

## The included scripts

The following scripts are currently included. You can view the documentation
below for usage and instructions.

<!--- When adding stuff here, please keep it alphabetical --->

- [hassbian-config](/docs/hassbian_config.md)
- [AppDaemon](/docs/appdaemon.md)
- [Cloud9](/docs/cloud9.md)
- [custom-component-store](/docs/custom-component-store.md)
- [Duck DNS](/docs/duckdns.md)
- [Fail2ban](/docs/fail2ban.md)
- [Hassbian](/docs/hassbian.md)
- [Home Assistant](/docs/homeassistant.md)
- [HUE](/docs/hue.md)
- [LibCEC](/docs/libcec.md)
- [Manager](/docs/manager.md)
- [MariaDB](/docs/mariadb.md)
- [Monitor](/docs/monitor.md)
- [Mosquitto](/docs/mosquitto.md)
- [Pi-hole](/docs/pihole.md)
- [PostgreSQL](/docs/postgresql.md)
- [MS SQL](/docs/mssql.md)
- [RaZberry](/docs/razberry.md)
- [Samba](/docs/samba.md)
- [Trådfri](/docs/tradfri.md)
- [Webterminal](/docs/webterminal.md)
- [Zigbee2mqtt](/docs/zigbee2mqtt.md)
- [Changelog][changelog]

***

## Raspbian Jessie

If this package is used with a Debian Jessie based distribution then you need
to uncomment the source repositories in `/etc/apt/sources.list`

```text
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
deb-src http://archive.raspbian.org/raspbian/ jessie main contrib non-free rpi
```

<!--- Links --->
[changelog]: https://github.com/home-assistant/hassbian-scripts/releases
[hassbian]: https://github.com/home-assistant/pi-gen
https://home-assistant.github.io/hassbian-scripts/
45 changes: 45 additions & 0 deletions docs/cli/cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
_Scripts used in the Hassbian image._

***

[HOME](/) | [SUITES](/suites) | [**HASSBIAN-CONFIG (CLI)**](/cli) | [CONTRIBUTE](/contribute)

***

[**CLI**](/cli/cli) | [HELPER FUNCTIONS](/cli/helpers)

***

# CLI Usage

```bash
hassbian-config [command] [suite] [options]
```

## command

command | alias | description
-- | -- | --
install | | Install a [suite].
upgrade | | Upgrade a [suite].
remove | | Remove a [suite].
show | | To see available [suite] for install/upgrade.
log | | Displays an log of the last operation.
share-log | | Generates an hastebin link of the last operation.
show-installed | | Generates a list of installed suites.
--version | -V | Prints the version of hassbian-config.
--help | -H | Displays information similar to this list.

## suite

All suites can be found [here](/suites)

## option (flags)

option | alias | description
-- | -- | --
--accept | -Y | Accept defaults on scripts that allows this.
--force | -F | Force run an script, this is useful if you need to reinstall a package.
--debug | -D | This will output every command to the console.
--beta | -B | This will install the current beta version if implemented.
--dev | | This will install the current development version if implemented.
Loading