mirror of
https://github.com/home-assistant/operating-system.git
synced 2025-07-24 13:36:31 +00:00
Lint hostapp.sh and robust umount (#406)
* Lint hostapp.sh and robust umount * Update hostapp.sh * Update Dockerfile * Update Dockerfile * Update hassos.mk * Update hostapp.sh * Update Dockerfile * Update hassos.mk * Update hostapp.sh * Update hdd-image.sh * Update entry.sh
This commit is contained in:
parent
d5e6cc78d5
commit
1febb31647
@ -1,10 +1,20 @@
|
||||
FROM alpine:3.9
|
||||
FROM ubuntu:18.04
|
||||
|
||||
# Install packages
|
||||
RUN apk add --no-cache \
|
||||
bash coreutils e2fsprogs curl
|
||||
RUN apk add --no-cache --repository http://nl.alpinelinux.org/alpine/v3.7/community \
|
||||
docker
|
||||
# Set shell
|
||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||
|
||||
# Docker
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
apt-transport-https \
|
||||
ca-certificates \
|
||||
curl \
|
||||
gpg-agent \
|
||||
software-properties-common \
|
||||
&& curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - \
|
||||
&& add-apt-repository "deb https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
|
||||
&& apt-get update && apt-get install -y --no-install-recommends \
|
||||
docker-ce=5:18.09.2~3-0~ubuntu-bionic \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY hostapp.sh /usr/bin/
|
||||
ENTRYPOINT ["/usr/bin/hostapp.sh"]
|
||||
|
@ -73,6 +73,13 @@ done
|
||||
dd if=/dev/zero of=${DATA_IMG} bs=1G count=1
|
||||
mkfs.ext4 -L "hassos-data" -E lazy_itable_init=0,lazy_journal_init=0 ${DATA_IMG}
|
||||
|
||||
# Setup local user
|
||||
if [ "${BUILDER_UID:0}" -ne 0 ] && [ "${BUILDER_GID:0}" -ne 0 ]; then
|
||||
groupadd -g "${BUILDER_GID}" builder
|
||||
useradd -m -u "${BUILDER_UID}" -g "${BUILDER_GID}" -G docker builder
|
||||
chown builder:builder ${DATA_IMG}
|
||||
fi
|
||||
|
||||
# Mount / init file structs
|
||||
mkdir -p /mnt/data/
|
||||
mount -o loop ${DATA_IMG} /mnt/data
|
||||
@ -114,19 +121,26 @@ cat > /mnt/data/hassos.json <<- EOF
|
||||
EOF
|
||||
|
||||
# Setup AppArmor
|
||||
if [ ! -z "${APPARMOR}" ]; then
|
||||
mkdir -p /mnt/data/${APPARMOR}
|
||||
if [ -n "${APPARMOR}" ]; then
|
||||
mkdir -p "/mnt/data/${APPARMOR}"
|
||||
|
||||
# Supervisor
|
||||
if [ ! -z "${SUPERVISOR_PROFILE_URL}" ]; then
|
||||
curl -L -o /mnt/data/${APPARMOR}/${SUPERVISOR_PROFILE} ${SUPERVISOR_PROFILE_URL}
|
||||
if [ -n "${SUPERVISOR_PROFILE_URL}" ]; then
|
||||
curl -sL -o "/mnt/data/${APPARMOR}/${SUPERVISOR_PROFILE}" "${SUPERVISOR_PROFILE_URL}"
|
||||
fi
|
||||
|
||||
# CLI
|
||||
if [ ! -z "${CLI_PROFILE_URL}" ]; then
|
||||
curl -L -o /mnt/data/${APPARMOR}/${CLI_PROFILE} ${CLI_PROFILE_URL}
|
||||
if [ -n "${CLI_PROFILE_URL}" ]; then
|
||||
curl -sL -o "/mnt/data/${APPARMOR}/${CLI_PROFILE}" "${CLI_PROFILE_URL}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Finish
|
||||
kill -TERM $DOCKER_PID && wait $DOCKER_PID && umount /mnt/data
|
||||
kill $DOCKER_PID && wait $DOCKER_PID
|
||||
|
||||
# Unmount resource
|
||||
if ! umount /mnt/data; then
|
||||
umount -f /mnt/data || echo "umount force fails!"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
@ -16,6 +16,7 @@ endef
|
||||
|
||||
define HASSOS_INSTALL_TARGET_CMDS
|
||||
docker run --rm --privileged \
|
||||
-e BUILDER_UID="$(shell id -u)" -e BUILDER_GID="$(shell id -g)" \
|
||||
-v $(BINARIES_DIR):/export \
|
||||
hassos-hostapps \
|
||||
--supervisor $(BR2_PACKAGE_HASSOS_SUPERVISOR) \
|
||||
|
@ -89,10 +89,10 @@ function create_kernel_image() {
|
||||
mkfs.ext4 -L "hassos-kernel" -E lazy_itable_init=0,lazy_journal_init=0 -O ^extent,^64bit "${kernel_img}"
|
||||
|
||||
# Mount / init file structs
|
||||
mkdir -p /mnt/data/
|
||||
mount -o loop "${kernel_img}" /mnt/data
|
||||
cp -f "${kernel}" /mnt/data/
|
||||
umount /mnt/data
|
||||
sudo mkdir -p /mnt/data/
|
||||
sudo mount -o loop "${kernel_img}" /mnt/data
|
||||
sudo cp -f "${kernel}" /mnt/data/
|
||||
sudo umount /mnt/data
|
||||
}
|
||||
|
||||
|
||||
|
@ -9,7 +9,8 @@ dockerd -s vfs &> /dev/null &
|
||||
# Setup local user
|
||||
if [ "${BUILDER_UID:0}" -ne 0 ] && [ "${BUILDER_GID:0}" -ne 0 ]; then
|
||||
groupadd -g "${BUILDER_GID}" builder
|
||||
useradd -m -u "${BUILDER_UID}" -g "${BUILDER_GID}" -G docker builder
|
||||
useradd -m -u "${BUILDER_UID}" -g "${BUILDER_GID}" -G docker,sudo builder
|
||||
echo "builder ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers
|
||||
USER="builder"
|
||||
fi
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user