mirror of
https://github.com/hassio-addons/addon-traccar.git
synced 2025-05-05 03:21: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
|
# Community Hass.io Add-ons: Traccar
|
||||||
# This files check if all user configuration requirements are met
|
# This files check if all user configuration requirements are met
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# shellcheck disable=SC1091
|
bashio::config.require.ssl
|
||||||
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
|
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
#!/usr/bin/with-contenv bash
|
#!/usr/bin/with-contenv bashio
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Community Hass.io Add-ons: Traccar
|
# Community Hass.io Add-ons: Traccar
|
||||||
# Ensures the user configuration file is present
|
# Ensures the user configuration file is present
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# shellcheck disable=SC1091
|
if ! bashio::fs.file_exists "/config/traccar.xml"; then
|
||||||
source /usr/lib/hassio-addons/base.sh
|
|
||||||
|
|
||||||
if ! hass.file_exists "/config/traccar.xml"; then
|
|
||||||
cp /etc/traccar/traccar.xml /config/traccar.xml
|
cp /etc/traccar/traccar.xml /config/traccar.xml
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,25 +1,22 @@
|
||||||
#!/usr/bin/with-contenv bash
|
#!/usr/bin/with-contenv bashio
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Community Hass.io Add-ons: Traccar
|
# Community Hass.io Add-ons: Traccar
|
||||||
# Configures NGINX for use with the Traccar server
|
# Configures NGINX for use with the Traccar server
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# shellcheck disable=SC1091
|
|
||||||
source /usr/lib/hassio-addons/base.sh
|
|
||||||
|
|
||||||
declare certfile
|
declare certfile
|
||||||
declare keyfile
|
declare keyfile
|
||||||
declare port
|
declare port
|
||||||
|
|
||||||
if hass.config.true 'ssl'; then
|
if bashio::config.true 'ssl'; then
|
||||||
rm /etc/nginx/nginx.conf
|
rm /etc/nginx/nginx.conf
|
||||||
mv /etc/nginx/nginx-ssl.conf /etc/nginx/nginx.conf
|
mv /etc/nginx/nginx-ssl.conf /etc/nginx/nginx.conf
|
||||||
|
|
||||||
certfile=$(hass.config.get 'certfile')
|
certfile=$(bashio::config 'certfile')
|
||||||
keyfile=$(hass.config.get 'keyfile')
|
keyfile=$(bashio::config 'keyfile')
|
||||||
|
|
||||||
sed -i "s/%%certfile%%/${certfile}/g" /etc/nginx/nginx.conf
|
sed -i "s/%%certfile%%/${certfile}/g" /etc/nginx/nginx.conf
|
||||||
sed -i "s/%%keyfile%%/${keyfile}/g" /etc/nginx/nginx.conf
|
sed -i "s/%%keyfile%%/${keyfile}/g" /etc/nginx/nginx.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
port=$(hass.config.get 'port')
|
port=$(bashio::config 'port')
|
||||||
sed -i "s/%%port%%/${port}/g" /etc/nginx/nginx.conf
|
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
|
# Community Hass.io Add-ons: Traccar
|
||||||
# Runs the Nginx daemon
|
# Runs the Nginx daemon
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# shellcheck disable=SC1091
|
bashio::log.info "Starting NGinx server..."
|
||||||
source /usr/lib/hassio-addons/base.sh
|
|
||||||
|
|
||||||
exec nginx -g "daemon off;"
|
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
|
# Community Hass.io Add-ons: Traccar
|
||||||
# Runs the Traccar daemon
|
# Runs the Traccar daemon
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# shellcheck disable=SC1091
|
|
||||||
source /usr/lib/hassio-addons/base.sh
|
|
||||||
|
|
||||||
declare -a options
|
declare -a options
|
||||||
|
|
||||||
|
bashio::log.info "Starting Traccar server..."
|
||||||
|
|
||||||
# Memory settings
|
# Memory settings
|
||||||
options+=(-Xms256m)
|
options+=(-Xms256m)
|
||||||
options+=(-Xmx512m)
|
options+=(-Xmx512m)
|
||||||
|
@ -22,6 +21,6 @@ options+=(-jar tracker-server.jar)
|
||||||
options+=(/config/traccar.xml)
|
options+=(/config/traccar.xml)
|
||||||
|
|
||||||
# Run the Traccar daemon
|
# 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[@]}"
|
exec java "${options[@]}"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue