#!/bin/sh
set -ex

# juju < 1.23 doesn't support systemd so switch back to upstart
if [ -d /run/systemd/system ]; then
    if [ ! -x /tmp/autopkgtest-reboot ]; then
        echo "SKIP: testbed does not support reboot"
        exit 0
    fi
    if [ -n "${ADT_REBOOT_MARK:-}" ]; then
        echo "SKIP: Reboot with upstart still runs systemd; using init= ?"
        exit 0
    fi
    echo "Installing upstart..."
    apt-get install -y upstart-sysv
    echo "Rebooting into upstart..."
    /tmp/autopkgtest-reboot b1
fi

sh debian/tests/normal-user.sh debian/tests/local-provider
