Skip to content

Commit

Permalink
Prepare console and run iguana workflow with tty redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
aaannz committed Sep 1, 2023
1 parent 39e2efb commit 1527e9b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
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

0 comments on commit 1527e9b

Please sign in to comment.