From b07a3043ca6b0a3eeaa1c4e203f62669b8fcce18 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Fri, 2 Nov 2018 23:55:41 +0100 Subject: [PATCH] :tada: Adds initial add-on code --- README.md | 222 +++++++++++++++ traccar/.README.j2 | 70 +++++ traccar/Dockerfile | 50 ++++ traccar/build.json | 9 + traccar/config.json | 41 +++ traccar/icon.png | Bin 0 -> 4855 bytes traccar/logo.png | Bin 0 -> 2607 bytes .../rootfs/etc/cont-init.d/10-requirements.sh | 26 ++ traccar/rootfs/etc/cont-init.d/20-config.sh | 11 + traccar/rootfs/etc/cont-init.d/30-nginx.sh | 25 ++ traccar/rootfs/etc/nginx/nginx-ssl.conf | 63 +++++ traccar/rootfs/etc/nginx/nginx.conf | 47 ++++ traccar/rootfs/etc/services.d/nginx/finish | 9 + traccar/rootfs/etc/services.d/nginx/run | 9 + traccar/rootfs/etc/services.d/traccar/finish | 9 + traccar/rootfs/etc/services.d/traccar/run | 26 ++ traccar/rootfs/etc/traccar/hassio.xml | 256 ++++++++++++++++++ traccar/rootfs/etc/traccar/traccar.xml | 22 ++ 18 files changed, 895 insertions(+) create mode 100644 README.md create mode 100644 traccar/.README.j2 create mode 100755 traccar/Dockerfile create mode 100644 traccar/build.json create mode 100755 traccar/config.json create mode 100644 traccar/icon.png create mode 100644 traccar/logo.png create mode 100644 traccar/rootfs/etc/cont-init.d/10-requirements.sh create mode 100644 traccar/rootfs/etc/cont-init.d/20-config.sh create mode 100644 traccar/rootfs/etc/cont-init.d/30-nginx.sh create mode 100644 traccar/rootfs/etc/nginx/nginx-ssl.conf create mode 100644 traccar/rootfs/etc/nginx/nginx.conf create mode 100644 traccar/rootfs/etc/services.d/nginx/finish create mode 100644 traccar/rootfs/etc/services.d/nginx/run create mode 100644 traccar/rootfs/etc/services.d/traccar/finish create mode 100644 traccar/rootfs/etc/services.d/traccar/run create mode 100644 traccar/rootfs/etc/traccar/hassio.xml create mode 100644 traccar/rootfs/etc/traccar/traccar.xml diff --git a/README.md b/README.md new file mode 100644 index 0000000..2fea0e4 --- /dev/null +++ b/README.md @@ -0,0 +1,222 @@ +# Community Hass.io Add-ons: Traccar + +[![GitHub Release][releases-shield]][releases] +![Project Stage][project-stage-shield] +[![License][license-shield]](LICENSE.md) + +[![GitLab CI][gitlabci-shield]][gitlabci] +![Project Maintenance][maintenance-shield] +[![GitHub Activity][commits-shield]][commits] + +[![Bountysource][bountysource-shield]][bountysource] +[![Discord][discord-shield]][discord] +[![Community Forum][forum-shield]][forum] + +[![Buy me a coffee][buymeacoffee-shield]][buymeacoffee] + +[![Support my work on Patreon][patreon-shield]][patreon] + +Modern GPS Tracking Platform. + +## About + +Lorem ipsum. + +## Installation + +The installation of this add-on is pretty straightforward and not different in +comparison to installing any other Hass.io add-on. + +1. [Add our Hass.io add-ons repository][repository] to your Hass.io instance. +1. Install the "Traccar" add-on. +1. Start the "Traccar" add-on +1. Check the logs of the "Traccar" add-on to see if everything went well. +1. Click the "OPEN WEB UI" button and log in using `admin`/`admin`. +1. Be sure to change the username and password! + +**NOTE**: Do not add this repository to Hass.io, please use: +`https://github.com/hassio-addons/repository`. + +## Docker status + +![Supports armhf Architecture][armhf-shield] +![Supports aarch64 Architecture][aarch64-shield] +![Supports amd64 Architecture][amd64-shield] +![Supports i386 Architecture][i386-shield] + +[![Docker Layers][layers-shield]][microbadger] +[![Docker Pulls][pulls-shield]][dockerhub] + +## Configuration + +**Note**: _Remember to restart the add-on when the configuration is changed._ + +Example add-on configuration: + +```json +{ + "log_level": "info", + "port": 8082, + "ssl": true, + "certfile": "fullchain.pem", + "keyfile": "privkey.pem" +} +``` + +**Note**: _This is just an example, don't copy and past it! Create your own!_ + +### Option: `log_level` + +The `log_level` option controls the level of log output by the addon and can +be changed to be more or less verbose, which might be useful when you are +dealing with an unknown issue. Possible values are: + +- `trace`: Show every detail, like all called internal functions. +- `debug`: Shows detailed debug information. +- `info`: Normal (usually) interesting events. +- `warning`: Exceptional occurrences that are not errors. +- `error`: Runtime errors that do not require immediate action. +- `fatal`: Something went terribly wrong. Add-on becomes unusable. + +Please note that each level automatically includes log messages from a +more severe level, e.g., `debug` also shows `info` messages. By default, +the `log_level` is set to `info`, which is the recommended setting unless +you are troubleshooting. + +### Option: `port` + +The `port` setting allows you to change the port the web interface +Traccar is running on. + +### Option: `ssl` + +Enables/Disables SSL (HTTPS) on the web interface. +Set it `true` to enable it, `false` otherwise. + +### Option: `certfile` + +The certificate file to use for SSL. + +**Note**: _The file MUST be stored in `/ssl/`, which is the default for Hass.io_ + +### Option: `keyfile` + +The private key file to use for SSL. + +**Note**: _The file MUST be stored in `/ssl/`, which is the default for Hass.io_ + +## Changelog & Releases + +This repository keeps a change log using [GitHub's releases][releases] +functionality. The format of the log is based on +[Keep a Changelog][keepchangelog]. + +Releases are based on [Semantic Versioning][semver], and use the format +of ``MAJOR.MINOR.PATCH``. In a nutshell, the version will be incremented +based on the following: + +- ``MAJOR``: Incompatible or major changes. +- ``MINOR``: Backwards-compatible new features and enhancements. +- ``PATCH``: Backwards-compatible bugfixes and package updates. + +## Support + +Got questions? + +You have several options to get them answered: + +- The [Community Hass.io Add-ons Discord chat server][discord] for add-on + support and feature requests. +- The [Home Assistant Discord chat server][discord-ha] for general Home + Assistant discussions and questions. +- The Home Assistant [Community Forum][forum]. +- Join the [Reddit subreddit][reddit] in [/r/homeassistant][reddit] + +You could also [open an issue here][issue] GitHub. + +## Contributing + +This is an active open-source project. We are always open to people who want to +use the code or contribute to it. + +We have set up a separate document containing our +[contribution guidelines](CONTRIBUTING.md). + +Thank you for being involved! :heart_eyes: + +## Authors & contributors + +The original setup of this repository is by [Franck Nijhof][frenck]. + +For a full list of all authors and contributors, +check [the contributor's page][contributors]. + +## We have got some Hass.io add-ons for you + +Want some more functionality to your Hass.io Home Assistant instance? + +We have created multiple add-ons for Hass.io. For a full list, check out +our [GitHub Repository][repository]. + +## License + +MIT License + +Copyright (c) 2018 Franck Nijhof + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +[aarch64-shield]: https://img.shields.io/badge/aarch64-yes-green.svg +[amd64-shield]: https://img.shields.io/badge/amd64-yes-green.svg +[anchore-shield]: https://anchore.io/service/badges/image/67d1185473090e99d5ac5e1bb4d1aa2295117a9bd3d7abbf8cd8a71e331c8388 +[anchore]: https://anchore.io/image/dockerhub/hassioaddons%2Ftraccar%3Alatest +[armhf-shield]: https://img.shields.io/badge/armhf-yes-green.svg +[bountysource-shield]: https://img.shields.io/bountysource/team/hassio-addons/activity.svg +[bountysource]: https://www.bountysource.com/teams/hassio-addons/issues +[buymeacoffee-shield]: https://www.buymeacoffee.com/assets/img/guidelines/download-assets-sm-2.svg +[buymeacoffee]: https://www.buymeacoffee.com/frenck +[commits-shield]: https://img.shields.io/github/commit-activity/y/hassio-addons/addon-traccar.svg +[commits]: https://github.com/hassio-addons/addon-traccar/commits/master +[contributors]: https://github.com/hassio-addons/addon-traccar/graphs/contributors +[discord-ha]: https://discord.gg/c5DvZ4e +[discord-shield]: https://img.shields.io/discord/478094546522079232.svg +[discord]: https://discord.me/hassioaddons +[dockerhub]: https://hub.docker.com/r/hassioaddons/traccar +[forum-shield]: https://img.shields.io/badge/community-forum-brightgreen.svg +[forum]: https://community.home-assistant.io/t/?u=frenck +[frenck]: https://github.com/frenck +[gitlabci-shield]: https://gitlab.com/hassio-addons/addon-traccar/badges/master/pipeline.svg +[gitlabci]: https://gitlab.com/hassio-addons/addon-traccar/pipelines +[home-assistant]: https://home-assistant.io +[i386-shield]: https://img.shields.io/badge/i386-yes-green.svg +[issue]: https://github.com/hassio-addons/addon-traccar/issues +[keepchangelog]: http://keepachangelog.com/en/1.0.0/ +[layers-shield]: https://images.microbadger.com/badges/image/hassioaddons/traccar.svg +[license-shield]: https://img.shields.io/github/license/hassio-addons/addon-traccar.svg +[maintenance-shield]: https://img.shields.io/maintenance/yes/2018.svg +[microbadger]: https://microbadger.com/images/hassioaddons/traccar +[patreon-shield]: https://www.frenck.nl/images/patreon.png +[patreon]: https://www.patreon.com/frenck +[project-stage-shield]: https://img.shields.io/badge/project%20stage-experimental-yellow.svg +[pulls-shield]: https://img.shields.io/docker/pulls/hassioaddons/traccar.svg +[reddit]: https://reddit.com/r/homeassistant +[releases-shield]: https://img.shields.io/github/release/hassio-addons/addon-traccar.svg +[releases]: https://github.com/hassio-addons/addon-traccar/releases +[repository]: https://github.com/hassio-addons/repository +[semver]: http://semver.org/spec/v2.0.0.htm diff --git a/traccar/.README.j2 b/traccar/.README.j2 new file mode 100644 index 0000000..cf8717b --- /dev/null +++ b/traccar/.README.j2 @@ -0,0 +1,70 @@ +# Community Hass.io Add-ons: Traccar + +[![Release][release-shield]][release] ![Project Stage][project-stage-shield] ![Project Maintenance][maintenance-shield] + +[![Discord][discord-shield]][discord] [![Community Forum][forum-shield]][forum] + +[![Buy me a coffee][buymeacoffee-shield]][buymeacoffee] + +[![Support my work on Patreon][patreon-shield]][patreon] + +Modern GPS Tracking Platform. + +## About + +Lorem ipsum. + +[Click here for the full documentation][docs] + +{% if channel == "edge" %} +## WARNING! THIS IS AN EDGE VERSION! + +This Hass.io Add-ons repository contains edge builds of add-ons. Edge builds +add-ons are based upon the latest development version. + +- They may not work at all. +- They might stop working at any time. +- They could have a negative impact on your system. + +This repository was created for: + +- Anybody willing to test. +- Anybody interested in trying out upcoming add-ons or add-on features. +- Developers. + +If you are more interested in stable releases of our add-ons: + + + +{% endif %} +{% if channel == "beta" %} +## WARNING! THIS IS A BETA VERSION! + +This Hass.io Add-ons repository contains beta releases of add-ons. + +- They might stop working at any time. +- They could have a negative impact on your system. + +This repository was created for: + +- Anybody willing to test. +- Anybody interested in trying out upcoming add-ons or add-on features. + +If you are more interested in stable releases of our add-ons: + + + +{% endif %} +[buymeacoffee-shield]: https://www.buymeacoffee.com/assets/img/guidelines/download-assets-sm-2.svg +[buymeacoffee]: https://www.buymeacoffee.com/frenck +[discord-shield]: https://img.shields.io/discord/478094546522079232.svg +[discord]: https://discord.me/hassioaddons +[docs]: {{ repo }}/blob/{{ version }}/README.md +[forum-shield]: https://img.shields.io/badge/community-forum-brightgreen.svg +[forum]: https://community.home-assistant.io/?u=frenck +[maintenance-shield]: https://img.shields.io/maintenance/yes/2018.svg +[patreon-shield]: https://www.frenck.nl/images/patreon.png +[patreon]: https://www.patreon.com/frenck +[project-stage-shield]: https://img.shields.io/badge/project%20stage-production%20ready-brightgreen.svg +[release-shield]: https://img.shields.io/badge/version-{{ version }}-blue.svg +[release]: {{ repo }}/tree/{{ version }} diff --git a/traccar/Dockerfile b/traccar/Dockerfile new file mode 100755 index 0000000..1b03721 --- /dev/null +++ b/traccar/Dockerfile @@ -0,0 +1,50 @@ +ARG BUILD_FROM=hassioaddons/base:2.3.0 +# hadolint ignore=DL3006 +FROM ${BUILD_FROM} + +# Set shell +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +# Copy root filesystem +COPY rootfs / + +# Set working dir +WORKDIR /opt/traccar + +# Setup base +RUN \ + apk add --no-cache \ + nginx=1.14.0-r1 \ + openjdk8-jre=8.181.13-r0 \ + \ + && curl -J -L -o /tmp/traccar.zip \ + "https://github.com/traccar/traccar/releases/download/v4.1/traccar-other-4.1.zip" \ + \ + && mkdir -p /opt/traccar \ + && unzip -d /opt/traccar /tmp/traccar.zip \ + \ + && rm -fr /tmp/* + +# Build arugments +ARG BUILD_ARCH +ARG BUILD_DATE +ARG BUILD_REF +ARG BUILD_VERSION + +# Labels +LABEL \ + io.hass.name="Traccar" \ + io.hass.description="Modern GPS Tracking Platform." \ + io.hass.arch="${BUILD_ARCH}" \ + io.hass.type="addon" \ + io.hass.version=${BUILD_VERSION} \ + maintainer="Franck Nijhof " \ + org.label-schema.description="Modern GPS Tracking Platform." \ + org.label-schema.build-date=${BUILD_DATE} \ + org.label-schema.name="Traccar" \ + org.label-schema.schema-version="1.0" \ + org.label-schema.url="https://community.home-assistant.io/?u=frenck" \ + org.label-schema.usage="https://github.com/hassio-addons/addon-traccar/tree/master/README.md" \ + org.label-schema.vcs-ref=${BUILD_REF} \ + org.label-schema.vcs-url="https://github.com/hassio-addons/addon-traccar" \ + org.label-schema.vendor="Community Hass.io Add-ons" diff --git a/traccar/build.json b/traccar/build.json new file mode 100644 index 0000000..13665d0 --- /dev/null +++ b/traccar/build.json @@ -0,0 +1,9 @@ +{ + "build_from": { + "aarch64": "hassioaddons/base-aarch64:2.3.0", + "amd64": "hassioaddons/base-amd64:2.3.0", + "armhf": "hassioaddons/base-armhf:2.3.0", + "i386": "hassioaddons/base-i386:2.3.0" + }, + "args": {} +} diff --git a/traccar/config.json b/traccar/config.json new file mode 100755 index 0000000..73eb47a --- /dev/null +++ b/traccar/config.json @@ -0,0 +1,41 @@ +{ + "name": "Traccar", + "version": "dev", + "slug": "traccar", + "description": "Modern GPS Tracking Platform", + "url": "https://community.home-assistant.io/?u=frenck", + "webui": "[PROTO:ssl]://[HOST]:[PORT:8082]", + "startup": "services", + "arch": [ + "aarch64", + "amd64", + "armhf", + "i386" + ], + "boot": "auto", + "hassio_api": true, + "hassio_role": "default", + "homeassistant_api": false, + "host_network": true, + "map": [ + "config:rw", + "ssl" + ], + "options": { + "log_level": "info", + "port": 8082, + "ssl": true, + "certfile": "fullchain.pem", + "keyfile": "privkey.pem" + }, + "schema": { + "log_level": "match(^(trace|debug|info|notice|warning|error|fatal)$)", + "port": "port", + "ssl": "bool", + "certfile": "str", + "keyfile": "str" + }, + "environment": { + "LOG_FORMAT": "{LEVEL}: {MESSAGE}" + } +} diff --git a/traccar/icon.png b/traccar/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..10be2c906912941bdb3792f0c6da64c8fb5380a7 GIT binary patch literal 4855 zcmVyP)C0008eP)t-s|Ns90 z008~{{r>*`5)u*+5D*j;6c-m478Vv06B7*$4HXp?{QUd^0s;X60RsaA3JMAb2L}-m z5e^Ox3=9kp4-W|m2?z)X3kwSb1Oylu80_rq1_lQC`T6nj@zc}O85tQG8X9V9YSGcr z%zjq<>lql($enk?)dolZEbBmJw1DSdoM39J3Bj=n3!;I zaQFB3g@uLf?d|&d`bFMdMt*sy+AUZla zI5;?(nwni*UA(-!va+(dxw)>cuA!l!^Yim3CnrlwOOun6(9qD!%ggok_3G;Cjg5`N z!^0sVA@A?+A|fKCrKPH>s>a5~M@L5=A0I?SM3Iq^z`($_x3{LIrkCQ&Ur`tE;K0sW~}0hlhtA z9v)CoP}XSyfe4Qc_Z&prB=CWs8f8Z*Om?sHjFpMk^~TkdTl-KtQpv zvAesw)YQ~`e0+0&&)z$Fu@N;u>dU|@Jqody5-XkL;8yg#nii(eqk55le zczAf++}s@<9baExhK7biLqk75KZ%KnTwGjtcXxz@gtWA@DJd!E=jS9OB*(|ca&mHv zjEpWWE*u;judlDazrXJ7?tXrLe}8{PMMa2+h%GHGxwyDdQBiSmaX~>rNl8h9f`Tk8 zENg3Pl$4a=;o&?yJTWmb_xARrq@*w~FwV}--`?H`2M5f|%+k@(NW8AY000l-Nkl}1?w(V=%er?{3f8IBP1Sp zdEVRujEUQ}96z#k#CWvf6tq?%LyNjUIJ6p|Xqnl3suYU@@pwGelFS%Z4&cGJU+rEd zB1$)sgH|GP*F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ykCnf*#J%q;uI}rE|KV@^Y#Gw8~{d=nMWQMQ8j#h z>ys~#H2^RR%-ti=v$zePSEdgCW5cf5LxBpDZSh#Xcsn$;0N}vd^=H>)A~%DT1i;Ng z-+3aU&!Wji-#rTohToutdGstr)FS8JLyHSQ!7ymqF@G{`KH6{dxo8DgMjjyU=6P|c zh(2o@9(mnu1Cx-7$763OsacqA7oK3+<)x326O9$V-7{IKw`^6n##knG? zuJfE|e=oR(SLTq&R2m+wm4~`ktee|6FtD!c{_UHmR~jC3E#-lpVL?}at7u(sGHX5B z3s{CPLp)J1o9ybA&yEfwS!ww!SuSwXtx*xxh^E)`|990@;5ef?Tg`|Q`86!-bn~l` zN#P@wN=6L0bk-HiMYL{E%eC$~=M>PAwsI-P2Z@}OE&-1{+!JkZ=dtWuy!I7{c~++duy4afcS!@y2Yrmox?g?!L4cfPWRfkh_y~=7tdz=UO{)m7de;a4w`eG6 z4s3k$`_|7L-*Ovc;=tT_FFz18zc(5|G8&q;u>J60*VQLq>vT*nZ(RJ=ExT8J)IFnT deK2g&_<#1i4k~ZYVoU%4002ovPDHLkV1kv2HhTa7 literal 0 HcmV?d00001 diff --git a/traccar/logo.png b/traccar/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..0d00ebecb1b2eee04811c299380368638c2fd8dd GIT binary patch literal 2607 zcmV+~3efe5P)gwwH`uY_W6=GsyO-)T$SXjWoz#SbO_xJZ~Y;4KN$#QaXKtMp^;^HPI zCNwlO+1c5io}Rb2x75_s=;-LCrlx&;eLOro85tR0UtcaRE`^1KR8&;3u&~6$#E_7X zDJdy<<6{32aG3K~#8N&E411qqq_P;BEzS&dxc^`@i71 zI8|E>1|i!>{=d83iy2CxgM=Aaln7Rrb?j&RkTGW)7T0~5?bdZuMer9zNu6d}oaB^l z-NGLto^F9UShj8i`~k^f!|@&0bppQ>t$YVR5T12y^t^0SZgJKo`Qan;tA9APorE4)1@+o} za8x)}V2W^Y(mq|a5)@=|@e7>7V*y5-re@ml>khPtl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#!`XAki*ib3bl3Hqf8)5@QsqEGKHK;5+p z&HRc=9vC3_)PY6BwEAmNqEZ9PJ4}bRonCT_GE^xfEKMke^Q`&ZmFS2n|6pmUDn@K{ zH`FOaw0Gc?bJdm!wA-iX#&HU-VOhR<$7K5F;q8&*7#8OSWAqh>kyX8c8RA~zkaG~Q zv~2FzsNQ>ZM0@b}{|$JtySHZhS=`J{1}h9{FtYiv`$D|;HPTsu839^Jb)icnD%W$$58PqyhUB82*Aoo zDI@ri=z&E2PU6HJ{D}YFIZ)32z-BzW+vT6|=Q-wy)amV)S@{aAYxoCO!k*%DdDcIe zm&uPl@^|{>=kf~i*-uk=^Sh7bvFiQe+x`k!@z2L=ZQxGU{HIA{?C~S8AlhM%`{fVl z9~~H%mtTL**~OkP0mA}E|Cx1Pr(rc1b>WL#xck`WbzqF}vCm!V(;?0i3|Tpgz0W0G zwDN`W+{1x*$%Ten14;ePa9|BzX&4S<2`sAJ-~ju2V5$O#{2Ufj?Qp1Q;cFtpA)X3Y zMDB7N@&qhE#`uCQaje_L9AB(qAtwi4@Ld95sZxfx^m3-e5l1{$5xoQq6G0 z_Ljg0l9(Z3u29G`92Lfagm)x|5=R|7Fq{J@$2|$q($&6$grTfOiJ0S*!oMUE6lA+f z_c+NFU`lmF1^#f?bx=v@kzIQ__*ae!UIHd18=SQ*H<{-h{hgncAw$CIBU7gVa!y11fa9+s_@!ih#dq+{A%Q3Hk_(R&-EghV+&C)uF;4g}*re5!|a(^wtt;1Nj&-{3OSp@=?^gpj&gpspl R!Xp3x002ovPDHLkV1gRc`&|G4 literal 0 HcmV?d00001 diff --git a/traccar/rootfs/etc/cont-init.d/10-requirements.sh b/traccar/rootfs/etc/cont-init.d/10-requirements.sh new file mode 100644 index 0000000..61e171c --- /dev/null +++ b/traccar/rootfs/etc/cont-init.d/10-requirements.sh @@ -0,0 +1,26 @@ +#!/usr/bin/with-contenv bash +# ============================================================================== +# Community Hass.io Add-ons: Traccar +# This files check if all user configuration requirements are met +# ============================================================================== +# shellcheck disable=SC1091 +source /usr/lib/hassio-addons/base.sh + +# Check SSL requirements, if enabled +if hass.config.true 'ssl'; then + if ! hass.config.has_value 'certfile'; then + hass.die 'SSL is enabled, but no certfile was specified' + fi + + if ! hass.config.has_value 'keyfile'; then + hass.die 'SSL is enabled, but no keyfile was specified' + fi + + if ! hass.file_exists "/ssl/$(hass.config.get 'certfile')"; then + hass.die 'The configured certfile is not found' + fi + + if ! hass.file_exists "/ssl/$(hass.config.get 'keyfile')"; then + hass.die 'The configured keyfile is not found' + fi +fi diff --git a/traccar/rootfs/etc/cont-init.d/20-config.sh b/traccar/rootfs/etc/cont-init.d/20-config.sh new file mode 100644 index 0000000..f903313 --- /dev/null +++ b/traccar/rootfs/etc/cont-init.d/20-config.sh @@ -0,0 +1,11 @@ +#!/usr/bin/with-contenv bash +# ============================================================================== +# Community Hass.io Add-ons: Traccar +# Ensures the user configuration file is present +# ============================================================================== +# shellcheck disable=SC1091 +source /usr/lib/hassio-addons/base.sh + +if ! hass.file_exists "/config/traccar.xml"; then + cp /etc/traccar/traccar.xml /config/traccar.xml +fi diff --git a/traccar/rootfs/etc/cont-init.d/30-nginx.sh b/traccar/rootfs/etc/cont-init.d/30-nginx.sh new file mode 100644 index 0000000..b4bdf64 --- /dev/null +++ b/traccar/rootfs/etc/cont-init.d/30-nginx.sh @@ -0,0 +1,25 @@ +#!/usr/bin/with-contenv bash +# ============================================================================== +# Community Hass.io Add-ons: Traccar +# Configures NGINX for use with the Traccar server +# ============================================================================== +# shellcheck disable=SC1091 +source /usr/lib/hassio-addons/base.sh + +declare certfile +declare keyfile +declare port + +if hass.config.true 'ssl'; then + rm /etc/nginx/nginx.conf + mv /etc/nginx/nginx-ssl.conf /etc/nginx/nginx.conf + + certfile=$(hass.config.get 'certfile') + keyfile=$(hass.config.get 'keyfile') + + sed -i "s/%%certfile%%/${certfile}/g" /etc/nginx/nginx.conf + sed -i "s/%%keyfile%%/${keyfile}/g" /etc/nginx/nginx.conf +fi + +port=$(hass.config.get 'port') +sed -i "s/%%port%%/${port}/g" /etc/nginx/nginx.conf diff --git a/traccar/rootfs/etc/nginx/nginx-ssl.conf b/traccar/rootfs/etc/nginx/nginx-ssl.conf new file mode 100644 index 0000000..e5ddb2a --- /dev/null +++ b/traccar/rootfs/etc/nginx/nginx-ssl.conf @@ -0,0 +1,63 @@ +worker_processes 1; +pid /var/run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + sendfile on; + keepalive_timeout 65; + + upstream traccar { + ip_hash; + server 127.0.0.1:18682; + } + + map $http_upgrade $connection_upgrade { + default upgrade; + '' close; + } + + server { + server_name hassio.local; + listen %%port%% default_server ssl; + root /dev/null; + + ssl_certificate /ssl/%%certfile%%; + ssl_certificate_key /ssl/%%keyfile%%; + ssl_protocols TLSv1.2; + ssl_prefer_server_ciphers on; + ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA; + ssl_ecdh_curve secp384r1; + ssl_session_timeout 10m; + ssl_session_cache shared:SSL:10m; + ssl_session_tickets off; + ssl_stapling on; + ssl_stapling_verify on; + + add_header X-Content-Type-Options nosniff; + add_header X-XSS-Protection "1; mode=block"; + add_header X-Robots-Tag none; + + location / { + proxy_redirect off; + proxy_pass http://traccar; + + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header Host $http_host; + proxy_set_header X-NginX-Proxy true; + if ($uri != '/') { + expires 30d; + } + } + } +} diff --git a/traccar/rootfs/etc/nginx/nginx.conf b/traccar/rootfs/etc/nginx/nginx.conf new file mode 100644 index 0000000..e70aaf6 --- /dev/null +++ b/traccar/rootfs/etc/nginx/nginx.conf @@ -0,0 +1,47 @@ +worker_processes 1; +pid /var/run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + sendfile on; + keepalive_timeout 65; + + upstream traccar { + ip_hash; + server 127.0.0.1:18682; + } + + map $http_upgrade $connection_upgrade { + default upgrade; + '' close; + } + + server { + server_name hassio.local; + listen %%port%% default_server; + root /dev/null; + + location / { + proxy_redirect off; + proxy_pass http://traccar; + + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header Host $http_host; + proxy_set_header X-NginX-Proxy true; + if ($uri != '/') { + expires 30d; + } + } + } +} diff --git a/traccar/rootfs/etc/services.d/nginx/finish b/traccar/rootfs/etc/services.d/nginx/finish new file mode 100644 index 0000000..d7057cc --- /dev/null +++ b/traccar/rootfs/etc/services.d/nginx/finish @@ -0,0 +1,9 @@ +#!/usr/bin/execlineb -S0 +# ============================================================================== +# Community Hass.io Add-ons: Traccar +# Take down the S6 supervision tree when Nginx fails +# ============================================================================== +if -n { s6-test $# -ne 0 } +if -n { s6-test ${1} -eq 256 } + +s6-svscanctl -t /var/run/s6/services diff --git a/traccar/rootfs/etc/services.d/nginx/run b/traccar/rootfs/etc/services.d/nginx/run new file mode 100644 index 0000000..5c3ce34 --- /dev/null +++ b/traccar/rootfs/etc/services.d/nginx/run @@ -0,0 +1,9 @@ +#!/usr/bin/with-contenv bash +# ============================================================================== +# Community Hass.io Add-ons: Traccar +# Runs the Nginx daemon +# ============================================================================== +# shellcheck disable=SC1091 +source /usr/lib/hassio-addons/base.sh + +exec nginx -g "daemon off;" diff --git a/traccar/rootfs/etc/services.d/traccar/finish b/traccar/rootfs/etc/services.d/traccar/finish new file mode 100644 index 0000000..5465a56 --- /dev/null +++ b/traccar/rootfs/etc/services.d/traccar/finish @@ -0,0 +1,9 @@ +#!/usr/bin/execlineb -S0 +# ============================================================================== +# Community Hass.io Add-ons: Traccar +# Take down the S6 supervision tree when the Traccar daemon fails +# ============================================================================== +if -n { s6-test $# -ne 0 } +if -n { s6-test ${1} -eq 256 } + +s6-svscanctl -t /var/run/s6/services diff --git a/traccar/rootfs/etc/services.d/traccar/run b/traccar/rootfs/etc/services.d/traccar/run new file mode 100644 index 0000000..6dce408 --- /dev/null +++ b/traccar/rootfs/etc/services.d/traccar/run @@ -0,0 +1,26 @@ +#!/usr/bin/with-contenv bash +# ============================================================================== +# Community Hass.io Add-ons: Traccar +# Runs the Traccar daemon +# ============================================================================== +# shellcheck disable=SC1091 +source /usr/lib/hassio-addons/base.sh + +declare -a options + +# Memory settings +options+=(-Xms256m) +options+=(-Xmx512m) + +# Prefer IPv4, because of Hassio general issues with IPv6 +options+=("-Djava.net.preferIPv4Stack=true") + +# Run the JAR +options+=(-jar tracker-server.jar) + +# Configuration file +options+=(/config/traccar.xml) + +# Run the Traccar daemon +cd /opt/traccar +exec java "${options[@]}" diff --git a/traccar/rootfs/etc/traccar/hassio.xml b/traccar/rootfs/etc/traccar/hassio.xml new file mode 100644 index 0000000..1fc950e --- /dev/null +++ b/traccar/rootfs/etc/traccar/hassio.xml @@ -0,0 +1,256 @@ + + + + + + + true + 18682 + ./web + 127.0.0.1 + max-age=3600,public + + false + google + + true + info + /dev/stdout + + true + 86400 + + true + true + true + true + + ./media + + web,mail + + true + + true + true + ./schema/changelog-master.xml + org.h2.Driver + jdbc:h2:/data + sa + + + + SELECT * FROM tc_users + WHERE email = :email OR login = :email + + + + SELECT * FROM tc_positions WHERE deviceId = :deviceId AND fixTime BETWEEN :from AND :to ORDER BY fixTime + + + + SELECT tc_positions.* FROM tc_positions INNER JOIN tc_devices ON tc_positions.id = tc_devices.positionid; + + + + UPDATE tc_devices SET positionId = :id WHERE id = :deviceId + + + + SELECT * FROM tc_events WHERE deviceId = :deviceId AND serverTime BETWEEN :from AND :to ORDER BY serverTime + + + + DELETE FROM tc_positions WHERE serverTime < :serverTime AND id NOT IN (SELECT positionId FROM tc_devices WHERE positionId IS NOT NULL) + + + + DELETE FROM tc_events WHERE serverTime < :serverTime + + + + SELECT * FROM tc_statistics WHERE captureTime BETWEEN :from AND :to ORDER BY captureTime + + + 5001 + 5002 + 5003 + 5004 + 5005 + 5006 + false + 5007 + 5008 + 5009 + 5010 + 5011 + 5012 + 5013 + 5014 + 5015 + 5016 + 5017 + 5018 + 5019 + 5020 + 5021 + 5022 + 5023 + 5024 + 5025 + 5026 + 5027 + 5028 + 5029 + 5030 + 5031 + 5032 + 5033 + 5034 + 5035 + 5036 + 5037 + 5038 + 5039 + 5040 + 5041 + 5042 + 5043 + 5044 + 5045 + 5046 + 5047 + 5048 + 5049 + 5050 + 5051 + 5052 + 5053 + 5054 + 5055 + 5056 + 5057 + 5058 + 5059 + 5060 + 5061 + 5062 + 5063 + 5064 + 5065 + 5066 + 5067 + 5068 + 5069 + 5070 + 5071 + 5072 + 5073 + 5074 + 5075 + 5076 + 5077 + 5078 + 5079 + 5080 + 5081 + 5082 + 5083 + 5084 + 5085 + 5086 + 5087 + 5088 + 5089 + 5090 + 5091 + 5092 + 5093 + 5094 + 5095 + 5096 + 5097 + 5098 + 5099 + 5100 + 5101 + 5102 + 5103 + 5104 + 5105 + 5106 + 5107 + 5108 + 5109 + 5110 + 5111 + 5112 + 5113 + 5114 + 5115 + 5116 + 5117 + 5118 + 5119 + 5120 + 5121 + 5122 + 5123 + 5124 + 5125 + 5126 + 5127 + 5128 + 5129 + 5130 + 5131 + 5132 + 5133 + 5134 + 5135 + 5136 + 5137 + 5138 + 5139 + 5140 + 5141 + 5142 + 5143 + 5144 + 5145 + 5146 + 5147 + 5148 + 5149 + 5150 + 5151 + 5152 + 5153 + 5154 + 5155 + 5156 + 5157 + 5158 + 5159 + 5160 + 5161 + 5162 + 5163 + 5164 + 5165 + 5166 + 5167 + 5168 + 5169 + 5170 + 5171 + 5172 + 5173 + 5174 + 5175 + 5176 + 5177 + 5178 + 5179 + + diff --git a/traccar/rootfs/etc/traccar/traccar.xml b/traccar/rootfs/etc/traccar/traccar.xml new file mode 100644 index 0000000..63ddb7e --- /dev/null +++ b/traccar/rootfs/etc/traccar/traccar.xml @@ -0,0 +1,22 @@ + + + + + + + /etc/traccar/hassio.xml + + + + + +