#!/bin/shset -euxcd "${0%/*}/../.."FLATPAK_ID="${1:-org.cockpit_project.CockpitClient}"# We need to setup an entry in the ssh config, but this is difficult:# if this script is run by a normal user then they probably already# have their own configuration, and we need to be careful not to change# that.if mkdir ~/.ssh; then# ~/.ssh didn't exist yet. Assume that we're safe to configure this.echo 'Include cockpit-client-test.config' > ~/.ssh/configtrap 'rm -rf ~/.ssh' EXIT INT QUIT PIPEelse# There's already a ~/.ssh directory. Don't modify that, but check it.if ! grep -q 'Include cockpit-client-test.config' ~/.ssh/config; thenecho 'Please add "Include cockpit-client-test.config" to your ssh config'exit 1fifirm -f cockpit-client-test-*-*-*cat > ~/.ssh/cockpit-client-test.config <<EOFHost cockpit-client-testProxyCommand touch $PWD/cockpit-client-test-%r-%h-%pEOFflatpak run "${FLATPAK_ID}" &CLIENT_PID=$!# wait until it comes upgdbus wait --session org.cockpit_project.CockpitClient# test some stufftest ! -f cockpit-client-test-"${USER}"-cockpit-client-test-22grep "${USER} cockpit-client-test 22" cockpit-client-test.log && exit 1gapplication action "${FLATPAK_ID}" open-path '"=cockpit-client-test"'until test -f cockpit-client-test-"${USER}"-cockpit-client-test-22; do sleep 0.5; donetest ! -f cockpit-client-test-rupert-cockpit-client-test-22grep "rupert cockpit-client-test 22" cockpit-client-test.log && exit 1gapplication action "${FLATPAK_ID}" open-path '"=rupert@cockpit-client-test"'until test -f cockpit-client-test-rupert-cockpit-client-test-22; do sleep 0.5; donegapplication action "${FLATPAK_ID}" quitwait $CLIENT_PIDrm cockpit-client-test-*-*-*# Check if we can start via pure DBus activationtest ! -f cockpit-client-test-"${USER}"-cockpit-client-test-22gapplication action "${FLATPAK_ID}" open-path '"=cockpit-client-test"'until test -f cockpit-client-test-"${USER}"-cockpit-client-test-22; do sleep 0.5; donegapplication action "${FLATPAK_ID}" quitwhile flatpak ps | grep org.cockpit_project.CockpitClient; do sleep 1; donerm cockpit-client-test-*-*-*