Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
3149131
initial hass.io support
fredrike Jun 30, 2019
e204d60
better start-stop script
fredrike Jul 1, 2019
4b516bd
fixed daemon version
fredrike Jul 1, 2019
df7dc0c
version bump
fredrike Jul 4, 2019
e797b68
only supports x64 arch
fredrike Jul 4, 2019
8f31d5a
fix newline
fredrike Jul 4, 2019
4e52c6e
updated install_ui
fredrike Jul 9, 2019
d00caa4
new install UI
fredrike Jul 9, 2019
3a23285
add docker stop to stop script
fredrike Jul 20, 2019
f262cc0
remove hassio network at uninstall too
fredrike Jul 23, 2019
d1b1997
fixes for @ymartin59
fredrike Jul 31, 2019
46e4571
service_preupgrade
fredrike Aug 1, 2019
e23d602
add fix_usb_devices
fredrike Aug 1, 2019
eb505bb
lint fixes
fredrike Aug 1, 2019
f5c97b7
fix usb_devices function
fredrike Aug 2, 2019
337ede0
fix uninstall (so new installs will work)
fredrike Aug 2, 2019
008c358
fix upgrade
fredrike Aug 2, 2019
7b9dbcc
more upgrade fixes
fredrike Aug 2, 2019
6295fc0
fix stupid typo
fredrike Aug 3, 2019
94f8c69
minor fixes in usb_devices
fredrike Aug 3, 2019
925f2a3
working updating version
fredrike Aug 4, 2019
fbdbec6
don't overwrite config-file (untested)
fredrike Aug 4, 2019
dd401dd
rev is git commit hash
fredrike Aug 4, 2019
d57bdf8
add remove addons option during uninstall
fredrike Aug 4, 2019
63550c4
more upgrade fixes
fredrike Aug 5, 2019
6dd0666
exprimental fix for usb.rules
fredrike Aug 13, 2019
89590ec
fix devices and remove hassio-dns container when uninstalling
fredrike Oct 4, 2019
3c5c9bc
make sure we are running a working Docker version
fredrike Oct 6, 2019
ca5bddc
fix variables
fredrike Oct 10, 2019
2269c99
remove dependency of busybox
fredrike Oct 10, 2019
d67e38b
fixes for @ymartin59
fredrike Jan 13, 2020
7127120
fix erroneous space
fredrike Jan 13, 2020
6209e1a
remove hassio_dns image and conditionally hass
fredrike Jan 13, 2020
7abccb3
port 8123 conflicts with homeassistant
fredrike Jan 13, 2020
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
48 changes: 48 additions & 0 deletions spk/hassio/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
SPK_NAME = hassio
SPK_VERS = $(shell date +%Y%m%d)
SPK_REV = 1
SPK_ICON = src/$(SPK_NAME).png
SPK_DEPENDS = Docker
DSM_UI_DIR = app

DEPENDS = cross/busybox

MAINTAINER = fredrike+hassio@gmail.com
DESCRIPTION = Open source home automation that puts local control and privacy first. Powered by a worldwide community of tinkerers and DIY enthusiasts.
ADMIN_PORT = 8123
RELOAD_UI = yes
STARTABLE = yes
DISPLAY_NAME = Hass.io
CHANGELOG = ""

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
BETA = 1

UNSUPPORTED_ARCHS = $(ARM_ARCHES) $(PPC_ARCHES) $(x86_ARCHES)

HOMEPAGE = https://www.home-assistant.io/hassio/
LICENSE = Apache License 2.0
HELPURL = https://www.home-assistant.io/docs/

WIZARDS_DIR = src/wizard/

SERVICE_SETUP = src/service-setup.sh
SSS_SCRIPT = src/start-stop-status
FWPORTS = src/${SPK_NAME}.sc
SERVICE_PORT_TITLE = $(DISPLAY_NAME)

INSTALL_DEP_SERVICES = Docker
START_DEP_SERVICES = Docker

POST_STRIP_TARGET = hassio_extra_install

BUSYBOX_CONFIG = daemon nice
ENV += BUSYBOX_CONFIG="$(BUSYBOX_CONFIG)"

include ../../mk/spksrc.spk.mk

