7bc1c4e
#!/bin/sh -eu
7bc1c4e
7bc1c4e
# This is the install script for cockpit-ws when run in a privileged container
7bc1c4e
# We expect that cockpit-bridge and related stuff is already in the host.
7bc1c4e
#
7bc1c4e
# The host file system must be mounted at /host
7bc1c4e
7bc1c4e
cd /
7bc1c4e
PATH="/bin:/sbin"
7bc1c4e
7bc1c4e
if [ ! -d /host/etc -o ! -d /host/proc -o ! -d /host/var/run ]; then
7bc1c4e
    echo "cockpit-run: host file system is not mounted at /host" >&2
7bc1c4e
    exit 1
7bc1c4e
fi
7bc1c4e
if [ ! -f /host/usr/bin/cockpit-bridge ]; then
7bc1c4e
    echo "cockpit-run: cockpit-bridge must be installed in the host" >&2
7bc1c4e
    exit 1
7bc1c4e
fi
7bc1c4e
if [ ! -d /host/usr/share/cockpit ]; then
7bc1c4e
    echo "cockpit-run: cockpit-shell and other resources must be installed in the host" >&2
7bc1c4e
    exit 1
7bc1c4e
fi
7bc1c4e
if [ -f /host/usr/libexec/cockpit-ws ]; then
7bc1c4e
    echo "cockpit-ws must not be installed in the host" >&2
7bc1c4e
    exit 1
7bc1c4e
fi
7bc1c4e
7bc1c4e
set -x
7bc1c4e
7bc1c4e
# Copy the cockpit pam file into the host, since the PAM stack is gonna run
7bc1c4e
# on the host with host PAM modules, and the host files, such as /etc/shadow
7bc1c4e
# However we must ensure that it doesn't have selinux stuff ... because well,
7bc1c4e
# containers and SELinux don't mix (yet?)
7bc1c4e
sed -e '/pam_selinux/d' -e '/pam_sepermit/d' /etc/pam.d/cockpit > /host/etc/pam.d/cockpit
7bc1c4e
7bc1c4e
# Make sure that we have required directories in the host
7bc1c4e
mkdir -p /host/etc/cockpit/ws-certs.d
7bc1c4e
chmod 755 /host/etc/cockpit/ws-certs.d
7bc1c4e
chown root:root /host/etc/cockpit/ws-certs.d
7bc1c4e
7bc1c4e
mkdir -p /host/var/lib/cockpit
7bc1c4e
chmod 775 /host/var/lib/cockpit
7bc1c4e
chown root:wheel /host/var/lib/cockpit
7bc1c4e
7bc1c4e
# Ensure we have certificates
7bc1c4e
/bin/mount --bind /host/etc/cockpit /etc/cockpit
7bc1c4e
/usr/sbin/remotectl certificate --ensure