diff --git a/traccar/rootfs/etc/cont-init.d/10-requirements.sh b/traccar/rootfs/etc/cont-init.d/10-requirements.sh index 61e171c..667aa98 100644 --- a/traccar/rootfs/etc/cont-init.d/10-requirements.sh +++ b/traccar/rootfs/etc/cont-init.d/10-requirements.sh @@ -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 diff --git a/traccar/rootfs/etc/cont-init.d/20-config.sh b/traccar/rootfs/etc/cont-init.d/20-config.sh index f903313..ab509f2 100644 --- a/traccar/rootfs/etc/cont-init.d/20-config.sh +++ b/traccar/rootfs/etc/cont-init.d/20-config.sh @@ -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 diff --git a/traccar/rootfs/etc/cont-init.d/30-nginx.sh b/traccar/rootfs/etc/cont-init.d/30-nginx.sh index b4bdf64..d5e0853 100644 --- a/traccar/rootfs/etc/cont-init.d/30-nginx.sh +++ b/traccar/rootfs/etc/cont-init.d/30-nginx.sh @@ -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 diff --git a/traccar/rootfs/etc/services.d/nginx/run b/traccar/rootfs/etc/services.d/nginx/run index 5c3ce34..f817a0f 100644 --- a/traccar/rootfs/etc/services.d/nginx/run +++ b/traccar/rootfs/etc/services.d/nginx/run @@ -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;" diff --git a/traccar/rootfs/etc/services.d/traccar/run b/traccar/rootfs/etc/services.d/traccar/run index 9f97b1c..87e2330 100644 --- a/traccar/rootfs/etc/services.d/traccar/run +++ b/traccar/rootfs/etc/services.d/traccar/run @@ -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[@]}"