.PHONY: hassio_extra_install
hassio_extra_install:
install -m 755 -d $(STAGING_DIR)/bin
install -m 755 src/hassio.sh $(STAGING_DIR)/bin/
install -m 755 -d $(STAGING_DIR)/var
install -m 644 src/hassio.json $(STAGING_DIR)/var/hassio.json
install -m 755 -d $(STAGING_DIR)/app
install -m 644 src/app/config $(STAGING_DIR)/app/config
Empty file added spk/hassio/PLIST
Empty file.
15 changes: 15 additions & 0 deletions spk/hassio/src/app/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
".url": {
"com.synocommunity.packages.hassio": {
"title": "Hass.io",
"desc": "Hass.io",
"icon": "images/hassio-{0}.png",
"type": "url",
"protocol": "http",
"port": "8123",
"url": "/",
"allUsers": true,
"grantPrivilege": "local"
}
}
}
3 changes: 3 additions & 0 deletions spk/hassio/src/config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[General]
launch_browser = 1
web_port = 8123
5 changes: 5 additions & 0 deletions spk/hassio/src/hassio.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"supervisor": "@supervisor@",
"homeassistant": "@homeassistant@",
"data": "@data_dir@"
}
Binary file added spk/hassio/src/hassio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions spk/hassio/src/hassio.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[hass.io]
title="Hass.io"
desc="HomeAssistant"
port_forward="yes"
dst.ports="8123/tcp"

42 changes: 42 additions & 0 deletions spk/hassio/src/hassio.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh

CONFIG_FILE="/var/packages/hassio/target/var/hassio.json"

runSupervisor() {
HOMEASSISTANT="$(jq --raw-output '.homeassistant' ${CONFIG_FILE})"
HASSIO_DATA="$(jq --raw-output '.data // "/usr/share/hassio"' ${CONFIG_FILE})"

APPARMOR="--security-opt apparmor=unconfined"

/usr/local/bin/docker rm --force hassio_supervisor > /dev/null || true
/usr/local/bin/docker run --name hassio_supervisor \
--privileged \
$APPARMOR \
--security-opt seccomp=unconfined \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /var/run/dbus:/var/run/dbus \
-v ${HASSIO_DATA}:/data \
-e SUPERVISOR_SHARE=${HASSIO_DATA} \
-e SUPERVISOR_NAME=hassio_supervisor \
-e HOMEASSISTANT_REPOSITORY=${HOMEASSISTANT} \
${SUPERVISOR}
}

start_hassio () {
SUPERVISOR="$(jq --raw-output '.supervisor' ${CONFIG_FILE})"

HASSIO_IMAGE_ID=$(/usr/local/bin/docker inspect --format='{{.Id}}' ${SUPERVISOR})
HASSIO_CONTAINER_ID=$(/usr/local/bin/docker inspect --format='{{.Image}}' hassio_supervisor || echo "--")

# Fix routing
route -vn |grep 172.30.32.0 >/dev/null || \
route add -net 172.30.32.0/23 gw 172.30.32.1

# Run supervisor
([ "${HASSIO_IMAGE_ID}" = "${HASSIO_CONTAINER_ID}" ] && /usr/local/bin/docker start --attach hassio_supervisor) || runSupervisor
}

while true; do
start_hassio
sleep 1
done
44 changes: 44 additions & 0 deletions spk/hassio/src/service-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
CFG_FILE="${SYNOPKG_PKGDEST}/var/hassio.json"

service_preinst ()
{
exit 0
}

service_postinst ()
{
DATA_DIR="${share_path}/${folder_name}"

URL_VERSION="https://s3.amazonaws.com/hassio-version/stable.json"

HOMEASSISTANT_DOCKER="homeassistant/qemux86-64-homeassistant"
HASSIO_DOCKER="homeassistant/amd64-hassio-supervisor"

# Read infos from web
HASSIO_VERSION=$(curl -s $URL_VERSION | jq -e -r '.supervisor')

# Pull supervisor image
/usr/local/bin/docker pull "$HASSIO_DOCKER:$HASSIO_VERSION" > /dev/null
/usr/local/bin/docker tag "$HASSIO_DOCKER:$HASSIO_VERSION" "$HASSIO_DOCKER:latest" > /dev/null

# Write config
sed -i -e "s|@supervisor@|${HASSIO_DOCKER}|g" ${CFG_FILE}
sed -i -e "s|@homeassistant@|${HOMEASSISTANT_DOCKER}|g" ${CFG_FILE}
sed -i -e "s|@data_dir@|${DATA_DIR}|g" ${CFG_FILE}

# Install busybox stuff
ln -s busybox ${SYNOPKG_PKGDEST}/bin/start-stop-daemon

# Fix install directory
mkdir -p "${DATA_DIR}"
}

