diff --git a/src/disk.sh b/src/disk.sh index 6c8dd33..3a1ff6d 100644 --- a/src/disk.sh +++ b/src/disk.sh @@ -522,7 +522,9 @@ addDevice () { return 0 } -html "Initializing disks..." +msg="Initializing disks..." +html "$msg" +[[ "$DEBUG" == [Yy1]* ]] && echo "$msg" [ -z "${DISK_OPTS:-}" ] && DISK_OPTS="" [ -z "${DISK_TYPE:-}" ] && DISK_TYPE="scsi" diff --git a/src/display.sh b/src/display.sh index 2affc00..9ee0af4 100644 --- a/src/display.sh +++ b/src/display.sh @@ -18,6 +18,10 @@ if [[ "$GPU" != [Yy1]* || "$CPU_VENDOR" != "GenuineIntel" || "$ARCH" != "amd64" fi +msg="Configuring display drivers..." +html "$msg" +[[ "$DEBUG" == [Yy1]* ]] && echo "$msg" + DISPLAY_OPTS="-display egl-headless,rendernode=$RENDERNODE" DISPLAY_OPTS+=" -vga $VGA" diff --git a/src/entry.sh b/src/entry.sh index 7180f7e..df0460d 100755 --- a/src/entry.sh +++ b/src/entry.sh @@ -6,6 +6,7 @@ set -Eeuo pipefail cd /run +. start.sh # Placeholder . utils.sh # Load functions . reset.sh # Initialize system . install.sh # Run installation diff --git a/src/install.sh b/src/install.sh index e89f3c9..6abe518 100644 --- a/src/install.sh +++ b/src/install.sh @@ -31,8 +31,9 @@ if [ -n "$URL" ] && [ ! -s "$FILE" ] && [ ! -d "$DIR" ]; then BASE=$(basename "$URL" .pat) if [ ! -s "$STORAGE/$BASE.system.img" ]; then BASE=$(basename "${URL%%\?*}" .pat) - : "${BASE//+/ }"; printf -v BASE '%b' "${_//%/\\x}" - BASE=$(echo "$BASE" | sed -e 's/[^A-Za-z0-9._-]/_/g') + BASE="${BASE//+/ }" + printf -v BASE '%b' "${BASE//%/\\x}" + BASE="${BASE//[!A-Za-z0-9._-]/_}" fi if [[ "${URL,,}" != "http"* && "${URL,,}" != "file:"* ]] ; then [ ! -s "$STORAGE/$BASE.pat" ] && error "Invalid URL: $URL" && exit 65 @@ -65,8 +66,9 @@ fi if [ ! -s "$FILE" ]; then BASE=$(basename "${URL%%\?*}" .pat) - : "${BASE//+/ }"; printf -v BASE '%b' "${_//%/\\x}" - BASE=$(echo "$BASE" | sed -e 's/[^A-Za-z0-9._-]/_/g') + BASE="${BASE//+/ }" + printf -v BASE '%b' "${BASE//%/\\x}" + BASE="${BASE//[!A-Za-z0-9._-]/_}" fi if [[ "$URL" != "file://$STORAGE/$BASE.pat" ]]; then diff --git a/src/network.sh b/src/network.sh index 1d96a9c..b3e8d98 100644 --- a/src/network.sh +++ b/src/network.sh @@ -29,6 +29,8 @@ ADD_ERR="Please add the following setting to your container:" configureDHCP() { + [[ "$DEBUG" == [Yy1]* ]] && echo "Configuring MACVTAP networking..." + # Create the necessary file structure for /dev/vhost-net if [ ! -c /dev/vhost-net ]; then if mknod /dev/vhost-net c 10 238; then @@ -125,6 +127,7 @@ configureDNS() { DNSMASQ_OPTS+=" --address=/host.lan/${VM_NET_IP%.*}.1" DNSMASQ_OPTS=$(echo "$DNSMASQ_OPTS" | sed 's/\t/ /g' | tr -s ' ' | sed 's/^ *//') + [[ "$DEBUG" == [Yy1]* ]] && echo "Starting Dnsmasq daemon..." if [[ "${DEBUG_DNS:-}" == [Yy1]* ]]; then DNSMASQ_OPTS+=" -d" @@ -188,6 +191,8 @@ getHostPorts() { configureUser() { + [[ "$DEBUG" == [Yy1]* ]] && echo "Configuring SLIRP networking..." + if [ -z "$IP6" ]; then NET_OPTS="-netdev user,id=hostnet0,host=${VM_NET_IP%.*}.1,net=${VM_NET_IP%.*}.0/24,dhcpstart=$VM_NET_IP,hostname=$VM_NET_HOST" else @@ -206,6 +211,8 @@ configureNAT() { local tuntap="TUN device is missing. $ADD_ERR --device /dev/net/tun" local tables="The 'ip_tables' kernel module is not loaded. Try this command: sudo modprobe ip_tables iptable_nat" + [[ "$DEBUG" == [Yy1]* ]] && echo "Configuring NAT networking..." + # Create the necessary file structure for /dev/net/tun if [ ! -c /dev/net/tun ]; then [[ "$PODMAN" == [Yy1]* ]] && return 1 @@ -487,6 +494,8 @@ if [[ "$NETWORK" == [Nn]* ]]; then return 0 fi +[[ "$DEBUG" == [Yy1]* ]] && echo "Retrieving network information..." + getInfo html "Initializing network..." diff --git a/src/reset.sh b/src/reset.sh index ec9dca9..8009050 100644 --- a/src/reset.sh +++ b/src/reset.sh @@ -2,6 +2,7 @@ set -Eeuo pipefail trap 'error "Status $? while: $BASH_COMMAND (line $LINENO/$BASH_LINENO)"' ERR +[[ "${TRACE:-}" == [Yy1]* ]] && set -o functrace && trap 'echo "# $BASH_COMMAND" >&2' DEBUG [ ! -f "/run/entry.sh" ] && error "Script must run inside Docker container!" && exit 11 [ "$(id -u)" -ne "0" ] && error "Script must be executed with root privileges." && exit 12 diff --git a/src/start.sh b/src/start.sh new file mode 100644 index 0000000..55f6874 --- /dev/null +++ b/src/start.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -Eeuo pipefail + +# Override this placeholder file using a Docker bind to execute a script during startup!