#!/bin/bash

#======================================
# Greeting...
#--------------------------------------
echo "Configure image: [$kiwi_iname]..."

#======================================
# Remove locale files
#--------------------------------------
(cd /usr/share/locale && find -name '*.mo' | xargs rm)

# Make sure harbor user and groups have always same UID:GID in the container
GROUPID=10000
USERID=10000
USERNAME=harbor
GROUPNAME=harbor
HOMEDIR=/var/lib/harbor

if getent group $GROUPNAME >/dev/null; then
    groupmod -g $GROUPID $GROUPNAME
else
    groupadd -r -g $GROUPID $GROUPNAME
fi

if getent passwd $USERNAME >/dev/null; then
    usermod -u $USERID $USERNAME
    chown -R $USERNAME:$GROUPNAME $HOMEDIR
else
    useradd -r -g $GROUPNAME -d $HOMEDIR -s /sbin/nologin -m -l -c "user for Harbor registry" -u $USERID $USERNAME
fi

exit 0
