#!/bin/sh

# HDSatelit: imaginea pornita din NeoBoot (/.multinfo) nu scrie memoria interna, care e a imaginii gazda
if [ -e /.multinfo ]; then
	echo "ofgwrite: the image runs from NeoBoot (/.multinfo); the internal flash belongs to the host image, nothing is written" >&2
	echo "ofgwrite: update this image from NeoBoot, or boot the image in the internal flash" >&2
	exit 1
fi

mkdir -p /newroot || exit 1
if ! awk '$2 == "/newroot" && $3 == "tmpfs" { found=1 } END { exit found ? 0 : 1 }' /proc/mounts; then
	mount -t tmpfs tmpfs /newroot || exit 1
fi
cp -p /usr/bin/ofgwrite_bin /newroot/ || exit 1
exec /newroot/ofgwrite_bin "$@"
