| 1 | #!/bin/sh |
| 2 | set -eu |
| 3 | arch=$(/bin/busybox uname -m) |
| 4 | case "$arch" in |
| 5 | aarch64) exec >/dev/console 2>&1 ;; |
| 6 | x86_64) exec >/dev/com1 2>&1 ;; |
| 7 | *) exit 1 ;; |
| 8 | esac |
| 9 | finish() { |
| 10 | status=$? |
| 11 | if [ "$status" -ne 0 ]; then echo "VPAC desktop fixture failed"; fi |
| 12 | /sbin/poweroff -f |
| 13 | } |
| 14 | trap finish EXIT |
| 15 | find_command() { |
| 16 | for proc in /proc/[0-9]*; do |
| 17 | [ -r "$proc/cmdline" ] || continue |
| 18 | command=$(tr '\000' ' ' <"$proc/cmdline" 2>/dev/null) || continue |
| 19 | if [ "$command" = "$1 " ]; then echo "${proc##*/}"; return 0; fi |
| 20 | done |
| 21 | return 1 |
| 22 | } |
| 23 | echo 'Checking the first-boot Vinix desktop' |
| 24 | /bin/busybox sha256sum -c /desktop-programs.sha256 |
| 25 | case "$arch" in |
| 26 | aarch64) test "$(readlink /proc/1/exe)" = /sbin/init ;; |
| 27 | x86_64) tr '\000' '\n' </proc/1/cmdline | grep -Fx /sbin/init ;; |
| 28 | esac |
| 29 | watchdog= |
| 30 | watchdog_program=/usr/libexec/vinix-desktop-watchdog |
| 31 | for attempt in $(seq 1 60); do |
| 32 | if [ -x "$watchdog_program" ] && [ -z "$watchdog" ]; then |
| 33 | watchdog=$(find_command "$watchdog_program") || true |
| 34 | fi |
| 35 | if session=$(find_command '/usr/sbin/vinix-session graphical --desktop /usr/bin/vinix-desktop') && |
| 36 | registration=$(find_command '/usr/bin/vinix-desktop --register-only') && |
| 37 | /framebuffer-check; then |
| 38 | if [ -x "$watchdog_program" ]; then |
| 39 | test -n "$watchdog" |
| 40 | echo "desktop watchdog PID $watchdog" |
| 41 | fi |
| 42 | echo "graphical session PID $session, registration PID $registration" |
| 43 | echo 'VPAC FIXTURE GUEST PASS' |
| 44 | exit 0 |
| 45 | fi |
| 46 | sleep 1 |
| 47 | done |
| 48 | ps |
| 49 | exit 1 |
| 50 | |