Docker ADR (#26085)
* Migrate Docker image to Hass.io / Multiarch * Fix sudo * Update CODEOWNERS * Fix manifest * Add more logic * fix handling * Move dockerfile * Modify optionspull/26092/head
parent
daa0330da4
commit
97d3f49bb8
|
@ -2,11 +2,12 @@
|
||||||
{
|
{
|
||||||
"name": "Home Assistant Dev",
|
"name": "Home Assistant Dev",
|
||||||
"context": "..",
|
"context": "..",
|
||||||
"dockerFile": "Dockerfile",
|
"dockerFile": "../Dockerfile.dev",
|
||||||
"postCreateCommand": "pip3 install -e .",
|
"postCreateCommand": "pip3 install -e .",
|
||||||
"appPort": 8123,
|
"appPort": 8123,
|
||||||
"runArgs": [
|
"runArgs": [
|
||||||
"-e", "GIT_EDITOR=\"code --wait\""
|
"-e",
|
||||||
|
"GIT_EDITOR=\"code --wait\""
|
||||||
],
|
],
|
||||||
"extensions": [
|
"extensions": [
|
||||||
"ms-python.python",
|
"ms-python.python",
|
||||||
|
@ -31,4 +32,4 @@
|
||||||
"!include_dir_merge_named scalar"
|
"!include_dir_merge_named scalar"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -9,10 +9,6 @@ homeassistant/*.py @home-assistant/core
|
||||||
homeassistant/helpers/* @home-assistant/core
|
homeassistant/helpers/* @home-assistant/core
|
||||||
homeassistant/util/* @home-assistant/core
|
homeassistant/util/* @home-assistant/core
|
||||||
|
|
||||||
# Virtualization
|
|
||||||
Dockerfile @home-assistant/docker
|
|
||||||
virtualization/Docker/* @home-assistant/docker
|
|
||||||
|
|
||||||
# Other code
|
# Other code
|
||||||
homeassistant/scripts/check_config.py @kellerza
|
homeassistant/scripts/check_config.py @kellerza
|
||||||
|
|
||||||
|
|
38
Dockerfile
38
Dockerfile
|
@ -1,38 +0,0 @@
|
||||||
# Notice:
|
|
||||||
# When updating this file, please also update virtualization/Docker/Dockerfile.dev
|
|
||||||
# This way, the development image and the production image are kept in sync.
|
|
||||||
|
|
||||||
FROM python:3.7-buster
|
|
||||||
LABEL maintainer="Paulus Schoutsen <Paulus@PaulusSchoutsen.nl>"
|
|
||||||
|
|
||||||
# Uncomment any of the following lines to disable the installation.
|
|
||||||
#ENV INSTALL_TELLSTICK no
|
|
||||||
#ENV INSTALL_OPENALPR no
|
|
||||||
#ENV INSTALL_FFMPEG no
|
|
||||||
#ENV INSTALL_LIBCEC no
|
|
||||||
#ENV INSTALL_SSOCR no
|
|
||||||
#ENV INSTALL_DLIB no
|
|
||||||
#ENV INSTALL_IPERF3 no
|
|
||||||
#ENV INSTALL_LOCALES no
|
|
||||||
|
|
||||||
VOLUME /config
|
|
||||||
|
|
||||||
WORKDIR /usr/src/app
|
|
||||||
|
|
||||||
# Copy build scripts
|
|
||||||
COPY virtualization/Docker/ virtualization/Docker/
|
|
||||||
RUN virtualization/Docker/setup_docker_prereqs
|
|
||||||
|
|
||||||
# Install hass component dependencies
|
|
||||||
COPY requirements_all.txt requirements_all.txt
|
|
||||||
RUN pip3 install --no-cache-dir -r requirements_all.txt && \
|
|
||||||
pip3 install --no-cache-dir mysqlclient psycopg2 cchardet cython tensorflow
|
|
||||||
|
|
||||||
# Copy source
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
EXPOSE 8123
|
|
||||||
EXPOSE 8300
|
|
||||||
EXPOSE 51827
|
|
||||||
|
|
||||||
CMD [ "python", "-m", "homeassistant", "--config", "/config" ]
|
|
|
@ -16,6 +16,7 @@ RUN apt-get update \
|
||||||
|
|
||||||
WORKDIR /usr/src
|
WORKDIR /usr/src
|
||||||
|
|
||||||
|
# Setup hass-release
|
||||||
RUN git clone --depth 1 https://github.com/home-assistant/hass-release \
|
RUN git clone --depth 1 https://github.com/home-assistant/hass-release \
|
||||||
&& cd hass-release \
|
&& cd hass-release \
|
||||||
&& pip3 install -e .
|
&& pip3 install -e .
|
|
@ -60,7 +60,7 @@ stages:
|
||||||
- script: |
|
- script: |
|
||||||
export TWINE_USERNAME="$(twineUser)"
|
export TWINE_USERNAME="$(twineUser)"
|
||||||
export TWINE_PASSWORD="$(twinePassword)"
|
export TWINE_PASSWORD="$(twinePassword)"
|
||||||
|
|
||||||
twine upload dist/* --skip-existing
|
twine upload dist/* --skip-existing
|
||||||
displayName: 'Upload pypi'
|
displayName: 'Upload pypi'
|
||||||
- job: 'ReleaseDocker'
|
- job: 'ReleaseDocker'
|
||||||
|
@ -150,3 +150,59 @@ stages:
|
||||||
git commit -am "Bump Home Assistant $version"
|
git commit -am "Bump Home Assistant $version"
|
||||||
git push
|
git push
|
||||||
displayName: 'Update version files'
|
displayName: 'Update version files'
|
||||||
|
- job: 'ReleaseDocker'
|
||||||
|
pool:
|
||||||
|
vmImage: 'ubuntu-latest'
|
||||||
|
steps:
|
||||||
|
- script: |
|
||||||
|
set -e
|
||||||
|
export DOCKER_CLI_EXPERIMENTAL=enabled
|
||||||
|
|
||||||
|
function create_manifest() {
|
||||||
|
local tag_l=$1
|
||||||
|
local tag_r=$2
|
||||||
|
|
||||||
|
sudo docker manifest create homeassistant/home-assistant:${tag_l} \
|
||||||
|
homeassistant/amd64-homeassistant:${tag_r} \
|
||||||
|
homeassistant/i386-homeassistant:${tag_r} \
|
||||||
|
homeassistant/armhf-homeassistant:${tag_r} \
|
||||||
|
homeassistant/armv7-homeassistant:${tag_r} \
|
||||||
|
homeassistant/aarch64-homeassistant:${tag_r}
|
||||||
|
|
||||||
|
sudo docker manifest annotate homeassistant/home-assistant:${tag_l} \
|
||||||
|
homeassistant/amd64-homeassistant:${tag_r} \
|
||||||
|
--os linux --arch amd64
|
||||||
|
|
||||||
|
sudo docker manifest annotate homeassistant/home-assistant:${tag_l} \
|
||||||
|
homeassistant/i386-homeassistant:${tag_r} \
|
||||||
|
--os linux --arch i386
|
||||||
|
|
||||||
|
sudo docker manifest annotate homeassistant/home-assistant:${tag_l} \
|
||||||
|
homeassistant/armhf-homeassistant:${tag_r} \
|
||||||
|
--os linux --arch arm --variant=v6
|
||||||
|
|
||||||
|
sudo docker manifest annotate homeassistant/home-assistant:${tag_l} \
|
||||||
|
homeassistant/armv7-homeassistant:${tag_r} \
|
||||||
|
--os linux --arch arm --variant=v7
|
||||||
|
|
||||||
|
sudo docker manifest annotate homeassistant/home-assistant:${tag_l} \
|
||||||
|
homeassistant/aarch64-homeassistant:${tag_r} \
|
||||||
|
--os linux --arch arm64 --variant=v8
|
||||||
|
|
||||||
|
sudo docker manifest push --purge homeassistant/home-assistant:${tag_l}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create version tag
|
||||||
|
create_manifest "$(Build.SourceBranchName)" "$(Build.SourceBranchName)"
|
||||||
|
|
||||||
|
# Create general tags
|
||||||
|
if [[ "$version" =~ d ]]; then
|
||||||
|
create_manifest "dev" "$(Build.SourceBranchName)"
|
||||||
|
elif [[ "$version" =~ b ]]; then
|
||||||
|
create_manifest "beta" "$(Build.SourceBranchName)"
|
||||||
|
else
|
||||||
|
create_manifest "stable" "$(Build.SourceBranchName)"
|
||||||
|
create_manifest "latest" "$(Build.SourceBranchName)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
displayName: 'Create Meta-Image'
|
||||||
|
|
|
@ -15,10 +15,6 @@ homeassistant/*.py @home-assistant/core
|
||||||
homeassistant/helpers/* @home-assistant/core
|
homeassistant/helpers/* @home-assistant/core
|
||||||
homeassistant/util/* @home-assistant/core
|
homeassistant/util/* @home-assistant/core
|
||||||
|
|
||||||
# Virtualization
|
|
||||||
Dockerfile @home-assistant/docker
|
|
||||||
virtualization/Docker/* @home-assistant/docker
|
|
||||||
|
|
||||||
# Other code
|
# Other code
|
||||||
homeassistant/scripts/check_config.py @kellerza
|
homeassistant/scripts/check_config.py @kellerza
|
||||||
|
|
||||||
|
|
|
@ -1,64 +0,0 @@
|
||||||
# Dockerfile for development
|
|
||||||
# Based on the production Dockerfile, but with development additions.
|
|
||||||
# Keep this file as close as possible to the production Dockerfile, so the environments match.
|
|
||||||
|
|
||||||
FROM python:3.7-buster
|
|
||||||
LABEL maintainer="Paulus Schoutsen <Paulus@PaulusSchoutsen.nl>"
|
|
||||||
|
|
||||||
# Uncomment any of the following lines to disable the installation.
|
|
||||||
#ENV INSTALL_TELLSTICK no
|
|
||||||
#ENV INSTALL_OPENALPR no
|
|
||||||
#ENV INSTALL_FFMPEG no
|
|
||||||
#ENV INSTALL_LIBCEC no
|
|
||||||
#ENV INSTALL_COAP no
|
|
||||||
#ENV INSTALL_SSOCR no
|
|
||||||
#ENV INSTALL_DLIB no
|
|
||||||
#ENV INSTALL_IPERF3 no
|
|
||||||
#ENV INSTALL_LOCALES no
|
|
||||||
|
|
||||||
VOLUME /config
|
|
||||||
|
|
||||||
WORKDIR /usr/src/app
|
|
||||||
|
|
||||||
# Copy build scripts
|
|
||||||
COPY virtualization/Docker/ virtualization/Docker/
|
|
||||||
RUN virtualization/Docker/setup_docker_prereqs
|
|
||||||
|
|
||||||
# Install hass component dependencies
|
|
||||||
COPY requirements_all.txt requirements_all.txt
|
|
||||||
|
|
||||||
RUN pip3 install --no-cache-dir -r requirements_all.txt && \
|
|
||||||
pip3 install --no-cache-dir mysqlclient psycopg2 cchardet cython
|
|
||||||
|
|
||||||
# BEGIN: Development additions
|
|
||||||
|
|
||||||
# Install git
|
|
||||||
RUN apt-get update \
|
|
||||||
&& apt-get install -y --no-install-recommends git \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
# Install nodejs
|
|
||||||
RUN curl -sL https://deb.nodesource.com/setup_7.x | bash - && \
|
|
||||||
apt-get install -y nodejs
|
|
||||||
|
|
||||||
# Install tox
|
|
||||||
RUN pip3 install --no-cache-dir tox
|
|
||||||
|
|
||||||
# Copy over everything required to run tox
|
|
||||||
COPY requirements_test_all.txt setup.cfg setup.py tox.ini ./
|
|
||||||
COPY homeassistant/const.py homeassistant/const.py
|
|
||||||
|
|
||||||
# Prefetch dependencies for tox
|
|
||||||
COPY homeassistant/package_constraints.txt homeassistant/package_constraints.txt
|
|
||||||
RUN tox -e py37 --notest
|
|
||||||
|
|
||||||
# END: Development additions
|
|
||||||
|
|
||||||
# Copy source
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
EXPOSE 8123
|
|
||||||
EXPOSE 8300
|
|
||||||
EXPOSE 51827
|
|
||||||
|
|
||||||
CMD [ "python", "-m", "homeassistant", "--config", "/config" ]
|
|
|
@ -1,47 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
# Sets up libcec.
|
|
||||||
# Dependencies that need to be installed:
|
|
||||||
# apt-get install cmake libudev-dev libxrandr-dev swig
|
|
||||||
|
|
||||||
# Stop on errors
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# Load required information about the current python environment
|
|
||||||
PYTHON_LIBDIR=$(python -c 'from distutils import sysconfig; print(sysconfig.get_config_var("LIBDIR"))')
|
|
||||||
PYTHON_LDLIBRARY=$(python -c 'from distutils import sysconfig; print(sysconfig.get_config_var("LDLIBRARY"))')
|
|
||||||
PYTHON_LIBRARY="${PYTHON_LIBDIR}/${PYTHON_LDLIBRARY}"
|
|
||||||
PYTHON_INCLUDE_DIR=$(python -c 'from distutils import sysconfig; print(sysconfig.get_python_inc())')
|
|
||||||
|
|
||||||
cd /usr/src/app/
|
|
||||||
mkdir -p build && cd build
|
|
||||||
|
|
||||||
if [ ! -d libcec ]; then
|
|
||||||
git clone --branch release --depth 1 https://github.com/Pulse-Eight/libcec.git
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd libcec
|
|
||||||
git checkout release
|
|
||||||
git pull
|
|
||||||
git submodule update --init src/platform
|
|
||||||
|
|
||||||
# Build libcec platform libs
|
|
||||||
(
|
|
||||||
mkdir -p src/platform/build
|
|
||||||
cd src/platform/build
|
|
||||||
cmake ..
|
|
||||||
make
|
|
||||||
make install
|
|
||||||
)
|
|
||||||
|
|
||||||
# Build libcec
|
|
||||||
(
|
|
||||||
mkdir -p build && cd build
|
|
||||||
|
|
||||||
cmake \
|
|
||||||
-DPYTHON_LIBRARY="${PYTHON_LIBRARY}" \
|
|
||||||
-DPYTHON_INCLUDE_DIR="${PYTHON_INCLUDE_DIR}" \
|
|
||||||
..
|
|
||||||
make -j$(nproc)
|
|
||||||
make install
|
|
||||||
ldconfig
|
|
||||||
)
|
|
|
@ -1,12 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
# Sets up locales.
|
|
||||||
|
|
||||||
# Stop on errors
|
|
||||||
set -e
|
|
||||||
|
|
||||||
apt-get update
|
|
||||||
apt-get install -y --no-install-recommends locales
|
|
||||||
|
|
||||||
# Set the locale
|
|
||||||
sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen
|
|
||||||
locale-gen
|
|
|
@ -1,32 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
# Sets up openalpr.
|
|
||||||
|
|
||||||
# Stop on errors
|
|
||||||
set -e
|
|
||||||
|
|
||||||
PACKAGES=(
|
|
||||||
# homeassistant.components.image_processing.openalpr_local
|
|
||||||
libopencv-dev libtesseract-dev libleptonica-dev liblog4cplus-dev
|
|
||||||
)
|
|
||||||
|
|
||||||
apt-get install -y --no-install-recommends ${PACKAGES[@]}
|
|
||||||
|
|
||||||
cd /usr/src/app/
|
|
||||||
mkdir -p build && cd build
|
|
||||||
|
|
||||||
# Clone the latest code from GitHub
|
|
||||||
git clone --depth 1 https://github.com/openalpr/openalpr.git openalpr
|
|
||||||
|
|
||||||
# Setup the build directory
|
|
||||||
cd openalpr/src/
|
|
||||||
mkdir -p build
|
|
||||||
cd build
|
|
||||||
|
|
||||||
# Setup the compile environment
|
|
||||||
cmake -DWITH_TESTS=FALSE -DWITH_BINDING_JAVA=FALSE --DWITH_BINDING_PYTHON=FALSE --DWITH_BINDING_GO=FALSE -DWITH_DAEMON=FALSE -DCMAKE_INSTALL_PREFIX:PATH=/usr/local ..
|
|
||||||
|
|
||||||
# compile the library
|
|
||||||
make -j$(nproc)
|
|
||||||
|
|
||||||
# Install the binaries/libraries to your local system (prefix is /usr/local)
|
|
||||||
make install
|
|
|
@ -1,24 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
# Sets up ssocr to support Seven Segments Display.
|
|
||||||
|
|
||||||
# Stop on errors
|
|
||||||
set -e
|
|
||||||
|
|
||||||
PACKAGES=(
|
|
||||||
libimlib2 libimlib2-dev
|
|
||||||
)
|
|
||||||
|
|
||||||
apt-get install -y --no-install-recommends ${PACKAGES[@]}
|
|
||||||
|
|
||||||
cd /usr/src/app/
|
|
||||||
mkdir -p build && cd build
|
|
||||||
|
|
||||||
# Clone the latest code from GitHub
|
|
||||||
git clone --depth 1 https://github.com/auerswal/ssocr.git ssocr
|
|
||||||
cd ssocr/
|
|
||||||
|
|
||||||
# Compile the library
|
|
||||||
make -j$(nproc)
|
|
||||||
|
|
||||||
# Install the binaries/libraries to your local system (prefix is /usr/local)
|
|
||||||
make install
|
|
|
@ -1,17 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
# Sets up tellstick.
|
|
||||||
|
|
||||||
# Stop on errors
|
|
||||||
set -e
|
|
||||||
|
|
||||||
PACKAGES=(
|
|
||||||
# homeassistant.components.tellstick
|
|
||||||
libtelldus-core2 socat
|
|
||||||
)
|
|
||||||
|
|
||||||
# Add Tellstick repository
|
|
||||||
echo "deb http://download.telldus.com/debian/ stable main" >> /etc/apt/sources.list.d/telldus.list
|
|
||||||
wget -qO - http://download.telldus.com/debian/telldus-public.key | apt-key add -
|
|
||||||
|
|
||||||
apt-get update
|
|
||||||
apt-get install -y --no-install-recommends ${PACKAGES[@]}
|
|
|
@ -1,84 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
# Install requirements and build dependencies for Home Assistant in Docker.
|
|
||||||
|
|
||||||
# Stop on errors
|
|
||||||
set -e
|
|
||||||
|
|
||||||
INSTALL_TELLSTICK="${INSTALL_TELLSTICK:-yes}"
|
|
||||||
INSTALL_OPENALPR="${INSTALL_OPENALPR:-yes}"
|
|
||||||
INSTALL_LIBCEC="${INSTALL_LIBCEC:-yes}"
|
|
||||||
INSTALL_SSOCR="${INSTALL_SSOCR:-yes}"
|
|
||||||
INSTALL_DLIB="${INSTALL_DLIB:-yes}"
|
|
||||||
INSTALL_LOCALES="${INSTALL_LOCALES:-yes}"
|
|
||||||
|
|
||||||
# Required debian packages for running hass or components
|
|
||||||
PACKAGES=(
|
|
||||||
# build-essential is required for python pillow module on non-x86_64 arch
|
|
||||||
build-essential
|
|
||||||
# homeassistant.components.image_processing.openalpr_local
|
|
||||||
libxrandr-dev
|
|
||||||
# homeassistant.components.device_tracker.nmap_tracker
|
|
||||||
nmap net-tools libcurl3-dev
|
|
||||||
# homeassistant.components.device_tracker.bluetooth_tracker
|
|
||||||
bluetooth libglib2.0-dev libbluetooth-dev
|
|
||||||
# homeassistant.components.device_tracker.owntracks
|
|
||||||
libsodium23
|
|
||||||
# homeassistant.components.zwave
|
|
||||||
libudev-dev
|
|
||||||
# homeassistant.components.homekit_controller
|
|
||||||
libmpc-dev libmpfr-dev libgmp-dev
|
|
||||||
# homeassistant.components.ffmpeg
|
|
||||||
ffmpeg
|
|
||||||
# homeassistant.components.stream
|
|
||||||
libavformat-dev libavcodec-dev libavdevice-dev
|
|
||||||
libavutil-dev libswscale-dev libswresample-dev libavfilter-dev
|
|
||||||
# homeassistant.components.sensor.iperf3
|
|
||||||
iperf3
|
|
||||||
)
|
|
||||||
|
|
||||||
# Required debian packages for building dependencies
|
|
||||||
PACKAGES_DEV=(
|
|
||||||
cmake
|
|
||||||
git
|
|
||||||
swig
|
|
||||||
)
|
|
||||||
|
|
||||||
# Install packages
|
|
||||||
apt-get update
|
|
||||||
apt-get install -y --no-install-recommends ${PACKAGES[@]} ${PACKAGES_DEV[@]}
|
|
||||||
|
|
||||||
# This is a list of scripts that install additional dependencies. If you only
|
|
||||||
# need to install a package from the official debian repository, just add it
|
|
||||||
# to the list above. Only create a script if you need compiling, manually
|
|
||||||
# downloading or a 3rd party repository.
|
|
||||||
if [ "$INSTALL_TELLSTICK" == "yes" ]; then
|
|
||||||
virtualization/Docker/scripts/tellstick
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$INSTALL_OPENALPR" == "yes" ]; then
|
|
||||||
virtualization/Docker/scripts/openalpr
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$INSTALL_LIBCEC" == "yes" ]; then
|
|
||||||
virtualization/Docker/scripts/libcec
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$INSTALL_SSOCR" == "yes" ]; then
|
|
||||||
virtualization/Docker/scripts/ssocr
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$INSTALL_DLIB" == "yes" ]; then
|
|
||||||
pip3 install --no-cache-dir "dlib>=19.5"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$INSTALL_LOCALES" == "yes" ]; then
|
|
||||||
virtualization/Docker/scripts/locales
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Remove packages
|
|
||||||
apt-get remove -y --purge ${PACKAGES_DEV[@]}
|
|
||||||
apt-get -y --purge autoremove
|
|
||||||
|
|
||||||
# Cleanup
|
|
||||||
apt-get clean
|
|
||||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/src/app/build/
|
|
|
@ -1,24 +0,0 @@
|
||||||
# -*- mode: ruby -*-
|
|
||||||
# vi: set ft=ruby :
|
|
||||||
|
|
||||||
Vagrant.configure(2) do |config|
|
|
||||||
config.vm.box = "debian/contrib-stretch64"
|
|
||||||
config.vm.synced_folder "../../", "/home-assistant"
|
|
||||||
config.vm.synced_folder "./config", "/root/.homeassistant"
|
|
||||||
config.vm.network "forwarded_port", guest: 8123, host: 8123
|
|
||||||
config.vm.provision "fix-no-tty", type: "shell" do |shell|
|
|
||||||
shell.path = "provision.sh"
|
|
||||||
end
|
|
||||||
config.vm.provider :virtualbox do |vb|
|
|
||||||
vb.cpus = 2
|
|
||||||
vb.customize ['modifyvm', :id, '--memory', '1024']
|
|
||||||
end
|
|
||||||
config.vm.provider :hyperv do |h, override|
|
|
||||||
override.vm.box = "generic/debian9"
|
|
||||||
override.vm.hostname = "contrib-stretch"
|
|
||||||
h.vmname = "home-assistant"
|
|
||||||
h.cpus = 2
|
|
||||||
h.memory = 1024
|
|
||||||
h.maxmemory = 1024
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,23 +0,0 @@
|
||||||
# This is a simple service file for systems with systemd to tun HA as user.
|
|
||||||
#
|
|
||||||
# For details please check https://home-assistant.io/getting-started/autostart/
|
|
||||||
#
|
|
||||||
[Unit]
|
|
||||||
Description=Home Assistant for %i
|
|
||||||
After=network.target
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=simple
|
|
||||||
User=%i
|
|
||||||
# Enable the following line if you get network-related HA errors during boot
|
|
||||||
#ExecStartPre=/usr/bin/sleep 60
|
|
||||||
# Use `whereis hass` to determine the path of hass
|
|
||||||
ExecStart=/usr/bin/hass --runner
|
|
||||||
SendSIGKILL=no
|
|
||||||
RestartForceExitStatus=100
|
|
||||||
|
|
||||||
# on vagrant (vboxfs), disable sendfile https://www.virtualbox.org/ticket/9069
|
|
||||||
Environment=AIOHTTP_NOSENDFILE=1
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
|
@ -1,50 +0,0 @@
|
||||||
@echo off
|
|
||||||
call:main %*
|
|
||||||
goto:eof
|
|
||||||
|
|
||||||
:usage
|
|
||||||
echo.############################################################
|
|
||||||
echo.
|
|
||||||
echo.Use `./provision.bat` to interact with HASS. E.g:
|
|
||||||
echo.
|
|
||||||
echo.- setup the environment: `./provision.bat start`
|
|
||||||
echo.- restart HASS process: `./provision.bat restart`
|
|
||||||
echo.- run test suit: `./provision.bat tests`
|
|
||||||
echo.- destroy the host and start anew: `./provision.bat recreate`
|
|
||||||
echo.
|
|
||||||
echo.Official documentation at https://home-assistant.io/docs/installation/vagrant/
|
|
||||||
echo.
|
|
||||||
echo.############################################################'
|
|
||||||
goto:eof
|
|
||||||
|
|
||||||
:main
|
|
||||||
if "%*"=="setup" (
|
|
||||||
if exist setup_done del setup_done
|
|
||||||
vagrant up --provision
|
|
||||||
copy /y nul setup_done
|
|
||||||
) else (
|
|
||||||
if "%*"=="tests" (
|
|
||||||
copy /y nul run_tests
|
|
||||||
vagrant provision
|
|
||||||
) else (
|
|
||||||
if "%*"=="restart" (
|
|
||||||
copy /y nul restart
|
|
||||||
vagrant provision
|
|
||||||
) else (
|
|
||||||
if "%*"=="start" (
|
|
||||||
vagrant up --provision
|
|
||||||
) else (
|
|
||||||
if "%*"=="stop" (
|
|
||||||
vagrant halt
|
|
||||||
) else (
|
|
||||||
if "%*"=="destroy" (
|
|
||||||
vagrant destroy -f
|
|
||||||
) else (
|
|
||||||
if "%*"=="recreate" (
|
|
||||||
if exist setup_done del setup_done
|
|
||||||
if exist restart del restart
|
|
||||||
vagrant destroy -f
|
|
||||||
vagrant up --provision
|
|
||||||
) else (
|
|
||||||
call:usage
|
|
||||||
)))))))
|
|
|
@ -1,121 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
set -e
|
|
||||||
|
|
||||||
readonly SETUP_DONE='/home-assistant/virtualization/vagrant/setup_done'
|
|
||||||
readonly RUN_TESTS='/home-assistant/virtualization/vagrant/run_tests'
|
|
||||||
readonly RESTART='/home-assistant/virtualization/vagrant/restart'
|
|
||||||
|
|
||||||
usage() {
|
|
||||||
echo '############################################################
|
|
||||||
|
|
||||||
Use `./provision.sh` to interact with HASS. E.g:
|
|
||||||
|
|
||||||
- setup the environment: `./provision.sh start`
|
|
||||||
- restart HASS process: `./provision.sh restart`
|
|
||||||
- run test suit: `./provision.sh tests`
|
|
||||||
- destroy the host and start anew: `./provision.sh recreate`
|
|
||||||
|
|
||||||
Official documentation at https://home-assistant.io/docs/installation/vagrant/
|
|
||||||
|
|
||||||
############################################################'
|
|
||||||
}
|
|
||||||
|
|
||||||
print_done() {
|
|
||||||
echo '############################################################
|
|
||||||
|
|
||||||
|
|
||||||
HASS running => http://localhost:8123/
|
|
||||||
|
|
||||||
'
|
|
||||||
}
|
|
||||||
|
|
||||||
setup_error() {
|
|
||||||
echo '############################################################
|
|
||||||
Something is off... maybe setup did not complete properly?
|
|
||||||
Please ensure setup did run correctly at least once.
|
|
||||||
|
|
||||||
To run setup again: `./provision.sh setup`
|
|
||||||
|
|
||||||
############################################################'
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
setup() {
|
|
||||||
local hass_path='/root/venv/bin/hass'
|
|
||||||
local systemd_bin_path='/usr/bin/hass'
|
|
||||||
# Setup systemd
|
|
||||||
cp /home-assistant/virtualization/vagrant/home-assistant@.service \
|
|
||||||
/etc/systemd/system/home-assistant.service
|
|
||||||
systemctl --system daemon-reload
|
|
||||||
systemctl enable home-assistant
|
|
||||||
systemctl stop home-assistant
|
|
||||||
# Install packages
|
|
||||||
apt-get update
|
|
||||||
apt-get install -y git rsync python3-dev python3-pip libssl-dev libffi-dev
|
|
||||||
pip3 install --upgrade virtualenv
|
|
||||||
virtualenv ~/venv
|
|
||||||
source ~/venv/bin/activate
|
|
||||||
pip3 install --upgrade tox
|
|
||||||
/home-assistant/script/setup
|
|
||||||
if ! [ -f $systemd_bin_path ]; then
|
|
||||||
ln -s $hass_path $systemd_bin_path
|
|
||||||
fi
|
|
||||||
touch $SETUP_DONE
|
|
||||||
print_done
|
|
||||||
usage
|
|
||||||
}
|
|
||||||
|
|
||||||
run_tests() {
|
|
||||||
rm -f $RUN_TESTS
|
|
||||||
echo '############################################################'
|
|
||||||
echo; echo "Running test suite, hang on..."; echo; echo
|
|
||||||
if ! systemctl stop home-assistant; then
|
|
||||||
setup_error
|
|
||||||
fi
|
|
||||||
source ~/venv/bin/activate
|
|
||||||
rsync -a --delete \
|
|
||||||
--exclude='*.tox' \
|
|
||||||
--exclude='*.git' \
|
|
||||||
--exclude='.vagrant' \
|
|
||||||
--exclude='lib64' \
|
|
||||||
--exclude='bin/python' \
|
|
||||||
--exclude='bin/python3' \
|
|
||||||
/home-assistant/ /home-assistant-tests/
|
|
||||||
cd /home-assistant-tests && tox || true
|
|
||||||
echo '############################################################'
|
|
||||||
}
|
|
||||||
|
|
||||||
restart() {
|
|
||||||
echo "Restarting Home Assistant..."
|
|
||||||
if ! systemctl restart home-assistant; then
|
|
||||||
setup_error
|
|
||||||
else
|
|
||||||
echo "done"
|
|
||||||
fi
|
|
||||||
rm $RESTART
|
|
||||||
}
|
|
||||||
|
|
||||||
main() {
|
|
||||||
# If a parameter is provided, we assume it's the user interacting
|
|
||||||
# with the provider script...
|
|
||||||
case $1 in
|
|
||||||
"setup") rm -f setup_done; vagrant up --provision && touch setup_done; exit ;;
|
|
||||||
"tests") touch run_tests; vagrant provision ; exit ;;
|
|
||||||
"restart") touch restart; vagrant provision ; exit ;;
|
|
||||||
"start") vagrant up --provision ; exit ;;
|
|
||||||
"stop") vagrant halt ; exit ;;
|
|
||||||
"destroy") vagrant destroy -f ; exit ;;
|
|
||||||
"recreate") rm -f setup_done restart; vagrant destroy -f; \
|
|
||||||
vagrant up --provision; exit ;;
|
|
||||||
esac
|
|
||||||
# ...otherwise we assume it's the Vagrant provisioner
|
|
||||||
if [ $(hostname) != "contrib-jessie" ] && [ $(hostname) != "contrib-stretch" ]; then usage; exit; fi
|
|
||||||
if ! [ -f $SETUP_DONE ]; then setup; fi
|
|
||||||
if [ -f $RESTART ]; then restart; fi
|
|
||||||
if [ -f $RUN_TESTS ]; then run_tests; fi
|
|
||||||
if ! systemctl start home-assistant; then
|
|
||||||
setup_error
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
main $*
|
|
Loading…
Reference in New Issue