#!/bin/bash
#
# Copyright (c) Authors: https://www.armbian.com/authors
#
# armbian-install - compatibility shim.
#
# The installer was redesigned as an armbian-config module (module_partitioner,
# backed by the module_install_engine library) so the logic is unit- and
# loopback-tested in CI instead of hand-verified on hardware. This wrapper keeps
# the historical /usr/bin/armbian-install entrypoint and forwards every argument
# to that module unchanged:
#
#   armbian-install                                     interactive TUI
#   armbian-install --target /dev/sdX --boot emmc --fs ext4 --yes
#   armbian-install --api detect | plan ...             machine-readable
#

trap "systemctl start docker >/dev/null 2>&1; exit" INT TERM

# Re-exec as root if needed.
[[ $EUID != 0 ]] && exec sudo "$0" "$@"

if ! command -v armbian-config >/dev/null 2>&1; then
	echo "armbian-install now ships as part of armbian-config." >&2
	echo "Install it with:  apt-get install armbian-config" >&2
	exit 1
fi

exec armbian-config --api module_partitioner "$@"
