Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allocate tty for main jobs #42

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions dracut-iguana/iguana/iguana-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 >/dev/tty2 2>&1'
setsid -f -- sh -c "exec /bin/bash <> /dev/${_tty} 2>&1"
fi

function iguana_reboot_action() {
Expand Down Expand Up @@ -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
}
26 changes: 22 additions & 4 deletions dracut-iguana/iguana/iguana.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion iguana-workflow/src/engines/podman.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down