#!/bin/sh

if [ -f /target/var/lib/dpkg/info/epoptes.postinst ]; then
    # Generate new keys
    rm -f /target/etc/epoptes/*
    chroot /target /var/lib/dpkg/info/epoptes.postinst configure

    # Add user to epoptes group
    username=$(chroot /target getent passwd 1000 | cut -d: -f1)
    if [ -n "$username" ]; then
        chroot /target/ adduser $username epoptes
    fi
fi
