├── base ├── etc │ └── avahi │ │ └── avahi-daemon.conf ├── homeseer │ ├── shutdown.sh │ ├── shutdown_controller.sh │ └── restart.sh ├── usr │ └── local │ │ └── sbin │ │ ├── shutdown │ │ ├── poweroff │ │ ├── reboot │ │ └── homeseer ├── clean.sh ├── build.sh └── Dockerfile ├── .gitattributes ├── .gitignore ├── run.sh ├── Dockerfile ├── docker-compose.yml ├── clean.sh └── README.md /base/etc/avahi/avahi-daemon.conf: -------------------------------------------------------------------------------- 1 | [server] 2 | #host-name= 3 | use-ipv4=yes 4 | use-ipv6=yes 5 | enable-dbus=yes 6 | ratelimit-interval-usec=1000000 7 | ratelimit-burst=1000 8 | 9 | [wide-area] 10 | enable-wide-area=yes 11 | 12 | [rlimits] 13 | rlimit-core=0 14 | rlimit-data=4194304 15 | rlimit-fsize=0 16 | rlimit-nofile=768 17 | rlimit-stack=4194304 -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set the default behavior, in case people don't have core.autocrlf set. 2 | * text eol=lf 3 | 4 | # Explicitly declare text files you want to always be normalized and converted 5 | # to native line endings on checkout. 6 | *.c text eol=lf 7 | *.h text eol=lf 8 | *.sh text eol=lf 9 | *.md text eol=lf 10 | *.conf text eol=lf 11 | 12 | 13 | -------------------------------------------------------------------------------- /base/homeseer/shutdown.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | ############################################ 4 | # HOMESEER (V4) LINUX - SHUTDOWN SCRIPT 5 | ############################################ 6 | 7 | echo 8 | echo "**********************************************************************" 9 | echo " HOMESEER CONTAINER - SHUTDOWN" 10 | echo "**********************************************************************" 11 | echo 12 | 13 | -------------------------------------------------------------------------------- /base/usr/local/sbin/shutdown: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | ############################################ 4 | # HOMESEER (V4) LINUX - SHUTDOWN SCRIPT 5 | ############################################ 6 | 7 | echo 8 | echo "**********************************************************************" 9 | echo " HOMESEER CONTAINER - SYSTEM SHUTDOWN" 10 | echo "**********************************************************************" 11 | echo 12 | 13 | -------------------------------------------------------------------------------- /base/usr/local/sbin/poweroff: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | ############################################ 4 | # HOMESEER (V4) LINUX - POWEROFF SCRIPT 5 | ############################################ 6 | 7 | echo 8 | echo "**********************************************************************" 9 | echo " HOMESEER CONTAINER - SYSTEM POWER OFF" 10 | echo "**********************************************************************" 11 | echo 12 | 13 | -------------------------------------------------------------------------------- /base/homeseer/shutdown_controller.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | ############################################ 4 | # HOMESEER (V4) LINUX - SHUTDOWN SCRIPT 5 | ############################################ 6 | 7 | echo 8 | echo "**********************************************************************" 9 | echo " HOMESEER CONTAINER - SHUTDOWN CONTROLLER" 10 | echo "**********************************************************************" 11 | echo 12 | 13 | -------------------------------------------------------------------------------- /base/homeseer/restart.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | ############################################ 4 | # HOMESEER (V4) LINUX - RESTART SCRIPT 5 | ############################################ 6 | 7 | echo 8 | echo "**********************************************************************" 9 | echo " HOMESEER CONTAINER - RESTART" 10 | echo "**********************************************************************" 11 | echo 12 | touch /homeseer-restart 13 | 14 | -------------------------------------------------------------------------------- /base/usr/local/sbin/reboot: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | ############################################ 4 | # HOMESEER (V4) LINUX - REBOOT SCRIPT 5 | ############################################ 6 | 7 | echo 8 | echo "**********************************************************************" 9 | echo " HOMESEER CONTAINER - SYSTEM REBOOT" 10 | echo "**********************************************************************" 11 | echo 12 | touch /homeseer-restart 13 | 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled source # 2 | ################### 3 | *.com 4 | *.class 5 | *.dll 6 | *.exe 7 | *.o 8 | *.so 9 | 10 | # Packages # 11 | ############ 12 | # it's better to unpack these files and commit the raw source 13 | # git has its own built in compression methods 14 | *.7z 15 | *.dmg 16 | *.gz 17 | *.iso 18 | *.jar 19 | *.rar 20 | *.tar 21 | *.zip 22 | 23 | # Logs and databases # 24 | ###################### 25 | *.log 26 | *.sql 27 | *.sqlite 28 | 29 | # OS generated files # 30 | ###################### 31 | .DS_Store 32 | .DS_Store? 33 | ._* 34 | .Spotlight-V100 35 | .Trashes 36 | ehthumbs.db 37 | Thumbs.db 38 | 39 | 40 | # IDE generated files # 41 | ###################### 42 | .idea/ 43 | out/ 44 | .idea_modules/ 45 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | ############################################## 4 | # HOMESEER (V4) LINUX - DOCKER RUN CONTAINER 5 | ############################################## 6 | docker run \ 7 | --interactive \ 8 | --tty \ 9 | --name homeseer \ 10 | --volume /etc/homeseer:/homeseer \ 11 | --publish 80:80 \ 12 | --publish 10200:10200 \ 13 | --publish 10300:10300 \ 14 | --publish 10401:10401 \ 15 | --publish 11000:11000 \ 16 | --env TZ=America/New_York \ 17 | --env LANG=en_US.UTF-8 \ 18 | --env HOMESEER_CREDENTIALS="default:default" \ 19 | homeseer/homeseer:latest $@ 20 | 21 | # PUBLISHED IP PORTS 22 | # ------------------------- 23 | # 80 : HTTP/WEB 24 | # 10200 : HS-TOUCH 25 | # 10300 : myHS 26 | # 10401 : SPEAKER CLIENTS 27 | # 11000 : ASCII/JSON REMOTE API 28 | 29 | # OTHER COMMON OPTIONS 30 | # ------------------------- 31 | # --detach 32 | # --restart always 33 | # --device /dev/ttyUSB0 34 | # --device /dev/ttyUSB1 35 | # --device /dev/ttyACM0 36 | # --volume /etc/localtime:/etc/localtime:ro 37 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | ######################################### 2 | # HOMESEER (V4) LINUX - DOCKERFILE 3 | ######################################### 4 | FROM homeseer/base:latest 5 | ARG TARGETARCH 6 | ARG BUILDDATE 7 | ARG VERSION 8 | ARG DOWNLOAD 9 | ARG DEBIAN_FRONTEND=noninteractive 10 | 11 | # docker container image labels 12 | LABEL org.label-schema.schema-version="1.0" 13 | LABEL org.label-schema.build-date=$BUILDDATE 14 | LABEL org.label-schema.name="homeseer/homeseer" 15 | LABEL org.label-schema.description="HomeSeer Docker Image" 16 | LABEL org.label-schema.url="https://homseer.sh/" 17 | LABEL org.label-schema.vcs-url="https://github.com/HomeSeerLinux/docker" 18 | LABEL org.label-schema.vendor="Homeseer.sh" 19 | LABEL org.label-schema.version=$VERSION 20 | 21 | RUN echo "=========================================================" 22 | RUN echo " BUILDING DOCKER HOMESEER ($VERSION) IMAGE FOR: $TARGETARCH" 23 | RUN echo "=========================================================" 24 | 25 | # configure build time environment variables 26 | ENV HOMESEER_VERSION="$VERSION" 27 | 28 | # download appropriate version of HomeSeer Linux 29 | RUN wget -O /homeseer.tar.gz "$DOWNLOAD" 30 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------- 2 | # HOMESEER LINUX SERVER 3 | # -------------------------------------------------- 4 | # This container hosts the HomeSeer V4 server. 5 | # This config will create standalone 'homeseer-data' 6 | # docker volume to store all homeseer runtime 7 | # files. (logs, config, backups, app files) 8 | # 9 | # Disclaimers: 10 | # -------------- 11 | # This docker container is not supported, sponsored 12 | # or directly affiliated with Homeseer 13 | # (https://homeseer.com). 14 | # 15 | # -------------------------------------------------- 16 | # (Developed with ♥ by SavageSoftware, LLC.) 17 | # -------------------------------------------------- 18 | version: '3.8' 19 | 20 | volumes: 21 | homeseer-data: 22 | name: homeseer-data 23 | 24 | services: 25 | homeseer: 26 | container_name: homeseer 27 | image: homeseer/homeseer:latest 28 | hostname: homeseer 29 | restart: unless-stopped 30 | network_mode: bridge 31 | ports: 32 | - 80:80 33 | - 10200:10200 34 | - 10300:10300 35 | - 10401:10401 36 | - 11000:11000 37 | environment: 38 | TZ: America/New_York 39 | LANG: en_US.UTF-8 40 | volumes: 41 | - homeseer-data:/homeseer 42 | -------------------------------------------------------------------------------- /clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | ############################################ 3 | # HOMESEER (V4) LINUX - DOCKER BUILD SCRIPT 4 | ############################################ 5 | 6 | #----------------------------------------------------------------------------------------- 7 | # !! THIS DOCKER BUILD REQUIRES THE EXPERIMENTAL DOCKER BUILDX PLUGIN !! 8 | #----------------------------------------------------------------------------------------- 9 | # 10 | # REF: https://docs.docker.com/buildx/working-with-buildx/ 11 | # 12 | # Docker Buildx is a CLI plugin that extends the docker command with the 13 | # full support of the features provided by Moby BuildKit builder toolkit. 14 | # It provides the same user experience as docker build with many new 15 | # features like creating scoped builder instances and building against 16 | # multiple nodes concurrently. 17 | # 18 | # This is an experimental feature. 19 | # 20 | # Experimental features provide early access to future product functionality. 21 | # These features are intended for testing and feedback only as they may change 22 | # between releases without warning or can be removed entirely from a future 23 | # release. Experimental features must not be used in production environments. 24 | # Docker does not offer support for experimental features. 25 | # 26 | #----------------------------------------------------------------------------------------- 27 | 28 | echo 29 | echo "**********************************************************************" 30 | echo "* CLEANING HOMESEER DOCKER IMAGES *" 31 | echo "**********************************************************************" 32 | echo 33 | 34 | # remove the builder instance 35 | docker buildx rm homeseer-builder || true 36 | 37 | # remove any containers from local Docker registry 38 | docker images -a | grep "homeseer/homeseer" | awk '{print $3}' | xargs docker rmi -------------------------------------------------------------------------------- /base/clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | ############################################ 3 | # HOMESEER (V4) LINUX - DOCKER BUILD SCRIPT 4 | ############################################ 5 | 6 | #----------------------------------------------------------------------------------------- 7 | # !! THIS DOCKER BUILD REQUIRES THE EXPERIMENTAL DOCKER BUILDX PLUGIN !! 8 | #----------------------------------------------------------------------------------------- 9 | # 10 | # REF: https://docs.docker.com/buildx/working-with-buildx/ 11 | # 12 | # Docker Buildx is a CLI plugin that extends the docker command with the 13 | # full support of the features provided by Moby BuildKit builder toolkit. 14 | # It provides the same user experience as docker build with many new 15 | # features like creating scoped builder instances and building against 16 | # multiple nodes concurrently. 17 | # 18 | # This is an experimental feature. 19 | # 20 | # Experimental features provide early access to future product functionality. 21 | # These features are intended for testing and feedback only as they may change 22 | # between releases without warning or can be removed entirely from a future 23 | # release. Experimental features must not be used in production environments. 24 | # Docker does not offer support for experimental features. 25 | # 26 | #----------------------------------------------------------------------------------------- 27 | 28 | echo 29 | echo "**********************************************************************" 30 | echo "* CLEANING HOMESEER DOCKER IMAGES *" 31 | echo "**********************************************************************" 32 | echo 33 | 34 | # remove the builder instance 35 | docker buildx rm homeseer-builder || true 36 | 37 | # remove any containers from local Docker registry 38 | docker images -a | grep "homeseer/base" | awk '{print $3}' | xargs docker rmi -------------------------------------------------------------------------------- /base/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | ############################################ 4 | # HOMESEER (V4) LINUX - DOCKER BUILD SCRIPT 5 | ############################################ 6 | 7 | #----------------------------------------------------------------------------------------- 8 | # !! THIS DOCKER BUILD REQUIRES THE EXPERIMENTAL DOCKER BUILDX PLUGIN !! 9 | #----------------------------------------------------------------------------------------- 10 | # 11 | # REF: https://docs.docker.com/buildx/working-with-buildx/ 12 | # 13 | # Docker Buildx is a CLI plugin that extends the docker command with the 14 | # full support of the features provided by Moby BuildKit builder toolkit. 15 | # It provides the same user experience as docker build with many new 16 | # features like creating scoped builder instances and building against 17 | # multiple nodes concurrently. 18 | # 19 | # This is an experimental feature. 20 | # 21 | # Experimental features provide early access to future product functionality. 22 | # These features are intended for testing and feedback only as they may change 23 | # between releases without warning or can be removed entirely from a future 24 | # release. Experimental features must not be used in production environments. 25 | # Docker does not offer support for experimental features. 26 | # 27 | #----------------------------------------------------------------------------------------- 28 | 29 | # docker image version 30 | VERSION="4.0" 31 | 32 | echo 33 | echo "**********************************************************************" 34 | echo "* BUILDING HOMESEER LINUX BASE DOCKER IMAGE *" 35 | echo "**********************************************************************" 36 | echo 37 | 38 | # use buildx to create a new builder instance; if needed 39 | docker buildx create --driver-opt env.BUILDKIT_STEP_LOG_MAX_SIZE=10485760 \ 40 | --driver-opt env.BUILDKIT_STEP_LOG_MAX_SPEED=100000000 \ 41 | --use --name homseer-builder || true; 42 | 43 | # perform multi-arch platform image builds; push the resulting image to the HomeSeer.sh DockerHub repository 44 | # (https://hub.docker.com/r/homeseer/homeseer) 45 | docker buildx build \ 46 | --build-arg BUILDDATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ 47 | --build-arg VERSION="$VERSION" \ 48 | --platform linux/amd64,linux/arm64 \ 49 | --tag homeseer/base:$VERSION \ 50 | --tag homeseer/base:latest \ 51 | . $@ 52 | -------------------------------------------------------------------------------- /base/Dockerfile: -------------------------------------------------------------------------------- 1 | ######################################### 2 | # HOMESEER (V4) LINUX - DOCKERFILE 3 | ######################################### 4 | FROM mono:6.12.0 5 | 6 | # build arguments 7 | ARG TARGETARCH 8 | ARG BUILDDATE 9 | ARG VERSION 10 | ARG DEBIAN_FRONTEND=noninteractive 11 | 12 | # custom STOP signal for 'docker stop' 13 | STOPSIGNAL SIGQUIT 14 | 15 | # environment variables 16 | ENV LANG en_US.UTF-8 17 | ENV TZ "America/New_York" 18 | ENV HOMESEER_FOLDER "/homeseer" 19 | ENV HOMESEER_CREDENTAILS "" 20 | 21 | # docker container image labels 22 | LABEL org.label-schema.schema-version="1.0" 23 | LABEL org.label-schema.build-date=$BUILDDATE 24 | LABEL org.label-schema.name="homeseer/base" 25 | LABEL org.label-schema.description="HomeSeer Base Docker Image" 26 | LABEL org.label-schema.url="https://homseer.sh/" 27 | LABEL org.label-schema.vcs-url="https://github.com/HomeSeerLinux/docker" 28 | LABEL org.label-schema.vendor="Homeseer.sh" 29 | LABEL org.label-schema.version=$VERSION 30 | 31 | RUN echo "=========================================================" && \ 32 | echo " BUILDING DOCKER HOMESEER BASE ($VERSION) IMAGE FOR: $TARGETARCH" && \ 33 | echo "=========================================================" 34 | 35 | # make sure APT packages are up to date 36 | RUN apt-get update && apt-get upgrade --yes 37 | 38 | # set non-interactive frontend 39 | RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections 40 | 41 | # update locale/language 42 | RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y locales 43 | RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \ 44 | dpkg-reconfigure --frontend=noninteractive locales && \ 45 | update-locale LANG=en_US.UTF-8 46 | 47 | # install container tools 48 | RUN apt-get install --yes tmux curl wget nano apt-utils net-tools iputils-ping etherwake ssh-client mosquitto-clients dos2unix 49 | 50 | # install HomeSeer dependencies 51 | # alsa-base (not available in Debian upstream) 52 | RUN apt-get install --yes aha ffmpeg alsa-utils tmux curl wget nano flite chromium \ 53 | avahi-discover libavahi-compat-libdnssd-dev libnss-mdns \ 54 | avahi-daemon avahi-utils mdns-scan mono-complete \ 55 | mono-devel mono-vbnc mono-xsp4 && \ 56 | apt-get remove --yes brltty 57 | 58 | # clean APT cache 59 | RUN apt-get clean && rm -rf /var/lib/apt/lists/* 60 | 61 | # copy container homeseer override scripts 62 | COPY homeseer/*.sh /scripts/ 63 | 64 | # copy container runtime scripts 65 | COPY usr/local/sbin/* /scripts/ 66 | 67 | # ensure scripts are executable 68 | RUN chmod a+x /scripts/* 69 | 70 | # ensure scripts are line-encoded for unix/linux 71 | RUN dos2unix /scripts/* 72 | 73 | # remove "reboot" and "shutdown" binaries from the container 74 | # (we will replace with symlinks to scripts) 75 | RUN rm -f /sbin/reboot && rm -f /sbin/shutdown 76 | 77 | # create symlinks in bin path ("/usr/local/sbin") 78 | RUN ln -sf /scripts/homeseer /usr/local/sbin/homeseer && \ 79 | ln -sf /scripts/reboot /usr/local/sbin/reboot && \ 80 | ln -sf /scripts/shutdown /usr/local/sbin/shutdown && \ 81 | ln -sf /scripts/poweroff /usr/local/sbin/poweroff 82 | 83 | # copy default configuration files 84 | COPY etc/avahi/avahi-daemon.conf /etc/avahi/avahi-daemon.conf 85 | 86 | # make folders for DBUS & AVAHI 87 | # apply folder permissions for DBUS & AVAHI 88 | RUN mkdir -p /var/run/dbus && \ 89 | mkdir -p /var/run/avahi-daemon && \ 90 | chown messagebus:messagebus /var/run/dbus && \ 91 | chown avahi:avahi /var/run/avahi-daemon 92 | 93 | # define IP ports to be exposed by this container 94 | # 80 : HTTP/WEB 95 | # 10200 : HS-TOUCH 96 | # 10300 : myHS 97 | # 10401 : SPEAKER CLIENTS 98 | # 11000 : ASCII/JSON REMOTE API 99 | EXPOSE 80 10200 10300 10401 11000 100 | 101 | # define required volume 102 | VOLUME ["/homeseer"] 103 | 104 | # set the working path 105 | WORKDIR "/homeseer" 106 | 107 | # launch homeseer script in container on startup 108 | CMD ["/usr/local/sbin/homeseer"] -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Docker](https://img.shields.io/docker/v/homeseer/homeseer/latest?color=darkgreen&logo=docker&label=DockerHub%20Latest%20Image)](https://hub.docker.com/repository/docker/homeseer/homeseer/) 2 | [![Docker](https://img.shields.io/docker/v/homeseer/homeseer/beta?color=red&logo=docker&label=DockerHub%20Beta%20Image)](https://hub.docker.com/repository/docker/homeseer/homeseer/) 3 | 4 | # Docker Container for HomeSeer 4 (Linux) 5 | 6 | (Developed with ♥ by SavageSoftware, LLC.) 7 | 8 | ## Disclaimers 9 | 10 | - This repository is not supported, sponsored or directly affiliated with Homeseer ([https://homeseer.com/](https://homeseer.com/)). 11 | - We are not responsible for any data lost or systems corrupted! 12 | 13 | --- 14 | 15 | ## Overview 16 | 17 | This project provides Docker container images for HomeSeer 4 on Linux. 18 | 19 | The docker images are published via Docker Hub: 20 | - [https://hub.docker.com/repository/docker/homeseer/homeseer](https://hub.docker.com/repository/docker/homeseer/homeseer) 21 | - [![Docker](https://img.shields.io/docker/v/homeseer/homeseer/latest?label=DockerHub%20Latest%20Image&logo=docker&style=social)](https://hub.docker.com/repository/docker/homeseer/homeseer/) 22 | - [![Docker](https://img.shields.io/docker/v/homeseer/homeseer/beta?label=DockerHub%20Beta%20Image&logo=docker&style=social)](https://hub.docker.com/repository/docker/homeseer/homeseer/) 23 | 24 | --- 25 | 26 | ## TL;DR 27 | 28 | Command to launch Docker container: 29 | ``` 30 | docker run -it --name homeseer \ 31 | -p 80:80 -p 10200:10200 -p 10300:10300 -p 10401:10401 -p 11000:11000 \ 32 | -v /etc/homeseer:/homeseer \ 33 | homeseer/homeseer:latest 34 | ``` 35 | 36 | --- 37 | 38 | ## Supported Architectures 39 | 40 | - ARM 64-bit ( `arm64` ) 41 | - Intel/AMD 64-bit ( `amd64` / `x86_64` ) 42 | 43 | --- 44 | 45 | ## Getting Started 46 | 47 | The following docker command will download and launch the latest HomeSeer 4 Docker image. 48 | ```shell 49 | docker run \ 50 | --interactive \ 51 | --tty \ 52 | --name homeseer \ 53 | --volume /etc/homeseer:/homeseer \ 54 | --publish 80:80 \ 55 | --publish 10200:10200 \ 56 | --publish 10300:10300 \ 57 | --publish 10401:10401 \ 58 | --publish 11000:11000 \ 59 | --env TZ=America/New_York \ 60 | --env LANG=en_US.UTF-8 \ 61 | homeseer/homeseer:latest 62 | ``` 63 | 64 | On the first run of the `homeseer` container, the script will take a few minutes while it 65 | installs the HomeSeer application files to the `/homeseer` mapped volume path. Subsequent 66 | container restarts will occur much faster as the HomeSeer application files are already 67 | installed. If the container is removed and a new container is launched, the HomeSeer 68 | application file will be re-installed even if they already exist in the `/homeseer` 69 | mapped volume path. Note: The installation process should not affect any user configuration, 70 | plugins or log files. However, it is always a good idea to make sure you have a complete backup 71 | of the `/homeseer` mapped volume path prior to any upgrades. 72 | 73 | --- 74 | 75 | ## Docker Compose 76 | 77 | Alternatively you can use a `docker-compose.yml` file to launch your homeseer container. 78 | Below is a sample `docker-compose.yml` file you can use to get started: 79 | 80 | ```yaml 81 | # -------------------------------------------------- 82 | # HOMESEER LINUX SERVER 83 | # -------------------------------------------------- 84 | # This container hosts the HomeSeer V4 server. 85 | # This config will create standalone 'homeseer-data' 86 | # docker volume to store all homeseer runtime 87 | # files. (logs, config, backups, app files) 88 | # 89 | # Disclaimers: 90 | # -------------- 91 | # This docker container is not supported, sponsored 92 | # or directly affiliated with Homeseer 93 | # (https://homeseer.com). 94 | # 95 | # -------------------------------------------------- 96 | # (Developed with ♥ by SavageSoftware, LLC.) 97 | # -------------------------------------------------- 98 | version: '3.8' 99 | 100 | volumes: 101 | homeseer-data: 102 | name: homeseer-data 103 | 104 | services: 105 | homeseer: 106 | container_name: homeseer 107 | image: homeseer/homeseer:latest 108 | hostname: homeseer 109 | restart: unless-stopped 110 | network_mode: bridge 111 | ports: 112 | - 80:80 113 | - 10200:10200 114 | - 10300:10300 115 | - 10401:10401 116 | - 11000:11000 117 | environment: 118 | TZ: America/New_York 119 | LANG: en_US.UTF-8 120 | volumes: 121 | - homeseer-data:/homeseer 122 | ``` 123 | 124 | 125 | Just run the `docker-compose up -d` command in the same directory as your `docker-compose.yml` 126 | file to launch the container instance. 127 | 128 | --- 129 | 130 | ## Acknowledgments 131 | 132 | Credit must be attributed to the following existing repositories and their respective authors. Much of 133 | the logic used in this project was based on these prior works. 134 | 135 | - https://github.com/marthoc/docker-homeseer 136 | - https://github.com/scyto/docker-homeseer 137 | - https://github.com/E1iTeDa357/docker-homeseer4 138 | -------------------------------------------------------------------------------- /base/usr/local/sbin/homeseer: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | ################################################# 4 | # HOMESEER (V4) LINUX - CONTAINER RUNTIME SCRIPT 5 | ################################################# 6 | 7 | # ------------------------------------------------------------------------- 8 | # INSTALL HOMESEER 9 | # ------------------------------------------------------------------------- 10 | # 'install' will overwrite the "/homeseer" directory contents with 11 | # application files from the embedded archive file included in this 12 | # container at ('/homeseer.tar.gz') 13 | # ------------------------------------------------------------------------- 14 | function install_homeseer { 15 | 16 | echo 17 | echo "**********************************************************************" 18 | echo " HOMESEER CONTAINER - INSTALLING HOMESEER" 19 | echo "**********************************************************************" 20 | echo 21 | 22 | # extract the HomeSeer application file from the embedded archive file in the container 23 | echo "Installing HomeSeer application files; please wait ..." 24 | tar --strip-components=1 -xzvf /homeseer.tar.gz -C /homeseer 25 | 26 | # write a flagging file to denote that we have installed the HomeSeer application in this container 27 | touch /homeseer-installed 28 | 29 | # remove unnecessary files from the HomeSeer application directory 30 | rm -f /homeseer/hs_sentry.log 31 | 32 | # copy updated (override) restart & shutdown command scripts for HomeSeer 33 | cp -r /scripts/restart.sh /homeseer/restart.sh 34 | cp -r /scripts/shutdown.sh /homeseer/shutdown.sh 35 | cp -r /scripts/shutdown_controller.sh /homeseer/shutdown_controller.sh 36 | 37 | echo 38 | echo "**********************************************************************" 39 | echo " HOMESEER CONTAINER - HOMESEER INSTALL COMPLETE" 40 | echo "**********************************************************************" 41 | echo 42 | } 43 | 44 | # ------------------------------------------------------------------------- 45 | # INITIALIZE HOMESEER 46 | # ------------------------------------------------------------------------- 47 | # 'initialize' will setup the system timezone and start the DBUS and AVAHI 48 | # daemon (initialization only occurs one time at container startup) 49 | # ------------------------------------------------------------------------- 50 | function initialize_homeseer { 51 | 52 | echo 53 | echo "**********************************************************************" 54 | echo " HOMESEER CONTAINER - IP ADDRESS" 55 | echo "**********************************************************************" 56 | echo 57 | ifconfig eth0 58 | 59 | echo 60 | echo "**********************************************************************" 61 | echo " HOMESEER CONTAINER - SET TIME ZONE: $TZ" 62 | echo "**********************************************************************" 63 | echo 64 | TZ="${TZ:=America/New_York}" 65 | LANG="${LANG:=en_US.UTF-8}" 66 | export LANG=$LANG 67 | export TZ=$TZ 68 | ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone 69 | dpkg-reconfigure --frontend noninteractive tzdata 70 | update-locale LANG=$LANG 71 | 72 | echo 73 | echo "**********************************************************************" 74 | echo " HOMESEER CONTAINER - STARTING DBUS DAEMON" 75 | echo "**********************************************************************" 76 | echo 77 | 78 | # stop any existing DBUS daemon processes 79 | killall -vq dbus-daemon || true; 80 | 81 | # delete existing pid if found 82 | [ -e /var/run/dbus.pid ] && rm -f /var/run/dbus.pid 83 | [ -e /var/run/dbus/pid ] && rm -f /var/run/dbus/pid 84 | 85 | # This will ensure that /var/lib/dbus/machine-id exists and has the uuid in it. 86 | # It won't overwrite an existing uuid, since this id should remain fixed for a 87 | # single machine until the next reboot at least. The important properties of 88 | # the machine UUID are that (1) it remains unchanged until the next reboot 89 | # and (2) it is different for any two running instances of the OS kernel. 90 | dbus-uuidgen --ensure || true 91 | echo " -> DBUS UUID generated: `cat /var/lib/dbus/machine-id`" 92 | sleep 1 93 | 94 | # launch DBUS as a background task and redirect STDOUT & STDERR to NULL 95 | dbus-daemon --system --nofork 2>/dev/null & 96 | DBUS_PID=$! 97 | echo " -> DBUS Daemon started in background (PID=$DBUS_PID)" 98 | ps -A | grep dbus-daemon || true 99 | 100 | echo 101 | echo "**********************************************************************" 102 | echo " HOMESEER CONTAINER - STARTING AVAHI DAEMON" 103 | echo "**********************************************************************" 104 | echo 105 | 106 | # stop any existing AVAHI daemon processes 107 | killall -vq avahi-daemon || true; 108 | 109 | # delete existing pid if found 110 | [ -e /var/run/avahi-daemon/pid ] && rm -f /var/run/avahi-daemon/pid 111 | 112 | # fix avahi config for synology dsm 113 | if [ ! -z "$DSM_HOSTNAME" ]; then 114 | echo " -> AVAHI configuration file updated for Synology DSM_HOSTNAME: ${DSM_HOSTNAME}" 115 | sed -i "s/.*host-name.*/host-name=${DSM_HOSTNAME}/" /etc/avahi/avahi-daemon.conf 116 | else 117 | sed -i "s/.*host-name.*/#host-name=/" /etc/avahi/avahi-daemon.conf 118 | fi 119 | echo " -> AVAHI configuration file updated: /etc/avahi/avahi-daemon.conf" 120 | 121 | # launch AVAHI as a background task and redirect STDOUT & STDERR to NULL 122 | avahi-daemon --no-chroot -f /etc/avahi/avahi-daemon.conf 2>/dev/null & 123 | AVAHI_PID=$! 124 | echo " -> AVAHI Daemon started in background (PID=$AVAHI_PID)" 125 | ps -A | grep avahi-daemon || true 126 | } 127 | 128 | # ------------------------------------------------------------------------- 129 | # START (OR RESTART) HOMESEER 130 | # ------------------------------------------------------------------------- 131 | function start_homeseer { 132 | 133 | # handle restarts if needed 134 | if [ -f "/homeseer-restart" ]; then 135 | echo 136 | echo "**********************************************************************" 137 | echo " HOMESEER CONTAINER - RESTARTING HOMESEER" 138 | echo "**********************************************************************" 139 | echo 140 | rm -f /homeseer-restart 141 | else 142 | echo 143 | echo "**********************************************************************" 144 | echo " HOMESEER CONTAINER - STARTING HOMESEER" 145 | echo "**********************************************************************" 146 | echo 147 | fi 148 | 149 | # make sure we are in the /homeseer working directory 150 | cd /homeseer 151 | 152 | # start the .NET Homeseer application (via mono) 153 | # (run the homeseer process in the background so that we can monitor signals to terminate) 154 | mono HSConsole.exe --log & 155 | HOMESEER_PID=$! 156 | 157 | # MONITOR TERMINATION SIGNALS 158 | # 1 HUP (hang up) 159 | # 2 INT (interrupt) 160 | # 3 QUIT (quit) 161 | # 6 ABRT (abort) 162 | # 15 TERM (software termination signal) 163 | trap 'echo "---> SIGHUP DETECTED"; stop_homeseer; exit 0;' SIGHUP 164 | trap 'echo "---> SIGINT DETECTED"; stop_homeseer; exit 0;' SIGINT 165 | trap 'echo "---> SIGQUIT DETECTED"; stop_homeseer; exit 0;' SIGQUIT 166 | trap 'echo "---> SIGABRT DETECTED"; stop_homeseer; exit 0;' SIGABRT 167 | trap 'echo "---> SIGTERM DETECTED"; stop_homeseer; exit 0;' SIGTERM 168 | 169 | # continuous loop waiting for a termination signal 170 | # of exit if the homeseer mono process has terminated/shutdown on its own 171 | while true 172 | do 173 | # check to see if the homeseer process is still running in the background 174 | if [ -d "/proc/${HOMESEER_PID}" ]; then 175 | sleep 2; # homeseer mono process is still running 176 | else 177 | echo "--> HOMESEER PROCESS HAS TERMINATED." ; 178 | break; # homeseer mono process has terminated 179 | fi 180 | done 181 | } 182 | 183 | # ------------------------------------------------------------------------- 184 | # STOP HOMESEER 185 | # ------------------------------------------------------------------------- 186 | # stop homeseer now; the mono process has already exited we just need 187 | # to stop any other daemons/processes and perform any cleanup 188 | # ------------------------------------------------------------------------- 189 | function stop_homeseer { 190 | 191 | echo 192 | echo "**********************************************************************" 193 | echo " HOMESEER CONTAINER - STOPPING HOMESEER PROCESS" 194 | echo "**********************************************************************" 195 | echo 196 | CURL_ERROR=0; 197 | 198 | # extract web server port from settings.ini 199 | HOMESEER_PORT=$(awk -F= '\ 200 | { 201 | gsub("\015", "") # remove CR character 202 | if ($1 == "gWebSvrPort") print $2 203 | } 204 | ' /homeseer/Config/settings.ini) 205 | 206 | # send application shutdown command (attempt the API call up to 5 times) 207 | for i in $(seq 1 5) 208 | do 209 | echo "--> CALLING SHUTDOWN API ON HOMESEER SERVER PORT: $HOMESEER_PORT" 210 | CURL_ERROR=0; 211 | curl -f -s -o /dev/null ${HOMESEER_CREDENTIALS:+-u} $HOMESEER_CREDENTIALS --data 'ConfirmShutdownhs=Yes' "http://localhost:$HOMESEER_PORT/LinuxTools" || CURL_ERROR=$?; 212 | test $CURL_ERROR -eq 0 && break 213 | echo "--> [$i] SHUTDOWN API CALL FAILED WITH ERROR: $CURL_ERROR; RETRYING IN 2 SECONDS" 214 | sleep 2 215 | done 216 | 217 | # if the API call failed, the we should directly kill the homeseer mono process; 218 | # this will result in an unclean termination but its the best we can do if the API call fails. 219 | if [[ CURL_ERROR -ne 0 ]]; then 220 | echo "--> UNABLE TO CALL SHUTDOWN API ON HOMESEER SERVER; KILLING HOMESEER PROCESS [$HOMESEER_PID]" 221 | test -n "$HOMESEER_PID" && kill -0 $HOMESEER_PID && kill $HOMESEER_PID 222 | fi; 223 | 224 | # wait until the homeseer mono process has been terminated 225 | # (timeout after one minute of waiting) 226 | for (( t=0; t<30; t+=2 )) 227 | do 228 | pgrep -af mono.'*'\(HSConsole\|HomeSeer\) || break 229 | echo "--> WAITING FOR HOMESEER TO SHUTDOWN"; 230 | sleep 2; # two seconds 231 | done 232 | 233 | # with homeseer mono process terminated; we are ready to clean up and exit 234 | exit_homeseer; 235 | } 236 | 237 | # ------------------------------------------------------------------------- 238 | # EXIT HOMESEER 239 | # ------------------------------------------------------------------------- 240 | # exit homeseer now; the mono process has already exited we just need 241 | # to stop any other daemons/processes and perform any cleanup 242 | # ------------------------------------------------------------------------- 243 | function exit_homeseer { 244 | 245 | echo 246 | echo "**********************************************************************" 247 | echo " HOMESEER CONTAINER - STOPPING AVAHI DAEMON" 248 | echo "**********************************************************************" 249 | echo 250 | killall -vq avahi-daemon || true; # stop the AVAHI daemon process 251 | 252 | echo 253 | echo "**********************************************************************" 254 | echo " HOMESEER CONTAINER - STOPPING DBUS DAEMON" 255 | echo "**********************************************************************" 256 | echo 257 | killall -vq dbus-daemon || true; # stop the DBUS daemon process 258 | 259 | echo 260 | echo "**********************************************************************" 261 | echo " HOMESEER CONTAINER - EXITING" 262 | echo "**********************************************************************" 263 | echo 264 | echo "GOODBYE!" 265 | echo 266 | 267 | # exit with success code 268 | exit 0; 269 | } 270 | 271 | # --------------------------------------------------------------------------------------------------- 272 | # --------------------------------------------------------------------------------------------------- 273 | # --------------------------------------------------------------------------------------------------- 274 | # --------------------------------------------------------------------------------------------------- 275 | # --------------------------------------------------------------------------------------------------- 276 | 277 | echo 278 | echo "**********************************************************************" 279 | echo " HOMESEER CONTAINER - STARTUP" 280 | echo "**********************************************************************" 281 | echo 282 | echo "PRESS CTRL-C TO SHUTDOWN; OR USE 'docker stop homeseer' COMMAND." 283 | echo 284 | 285 | # install HomeSeer if not already installed by this container instance 286 | # (the "/homeseer-installed" file is written after installation) 287 | if [[ ! -f "/homeseer-installed" ]] && [ ! -f "/homeseer/no-install" ]; then 288 | echo "Homeseer is not installed in this container; install it now." 289 | # 'install' will overwrite the "/homeseer" directory contents with 290 | # application files from the embedded archive file included in this 291 | # container at ('/homeseer.tar.gz') 292 | install_homeseer; 293 | else 294 | echo "Homeseer is already installed in this container." 295 | fi 296 | 297 | echo 298 | echo "**********************************************************************" 299 | echo " HOMESEER CONTAINER - INITIALIZE" 300 | echo "**********************************************************************" 301 | echo 302 | ps -A | grep homeseer 303 | 304 | # 'initialize' will setup the system timezone and start the DBUS and AVAHI daemon 305 | # (initialization only occurs one time at container startup) 306 | initialize_homeseer; 307 | 308 | # initial runtime counter value 309 | RunCounter=0; 310 | 311 | # program runtime loop; handles software initiated restarts/reboots/updates 312 | # continuous loop while ... 313 | # (1) RunCounter=0; this denoted the first run after container startup 314 | # (2) if a restart flag file exists on the root directory ("/homeseer-restart") 315 | # (3) or if an update file exists in the homeseer directory ("/homeseer/hs4_sel*") 316 | while [[ RunCounter -eq 0 ]] || [[ -f "/homeseer-restart" ]] || [[ "`echo /homeseer/hs4_sel*`" != "/homeseer/hs4_sel*" ]] 317 | do 318 | # if an update file exists; then wait for it to be removed by the updater 319 | while [[ "`echo /homeseer/hs4_sel*`" != "/homeseer/hs4_sel*" ]] 320 | do 321 | echo "------------- WAITING FOR HOMESEER UPDATE TO COMPLETE" 322 | sleep 10; 323 | done 324 | 325 | ((RunCounter=RunCounter+1)) # increment runtime counter 326 | start_homeseer; # start (or restart) homeseer 327 | sleep 1; 328 | done 329 | 330 | 331 | echo 332 | echo "**********************************************************************" 333 | echo " HOMESEER CONTAINER - STOPPING" 334 | echo "**********************************************************************" 335 | echo 336 | 337 | # exit homeseer now; the mono process has already exited we just need 338 | # to stop any other daemons/processes and perform any cleanup 339 | exit_homeseer; 340 | 341 | # GOODBYE 342 | exit 0 343 | --------------------------------------------------------------------------------