#!/bin/sh
# Phoebus installer launcher (Debian-Live appliance).
#
# Stages the payload to a writable, executable location, puts the bundled
# disk/encryption/filesystem tools on PATH, and runs the static installer.
set -eu
here="$(cd "$(dirname "$0")/.." && pwd)"
stage="${TMPDIR:-/tmp}/phoebus-payload"
if [ ! -x "$stage/bin/phoebus-installer" ]; then
    mkdir -p "$stage"
    cp -a "$here/." "$stage/"
fi
export PATH="$stage/tools/usr/sbin:$stage/tools/usr/bin:$stage/bin:$PATH"
export LD_LIBRARY_PATH="$stage/tools/usr/lib/x86_64-linux-gnu${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
exec "$stage/bin/phoebus-installer" "$@"
