Browse Source

Initial commit.

main
Atridad Lahiji 2 months ago
parent
commit
886239cdb1
  1. 2
      CHANGELOG
  2. 35
      CloudronManifest.json
  3. 1
      DESCRIPTION.md
  4. 17
      Dockerfile
  5. 1
      POSTINSTALL.md
  6. 25
      README.md
  7. 7
      build.sh
  8. 3
      fix_default_conf.sh
  9. BIN
      logo.png
  10. 71
      root.py
  11. 16
      start.sh

2
CHANGELOG

@ -0,0 +1,2 @@
[0.1.0]
* Initial version

35
CloudronManifest.json

@ -0,0 +1,35 @@
{
"id": "org.homeassistant.cloudronapp",
"title": "Home Assistant",
"author": "Home Assistant Developers",
"description": "file://DESCRIPTION.md",
"tagline": "Open source home automation that puts local control and privacy first.",
"version": "0.1.0",
"healthCheckPath": "/auth/authorize",
"httpPort": 8123,
"manifestVersion": 2,
"website": "https://home-assistant.io",
"contactEmail": "atri.lahiji@lahijiapps.dev",
"icon": "logo.png",
"memoryLimit": 262144000,
"tcpPorts": {
"HASS_Bridge": {
"title": "HASS Bridge",
"description": "Port for HASS Bridge",
"defaultValue": 21063,
"containerPort": 21063
}
},
"addons": {
"localstorage": {}
},
"tags": [ "python", "iot" ],
"changelog": "file://CHANGELOG",
"postInstallMessage": "file://POSTINSTALL.md",
"mediaLinks": [
],
"minBoxVersion": "5.3.0",
"forumUrl": "https://forum.cloudron.io/category/102/homeassistant",
"documentationUrl": "https://docs.cloudron.io/apps/homeassistant/"
}

1
DESCRIPTION.md

@ -0,0 +1 @@
Home Assistant is an Open source home automation that puts local control and privacy first.

17
Dockerfile

@ -0,0 +1,17 @@
FROM cloudron/base:3.0.0@sha256:455c70428723e3a823198c57472785437eb6eab082e79b3ff04ea584faf46e92
RUN mkdir -p /app/code /app/data /app/data/dhcpconf
WORKDIR /app/code
# ffmpeg required
RUN apt-get -y update && \
apt-get update && \
apt install -y python3 python3-dev python3-venv python3-pip libffi-dev libssl-dev libjpeg-dev zlib1g-dev autoconf build-essential libopenjp2-7 libtiff5 tzdata
# copy start script
ADD start.sh build.sh root.py fix_default_conf.sh /app/code/
RUN /bin/bash /app/code/build.sh
RUN chmod +x /app/code/fix_default_conf.sh
CMD [ "/app/code/start.sh" ]

1
POSTINSTALL.md

@ -0,0 +1 @@
RUN THE DEFAULT CONFIG SCRIPT

25
README.md

@ -1,2 +1,25 @@
# cloudron-homeassistant-app
# Home Assistant Cloudron App
This repository contains the Cloudron app package source for Home Assistant, a self-hosted open source home automation that puts local control and privacy first.
Repo: https://github.com/homeassistant/core
## Installation
[![Install](https://cloudron.io/img/button.svg)](https://cloudron.io/button.html?app=org.homeassistant.cloudronapp)
or using the [Cloudron command line tooling](https://cloudron.io/references/cli.html)
```
cloudron install --appstore-id homeassistant.cloudronapp
```
## Building
The app package can be built using the [Cloudron command line tooling](https://cloudron.io/references/cli.html).
```
cd homeassistant-app
cloudron build
cloudron install
```

7
build.sh

@ -0,0 +1,7 @@
#!/bin/bash
cd /app/data
virtualenv -p /usr/bin/python3.8 hass
source /app/data/hass/bin/activate
pip3 install wheel
pip3 install homeassistant==2021.6.0
# python3 /app/data/hass/lib/python3.8/site-packages/homeassistant/setup.py

3
fix_default_conf.sh

@ -0,0 +1,3 @@
#!/bin/bash
rm /app/data/hass/lib/python3.8/site-packages/async_dns/core/config/root.py
cp /app/code/root.py /app/data/hass/lib/python3.8/site-packages/async_dns/core/config/root.py

BIN
logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 KiB

71
root.py

@ -0,0 +1,71 @@
'''
Cache module.
'''
import os
import json
from .. import logger, types, Record
__all__ = [
'core_config',
'get_name_cache',
'get_root_servers',
]
CONFIG_DIR = '/app/data/dhcpconf'
CACHE_FILE = os.path.join(CONFIG_DIR, 'named.cache.txt')
try:
user_config = json.load(open(os.path.join(CONFIG_DIR, 'config.json')))
except:
user_config = None
core_config = {
'default_nameservers': [
'8.8.8.8',
'8.8.4.4',
],
}
if user_config is not None:
core_config.update(user_config)
del user_config
def get_nameservers():
return []
def get_name_cache(
url='ftp://rs.internic.net/domain/named.cache',
filename=CACHE_FILE, timeout=10):
'''
Download root nameservers and save cache.
'''
from urllib import request
logger.info('Fetching named.cache...')
try:
res = request.urlopen(url, timeout=timeout)
except:
logger.warning('Error fetching named.cache')
else:
open(filename, 'wb').write(res.read())
def get_root_servers(filename=CACHE_FILE):
'''
Load root servers from cache.
'''
if not os.path.isfile(filename):
get_name_cache(filename=filename)
# in case failed fetching named.cache
if not os.path.isfile(filename):
return
for line in open(filename, 'r'):
if line.startswith(';'):
continue
parts = line.lower().split()
if len(parts) < 4:
continue
yield Record(
name=parts[0].rstrip('.'), # name
# parts[1] (expires) is ignored
qtype=types.get_code(parts[2], 0), # qtype
data=parts[3].rstrip('.'), # data
ttl=-1,
)

16
start.sh

@ -0,0 +1,16 @@
#!/bin/bash
set -eu
# ensure that data directory is owned by 'cloudron' user
chown -R cloudron:cloudron /app/data
echo "==> Starting Home Assistant"
cd /app/data
source /app/data/hass/bin/activate
if [[ ! -f /app/data/.initialized ]]; then
echo "==> Fresh installation, performing first time setup"
( sleep 60 ; /app/code/fix_default_conf.sh & touch /app/data/.initialized ) &
fi
exec /usr/local/bin/gosu cloudron:cloudron hass --config /app/data
Loading…
Cancel
Save