generated from aniongithub/pi-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Working template for rhasspy based voice-assistant without any site-s…
…pecific settings
- Loading branch information
1 parent
cc48363
commit 9d6dc0d
Showing
17 changed files
with
155 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Initialize any environment variables here | ||
# Note that env. substitution takes place on the host. | ||
|
||
BOOTSTRAP_HOSTNAME="pi-bootstrap" | ||
BOOTSTRAP_HOSTNAME="rhasspy" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,17 +18,17 @@ jobs: | |
- name: Write secrets.env | ||
env: | ||
SECRETS: ${{ secrets.SECRETS_ENV }} | ||
PIFILE: bootstrap.Pifile | ||
PIFILE: rhasspy.Pifile | ||
run: | | ||
echo $SECRETS > $(dirname $PIFILE)/secrets.env | ||
- name: Build image | ||
uses: Nature40/[email protected] | ||
with: | ||
pifile: bootstrap.Pifile | ||
pifile: rhasspy.Pifile | ||
|
||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ${{ github.workflow }}-${{ github.event.release.tag_name }}.zip | ||
path: bootstrap.img | ||
path: rhasspy.img |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"files.associations": { | ||
"*.yaml": "home-assistant" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,5 @@ | ||
# pi-bootstrap | ||
# rhasspy appliance | ||
|
||
A repository that shows how to use Pi-Gen and Github Actions to create a ready-to-use Raspberry Pi image that includes connectivity to your home Wi-Fi, custom packages and build steps without opening a terminal or any manual setup. You can do all of this directly within the Github UI, which significantly lowers the barrier of entry for novice users, who don't need to understand a lot of the technical details. | ||
A repository that shows how to use Pi-Bootstrap ready-to-use Raspberry Pi image that has Rhasspy, HomeAssistant and Node-RED ready to use as a voice assistant, including drivers for the [seeed-voicecard](https://github.com/respeaker/seeed-voicecard) based Raspberry Pi hats. | ||
|
||
Youtube video explaining the what, why and how. | ||
|
||
[![Bootstrapping the Raspberry Pi using GitHub Actions](http://img.youtube.com/vi/Lc6wvHgMYH4/0.jpg)](http://www.youtube.com/watch?v=Lc6wvHgMYH4 "Bootstrapping the Raspberry Pi using GitHub Actions ") | ||
|
||
:gear: This repository is intended as a basic template for developers who wish to create ready-to-use bootstrap repositories meant for novice users. See [aniongithub/raspotify-appliance](https://github.com/aniongithub/raspotify-appliance) for an example of a repository meant for novice end-users to use directly | ||
|
||
## Module environment variables | ||
|
||
The table below lists variables for each module in pi-bootstrap, confidential variables are marked by 🔑 and should be set in Github repository secret ```SECRET_ENV``` (or ```secrets.env``` if developing locally) while others can be committed to git in ```.env``` | ||
|
||
|
||
| Module | Variable | Description | Default | | ||
| :--------------: | --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | ----------------------- | | ||
| ```core``` | | Sets up core functions, software, environment, etc. Required to use pi-bootstrap modules | | | ||
| ```hostname``` | | Changes the hostname of your Raspberry Pi | | | ||
| | **BOOTSTRAP_HOSTNAME** | The name with which your Pi will identify itself to any networks | *pi-bootstrap* | | ||
| ```ssh``` | | Enables SSH access | | | ||
| ```password``` | | Changes the password for a specified user for more security | | | ||
| | **BOOTSTRAP_USER** 🔑 | Name of the user to change the password for | *pi* | | ||
| | **BOOTSTRAP_PASSWORD** 🔑 | The password for**${BOOTSTRAP_USER}** on the generated image | *b00tstrap* | | ||
| ```timezone``` | | Sets the timezone of your Raspberry Pi | | | ||
| | **BOOTSTRAP_TIMEZONE** | The[TZ database name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) (timezone) where your Raspberry Pi will run | *America/Los_Angeles* | | ||
| ```camera``` | | Enables the Raspberry Pi camera module | | | ||
| | **BOOTSTRAP_GPU_MEM** | Amount of GPU memory (MB) to reserve for camera operation | 128 | | ||
| ```wifi``` | | | | | ||
| | **BOOTSTRAP_WPA_SSID** 🔑 | SSID of your Wi-Fi network | *None* | | ||
| | **BOOTSTRAP_WPA_PASSPHRASE** 🔑 | Passphrase of your Wi-Fi network | *None* | | ||
| | **BOOTSTRAP_WPA_COUNTRY** | Two-character ISO-3166-1 alpha-2 country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) for your country. | *None* | | ||
| ```docker``` | | Sets up docker and docker-compose | | | ||
|
||
## Usage | ||
|
||
The flowchart below shows simple usage of pi-bootstrap. | ||
|
||
![Usage](assets/pi-bootstrap usage.svg) | ||
:gear: This repository is intended as a template for users who wish to create ready-to-use voice assistants customized for their homes, intents, networking and hardware setup. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# assuming you have only one non-system user | ||
homeassistant: | ||
auth_providers: | ||
- type: homeassistant | ||
- type: trusted_networks | ||
trusted_networks: | ||
- 192.168.68.0/24 | ||
- 127.0.0.1 | ||
- ::1 | ||
allow_bypass_login: true | ||
http: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Any environment vars we need for our startup/shutdown steps | ||
CONFIG_PATH= | ||
RHASSPY_PROFILES_PATH= | ||
HOMEASSISTANT_CONFIG_PATH= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
export SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
|
||
# Ensure we're running in our current directory | ||
pushd $SCRIPT_DIR | ||
trap "popd; exit" INT TERM EXIT | ||
|
||
# Set up environment configured in our env file | ||
# https://unix.stackexchange.com/a/79077/358706 | ||
set -o allexport | ||
. ./bootstrap.conf | ||
set +o allexport | ||
|
||
# Parse options using getopt | ||
# https://www.codebyamir.com/blog/parse-command-line-arguments-using-getopt | ||
opts=$(getopt \ | ||
--longoptions "start,stop" \ | ||
--name "$(basename "$0")" \ | ||
--options "" \ | ||
-- "$@" | ||
) | ||
eval set --$opts | ||
|
||
while [[ $# -gt 0 ]]; do | ||
case "$1" in | ||
--start) | ||
# Run (in lexical sort-order) all executable scripts within init.d for startup | ||
run-parts --exit-on-error init.d | ||
shift | ||
;; | ||
|
||
--stop) | ||
# Run (in lexical sort-order) all executable scripts within shutdown.d for shutdown | ||
run-parts --exit-on-error shutdown.d | ||
shift | ||
;; | ||
|
||
*) | ||
break | ||
;; | ||
esac | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
version: "3" | ||
services: | ||
nodered: | ||
image: nodered/node-red | ||
network_mode: host | ||
environment: | ||
TZ: "America/Los_Angeles" | ||
volumes: | ||
- /home/pi/.config/node-red:/data | ||
- /etc/localtime:/etc/localtime:ro | ||
- /etc/TZ:/etc/timezone:ro | ||
- /usr/share/zoneinfo:/usr/share/zoneinfo:ro | ||
rhasspy: | ||
depends_on: | ||
- nodered | ||
image: rhasspy/rhasspy | ||
network_mode: host | ||
volumes: | ||
- /home/pi/.config/rhasspy/profiles:/rhasspy/profiles | ||
devices: | ||
- /dev/snd:/dev/snd | ||
entrypoint: ["/usr/lib/rhasspy/bin/rhasspy-voltron", "--user-profiles", "/rhasspy/profiles", "--profile", "en"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
if ! lsmod | grep seeed; then | ||
echo "Installing seeed-voicecard driver..." | ||
export LC_ALL=C.UTF-8 | ||
cd /usr/local/src | ||
git clone https://github.com/HinTak/seeed-voicecard.git | ||
cd seeed-voicecard | ||
./install.sh | ||
reboot --force | ||
else | ||
echo "seeed-voicecard driver installed, continuing..." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
docker pull rhasspy/rhasspy | ||
docker pull nodered/node-red |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
echo heartbeat > /sys/class/leds/led0/trigger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
TIMEZONE="$(cat /etc/timezone)" \ | ||
docker-compose -f ${SCRIPT_DIR}/docker-compose.yaml up |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
docker-compose -f ${SCRIPT_DIR}/docker-compose.yaml down |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
echo none > /sys/class/leds/led0/trigger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[Unit] | ||
Description=Rhasspy | ||
Requires=docker.service | ||
After=docker.service | ||
|
||
[Service] | ||
Type=forking | ||
ExecStart=/etc/rhasspy/bootstrap.sh --start | ||
ExecStop=/etc/rhasspy/bootstrap.sh --stop | ||
Restart=on-failure | ||
RestartSec=5s | ||
User=root | ||
TimeoutSec=900 | ||
|
||
[Install] | ||
WantedBy=sysinit.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters