Justfile/shell: experiment to verify server via VNC/SSH
This commit is contained in:
parent
67674b86a4
commit
ecd75c182f
2 changed files with 31 additions and 0 deletions
27
Justfile
27
Justfile
|
@ -99,3 +99,30 @@ disk-umount dir:
|
|||
# Perform an offline installation on the mounted target disk, specified by device configuration directory
|
||||
disk-install dir: _render_templates
|
||||
just -v _device diskInstall {{dir}} --argstr rebuildarg "dummy"
|
||||
|
||||
verify-vnc sshserver attempts="10":
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
export MAGICK_ARGS="-filter Catrom -density 72 -resample 300 -contrast -normalize -despeckle -type grayscale -sharpen 1 -posterize 3 -negate -gamma 100 -blur 1x65535"
|
||||
export TESS_ARGS="-c debug_file=/dev/null --psm 4"
|
||||
|
||||
send_and_compare() {
|
||||
local EXPECT="$(pwgen -0 12)"
|
||||
ssh -4 ${SSHOPTS} root@{{sshserver}} "echo -e '\0033\0143'${EXPECT}>> /dev/tty0" 1>/dev/null 2>&1
|
||||
vncdo --server=${VNCSOCK} --password=${VNCPW} --disable-desktop-resizing --nocursor capture $PWD/screenshot.bmp
|
||||
convert ${MAGICK_ARGS} screenshot.bmp screenshot.tiff
|
||||
tesseract ${TESS_ARGS} screenshot.tiff screenshot
|
||||
grep --quiet ${EXPECT} screenshot.txt
|
||||
}
|
||||
|
||||
trap "E=$?; set +e; rm screenshot.*; echo Exiting...; exit $E" INT TERM HUP
|
||||
|
||||
for i in `seq 1 {{attempts}}`; do
|
||||
if send_and_compare; then
|
||||
echo Verification succeeded at attempt $i. Unlocking remote drive...
|
||||
# TODO: unlock drive
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
echo Verification failed {{attempts}} times. Giving up...
|
||||
exit 1
|
||||
|
|
|
@ -11,6 +11,10 @@ stdenv.mkDerivation {
|
|||
git-crypt
|
||||
vcsh
|
||||
gnupg
|
||||
|
||||
vncdo
|
||||
tesseract
|
||||
imagemagick
|
||||
];
|
||||
|
||||
# Set Environment Variables
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue