mirror of
https://github.com/hassio-addons/addon-traccar.git
synced 2025-05-04 19:11:31 +00:00
🔨 Rewrite add-on onto Bashio
This commit is contained in:
parent
74b9c35ea0
commit
17c090a97b
5 changed files with 15 additions and 44 deletions
|
@ -1,26 +1,6 @@
|
|||
#!/usr/bin/with-contenv bash
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# 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
|
||||
bashio::config.require.ssl
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
#!/usr/bin/with-contenv bash
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# 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
|
||||
if ! bashio::fs.file_exists "/config/traccar.xml"; then
|
||||
cp /etc/traccar/traccar.xml /config/traccar.xml
|
||||
fi
|
||||
|
|
|
@ -1,25 +1,22 @@
|
|||
#!/usr/bin/with-contenv bash
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# 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
|
||||
if bashio::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')
|
||||
certfile=$(bashio::config 'certfile')
|
||||
keyfile=$(bashio::config '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')
|
||||
port=$(bashio::config 'port')
|
||||
sed -i "s/%%port%%/${port}/g" /etc/nginx/nginx.conf
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
#!/usr/bin/with-contenv bash
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Community Hass.io Add-ons: Traccar
|
||||
# Runs the Nginx daemon
|
||||
# ==============================================================================
|
||||
# shellcheck disable=SC1091
|
||||
source /usr/lib/hassio-addons/base.sh
|
||||
|
||||
bashio::log.info "Starting NGinx server..."
|
||||
exec nginx -g "daemon off;"
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
#!/usr/bin/with-contenv bash
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Community Hass.io Add-ons: Traccar
|
||||
# Runs the Traccar daemon
|
||||
# ==============================================================================
|
||||
# shellcheck disable=SC1091
|
||||
source /usr/lib/hassio-addons/base.sh
|
||||
|
||||
declare -a options
|
||||
|
||||
bashio::log.info "Starting Traccar server..."
|
||||
|
||||
# Memory settings
|
||||
options+=(-Xms256m)
|
||||
options+=(-Xmx512m)
|
||||
|
@ -22,6 +21,6 @@ options+=(-jar tracker-server.jar)
|
|||
options+=(/config/traccar.xml)
|
||||
|
||||
# Run the Traccar daemon
|
||||
cd /opt/traccar || hass.die "Failed to switch to Traccar directory"
|
||||
cd /opt/traccar || bashio::exit.nok "Failed to switch to Traccar directory"
|
||||
|
||||
exec java "${options[@]}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue