#!/bin/sh -eu

# This is the install script for Cockpit when run in a privileged container
#
# The host file system must be mounted at /host

cd /
PATH="/bin:/sbin"

if [ ! -d /host/etc -o ! -d /host/proc -o ! -d /host/var/run ]; then
    echo "host file system is not mounted at /host" >&2
    exit 1
fi
if [ ! -f /host/usr/bin/cockpit-bridge ]; then
    echo "cockpit-bridge must be installed in the host" >&2
    exit 1
fi
if [ ! -d /host/usr/share/cockpit ]; then
    echo "cockpit-system and other resources must be installed in the host" >&2
    exit 1
fi
if [ -f /host/usr/libexec/cockpit-ws ]; then
    echo "cockpit-ws must not be installed in the host" >&2
    exit 1
fi

set -x

# Everything else is settings and should remain
rm -f /host/etc/pam.d/cockpit
rm -f /host/etc/systemd/system/cockpit.service
