mirror of
https://github.com/home-assistant/operating-system.git
synced 2025-11-09 02:48:33 +00:00
* Prevent root from running the enter.sh helper script Since configure doesn't like being ran as root, check in the enter.sh script that the user running it is not UID/GID 0. The script itself takes care of running what needs to be executed privileged with explicit sudo commands. Fixes #4214 * Reword the error message Co-authored-by: Stefan Agner <stefan@agner.ch>
32 lines
847 B
Bash
Executable File
32 lines
847 B
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
BUILDER_UID="$(id -u)"
|
|
BUILDER_GID="$(id -g)"
|
|
CACHE_DIR="${CACHE_DIR:-$HOME/hassos-cache}"
|
|
ARGS="$*"
|
|
COMMAND="${ARGS:-bash}"
|
|
|
|
if [ "$BUILDER_UID" -eq "0" ] || [ "$BUILDER_GID" == "0" ]; then
|
|
echo "ERROR: Please run this script as a regular (non-root) user with sudo privileges."
|
|
exit 1
|
|
fi
|
|
|
|
sudo mkdir -p "${CACHE_DIR}"
|
|
sudo chown -R "${BUILDER_UID}:${BUILDER_GID}" "${CACHE_DIR}"
|
|
sudo docker build -t hassos:local .
|
|
|
|
if [ ! -f buildroot/Makefile ]; then
|
|
# Initialize git submodule
|
|
git submodule update --init
|
|
fi
|
|
|
|
# Make sure loop devices are present before starting the container
|
|
sudo losetup -f > /dev/null
|
|
|
|
# shellcheck disable=SC2086
|
|
sudo docker run -it --rm --privileged \
|
|
-v "$(pwd):/build" -v "${CACHE_DIR}:/cache" \
|
|
-e BUILDER_UID="${BUILDER_UID}" -e BUILDER_GID="${BUILDER_GID}" \
|
|
hassos:local ${COMMAND}
|