2024-08-05 06:15:19 +02:00
|
|
|
#!/usr/bin/env bash
|
2021-09-20 09:07:38 +02:00
|
|
|
|
|
|
|
# If /cache is mounted, use that as PIO's coredir
|
|
|
|
# otherwise use path in /config (so that PIO packages aren't downloaded on each compile)
|
|
|
|
|
|
|
|
if [[ -d /cache ]]; then
|
2021-09-22 10:32:39 +02:00
|
|
|
pio_cache_base=/cache/platformio
|
2021-09-20 09:07:38 +02:00
|
|
|
else
|
2021-09-22 10:32:39 +02:00
|
|
|
pio_cache_base=/config/.esphome/platformio
|
2021-09-20 09:07:38 +02:00
|
|
|
fi
|
|
|
|
|
2021-09-22 10:32:39 +02:00
|
|
|
if [[ ! -d "${pio_cache_base}" ]]; then
|
|
|
|
echo "Creating cache directory ${pio_cache_base}"
|
2021-09-20 09:07:38 +02:00
|
|
|
echo "You can change this behavior by mounting a directory to the container's /cache directory."
|
2021-09-22 10:32:39 +02:00
|
|
|
mkdir -p "${pio_cache_base}"
|
2021-09-20 09:07:38 +02:00
|
|
|
fi
|
|
|
|
|
2021-09-22 10:32:39 +02:00
|
|
|
# we can't set core_dir, because the settings file is stored in `core_dir/appstate.json`
|
|
|
|
# setting `core_dir` would therefore prevent pio from accessing
|
|
|
|
export PLATFORMIO_PLATFORMS_DIR="${pio_cache_base}/platforms"
|
|
|
|
export PLATFORMIO_PACKAGES_DIR="${pio_cache_base}/packages"
|
|
|
|
export PLATFORMIO_CACHE_DIR="${pio_cache_base}/cache"
|
|
|
|
|
2024-02-25 23:26:08 +01:00
|
|
|
# If /build is mounted, use that as the build path
|
|
|
|
# otherwise use path in /config (so that builds aren't lost on container restart)
|
|
|
|
if [[ -d /build ]]; then
|
|
|
|
export ESPHOME_BUILD_PATH=/build
|
|
|
|
fi
|
|
|
|
|
2021-09-20 09:07:38 +02:00
|
|
|
exec esphome "$@"
|