service_preuninst ()
{
HOMEASSISTANT="$(jq --raw-output '.homeassistant' ${CONFIG_FILE})"
SUPERVISOR="$(jq --raw-output '.supervisor' ${CONFIG_FILE})"

docker rm --force homeassistant hassio_supervisor
docker image rm ${HOMEASSISTANT} ${SUPERVISOR}
docker network rm hassio
}
76 changes: 76 additions & 0 deletions spk/hassio/src/start-stop-status
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/bin/sh

# Package
PACKAGE="hassio"
DNAME="hass.io"

# Others
INSTALL_DIR="/var/packages/${PACKAGE}/target"
PATH="${INSTALL_DIR}/bin:${PATH}"
USER="root"
EXEC="${INSTALL_DIR}/bin/${PACKAGE}.sh"
PID_FILE="${INSTALL_DIR}/var/${PACKAGE}.pid"

start_daemon ()
{
start-stop-daemon -S -q -m -b -x ${EXEC} -c ${USER} -u ${USER} -p ${PID_FILE} > /dev/null
}

stop_daemon ()
{
start-stop-daemon -K -q -u ${USER} -p ${PID_FILE}
wait_for_status 1 20 || start-stop-daemon -K -s 9 -q -p ${PID_FILE}
docker stop hassio_supervisor homeassistant
}

daemon_status ()
{
start-stop-daemon -K -q -t -u ${USER} -p ${PID_FILE}
}

wait_for_status ()
{
counter=$2
while [ ${counter} -gt 0 ]; do
daemon_status
[ $? -eq $1 ] && return
let counter=counter-1
sleep 1
done
return 1
}


case $1 in
start)
if daemon_status; then
echo ${DNAME} is already running
else
echo Starting ${DNAME} ...
start_daemon
fi
;;
stop)
if daemon_status; then
echo Stopping ${DNAME} ...
stop_daemon
else
echo ${DNAME} is not running
fi
;;
status)
if daemon_status; then
echo ${DNAME} is running
exit 0
else
echo ${DNAME} is not running
exit 1
fi
;;
log)
exit 1
;;
*)
exit 1
;;
esac
48 changes: 48 additions & 0 deletions spk/hassio/src/wizard/install_uifile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/sh
set +x

GetShares()
{
for share in `sudo /usr/syno/sbin/synoshare --enum ALL|tail -n +3`; do
path=$(sudo /usr/syno/sbin/synoshare --get "${share}"|sed -n 's/.*Path.*\[\(.*\)\]/\1/p')
echo "[\"$path\", \"$share (${path})\"]"
done | tr -s '\n' ',' | sed -e 's/,$//'
}


FIRST=`/bin/cat<<EOF
{
"step_title": "Data location",
"items": [{
"desc": "The installer will download and build the latest versions of hass.io and homeassistant. <br/>Please fill the desired storage location for the data directory below (create a new <b>Shared Folder</b> if none of the ones below suits storage of hass.io data)."
},{
"type": "combobox",
"subitems": [{
"key": "share_path",
"desc": "Shared Folder to store hass.io data in",
"editable": false,
"mode": "local",
"value": "",
"valueField": "path",
"displayField": "display_name",
"store": {
"xtype": "arraystore",
"fields": ["path", "display_name"],
"data": [$(GetShares)]
}
}]
}, {
"type": "textfield",
"subitems": [{
"key": "folder_name",
"desc": "Data folder name",
"value": "hass.io",
"disabled": false
}]
}]
}
EOF`

echo "[$FIRST]" > $SYNOPKG_TEMP_LOGFILE

exit 0