#!/usr/bin/env bash set -Eeuo pipefail source_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) subject=${source_root}/scripts/guanghu-master-init.sh bash -n "$subject" grep -Fq 'readonly NODE_ID=JD-FD-PRIMARY' "$subject" grep -Fq 'readonly INSTANCE_ID=f3d4b730-7f02-452f-975b-7091a4800431' "$subject" grep -Fq '[[ $$ -eq 1 ]]' "$subject" grep -Fq "if [[ \$\$ -ne 1 ]]" "$subject" grep -Fq "GUANGHU_MASTER_REFUSED: run mode requires PID 1" "$subject" grep -Fq '\"control\":\"GUANGHU_OS_MASTER\"' "$subject" grep -Fq '\"full_linux_userspace\":\"DORMANT\"' "$subject" grep -Fq '/usr/bin/grub-editenv /boot/grub/grubenv set next_entry=' "$subject" grep -Fq 'start_root sshd /usr/sbin/sshd -D -e' "$subject" grep -Fq 'mount -o remount,rw /' "$subject" grep -Fq 'start_guanghu repository-bridge' "$subject" grep -Fq 'start_guanghu app-hub' "$subject" grep -Fq 'start_guanghu navigation-bridge' "$subject" grep -Fq '[[ ",$expected," == *",$code,"* ]]' "$subject" grep -Fq 'wait_http code-projection http://127.0.0.1:8088/code/ 200,303' "$subject" grep -Fq 'wait_http navigation-bridge http://127.0.0.1:3922/v1/anchor 200' "$subject" if grep -Eq '(^|[[:space:]])(systemd|/sbin/init)([[:space:]]|$)' "$subject"; then echo 'full Linux init must remain dormant' >&2 exit 1 fi echo GUANGHU_MASTER_INIT_CONTRACT_OK