diff --git a/dracut-iguana/iguana/iguana-lib.sh b/dracut-iguana/iguana/iguana-lib.sh index f6c955f..8e0f62c 100644 --- a/dracut-iguana/iguana/iguana-lib.sh +++ b/dracut-iguana/iguana/iguana-lib.sh @@ -8,9 +8,11 @@ if ! declare -f Echo > /dev/null ; then fi if [ -n "$IGUANA_DEBUG" ]; then - Echo "Debug mode - starting secondary tty2" + #TODO properly find next available console + _tty=/dev/tty2 + Echo "Debug mode - starting secondary ${_tty}" echo "export PS1='iguana@\h:\w> '" > /root/.bashrc - setsid -f -- sh -c 'exec /bin/bash /dev/tty2 2>&1' + setsid -f -- sh -c "exec /bin/bash <> /dev/${_tty} 2>&1" fi function iguana_reboot_action() { @@ -79,3 +81,21 @@ function is_root_encrypted() { lsblk -o FSTYPE -n -l "$device" | grep -q "crypto_LUKS" && return 0 return 1 } + +function prepare_console() { +setterm -msg off 2>/dev/null || true + if ! dbus-send --system --print-reply --dest=org.freedesktop.systemd1 /org/freedesktop/systemd1 \ + org.freedesktop.systemd1.Manager.SetShowStatus string:off &>/dev/null; then + kill -s SIGRTMAX-9 1 + sleep 1 + fi +} + +function restore_console() { + if ! run dbus-send --system --print-reply --dest=org.freedesktop.systemd1 /org/freedesktop/systemd1 \ + org.freedesktop.systemd1.Manager.SetShowStatus string: &>/dev/null; then + kill -s SIGRTMAX-10 1 + fi + sleep 1 + setterm -msg on 2>/dev/null || true +} diff --git a/dracut-iguana/iguana/iguana.sh b/dracut-iguana/iguana/iguana.sh index 4b99728..0db61a6 100755 --- a/dracut-iguana/iguana/iguana.sh +++ b/dracut-iguana/iguana/iguana.sh @@ -115,8 +115,9 @@ if [ -n "$IGUANA_CONTROL_URL" ]; then fi fi +_WORKFLOW="" if [ -f "$IGUANA_URL_WORKFLOW" ]; then - $IGUANA_WORKFLOW "${IGUANA_CMDLINE_EXTRA[@]}" "$IGUANA_URL_WORKFLOW" + _WORKFLOW="$IGUANA_URL_WORKFLOW" elif [ -n "$IGUANA_CONTAINERS" ]; then Echo "Using container list from kcmdline: ${IGUANA_CONTAINERS}" readarray -d , -t container_array <<< "$IGUANA_CONTAINERS" @@ -135,13 +136,30 @@ EOH EOF N=$(( N + 1 )) done - $IGUANA_WORKFLOW "${IGUANA_CMDLINE_EXTRA[@]}" /control_containers.yaml + _WORKFLOW="/control_containers.yaml" # control.yaml is buildin control file in initrd elif [ -f "$IGUANA_BUILDIN_WORKFLOW" ]; then - $IGUANA_WORKFLOW "${IGUANA_CMDLINE_EXTRA[@]}" "$IGUANA_BUILDIN_WORKFLOW" + _WORKFLOW="$IGUANA_BUILDIN_WORKFLOW" fi -Echo "Containers run finished" +if [ ! -f "$_WORKFLOW" ]; then + Echo "ERROR: No usable workflow file found!" + sleep 10 + iguana_reboot_action "reboot" "unless-debug" +fi + +systemctl start iguana-workflow-run + +# monitor workflow until finished + +# TODO get correct tty +prepare_console +if $IGUANA_WORKFLOW "${IGUANA_CMDLINE_EXTRA[@]}" "$_WORKFLOW" <> /dev/tty1 2>&1; then + Echo "Workflow run has finished" +else + Echo "Workflow finished with error!" +fi +restore_console # First if workflow set kernelAction then do that if [ -f /iguana/kernelAction ]; then diff --git a/iguana-workflow/src/engines/podman.rs b/iguana-workflow/src/engines/podman.rs index 1a95a75..8dfa27d 100644 --- a/iguana-workflow/src/engines/podman.rs +++ b/iguana-workflow/src/engines/podman.rs @@ -145,7 +145,7 @@ impl ContainerOps for Podman { if is_service { cmd = cmd.arg("--detach"); } else { - cmd = cmd.arg("--interactive"); + cmd = cmd.args(["--interactive", "--attach=stdin", "--attach=stdout", "--attach=stderr"]); } if !opts.debug {