Skip to content

Commit

Permalink
Updated homeassistant template to fix netdiscover requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
ngardiner committed Feb 19, 2017
1 parent a14668a commit f22b8b1
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 9 deletions.
12 changes: 12 additions & 0 deletions INTEGRATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Integration with Automation and Orchestration tools

## Introduction

The purpose of this topic is to explore how the hooks and customization features offered could be used to provide tight integration with automation and orchestration tools.

There are 3 ways in which automation and orchestration tools can hook into the containers created with this platform:
- Through post-deployment configuration, using tools such as ansible, chef, puppet.
- Through a call-back mechanism
- Through the on-demand instantiation of containers

# Ansible
8 changes: 7 additions & 1 deletion homeassistant/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ all: info/init_ok bootstrap global finalize

bootstrap:
dab bootstrap
dab install python3-pip python3-dev python3-setuptools
# These are known packaged dependancies
dab install netdiscover python3-aiohttp
dab install python3-appdirs python3-chardet python3-dev python3-distro-info python3-fuzzywuzzy
dab install python3-jinja2 python3-mutagen python3-netifaces python3-pip python3-six python3-sqlalchemy
dab install python3-markupsafe python3-pyparsing python3-requests python3-setuptools
dab install python3-tz python3-voluptuous python3-xmltodict python3-yaml python3-zeroconf
pip3 install -d . homeassistant
install -m 0644 [email protected] ${BASEDIR}/etc/systemd/system/[email protected]
install -m 0600 aiohttp-1.3.1.tar.gz ${BASEDIR}/tmp
Expand All @@ -33,6 +38,7 @@ bootstrap:
dab exec rm -f /tmp/*.whl
dab exec rm -f /tmp/*.tar.gz
install -m 0700 runonce.sh ${BASEDIR}/etc/init.d/firstboot
dab exec update-rc.d firstboot defaults
install -m 0700 custom.sh ${BASEDIR}/tmp
dab exec /bin/bash /tmp/custom.sh
dab exec rm -f /tmp/custom.sh
Expand Down
20 changes: 17 additions & 3 deletions homeassistant/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Homeassistant
# Home Assistant

- Creates a Ubuntu Xenial template with Python 3 and Home Assistant home automation system
- NOTE: Currently, this image will require some internet ac
- Adds any customizations such as root login enabled or SSH keys from ../Makefile.global
- Total uncompressed image size is *700 MB*
- Total compressed image size is *257 MB*
- Total uncompressed image size is *709 MB*
- Total compressed image size is *259 MB*

## How to use

- Deploy the Home Assistant template as a Linux Container and wait for it to boot
- Point your web browser to http://[container ip]:8123/ to view the Web Interface

## Development Notes

- Home Assistant will try to install all unmet dependancies at startup
- This is an issue for isolated hosts as well as for Python modules which require compilation
- Every new release will need some work to identify dependancy versions that have changed and new dependancies are added to the template
- We first try to meet the dependancies with inbuilt Ubuntu packages, followed by
4 changes: 2 additions & 2 deletions homeassistant/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ After=network.target

[Service]
Type=simple
User=%i
ExecStart=/usr/bin/hass
User=hass
ExecStart=/usr/local/bin/hass

[Install]
WantedBy=multi-user.target
53 changes: 50 additions & 3 deletions homeassistant/runonce.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,53 @@
#!/bin/bash
### BEGIN INIT INFO
# Provides: firstboot
# Required-Start: $local_fs
# Required-Stop:
# Should-Start: $network $portmap nfs-common udev-mtab
# Default-Start: S
# Default-Stop:
# Short-Description: First-boot system customization routines
# Description: Provides first-boot system customization for
# proxmox container templates.
# Removes itself entirely when done.
### END INIT INFO

# Once the script has completed execution, delete ourselves
rm $0
case "$1" in
start)

# Put first boot routines here

# Create HASS user
useradd -m hass

# Upgrade pip
pip3 install --upgrade pip

# Install netdiscover
pip3 install netdisco

# Enable the Home Assistant service
/bin/systemctl enable home-assistant@hass

# Start the Home Assistant service (need to spawn or it will hold up this script)
/bin/systemctl start home-assistant@hass &

# Once the script has completed execution, delete ourselves
update-rc.d firstboot disable
rm $0
;;
stop)
echo "Not Implemented"
;;
status)
echo "Not Implemented"
;;
restart|force-reload)
echo "Not Implemented"
;;
*)
echo "Usage: /etc/init.d/$NAME {start}" >&2
exit 1
;;
esac

exit 0

0 comments on commit f22b8b1

Please sign in to comment.