#!/bin/sh

set -e

# In a privileged container or a VM Corosync and Pacemaker are already
# running, so this operation does not affect them.  In an unprivileged
# container they did not start and need this configuration change:
printf 'system.allow_knet_handle_fallback: yes\n' >>/etc/corosync/corosync.conf
service pacemaker start

OUTPUT="${AUTOPKGTEST_ARTIFACTS:-.}/crm_mon.txt"

# Wait more than dc-deadtime (20s by default)
sleep 25

crm_mon -1 >"$OUTPUT"
cat "$OUTPUT"
fgrep -q "Online: [ node1 ]" "$OUTPUT"
