30 lines
821 B
Bash
Executable File
30 lines
821 B
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Copyright (c) 2019 Red Hat, Inc.
|
|
# This program and the accompanying materials are made
|
|
# available under the terms of the Eclipse Public License 2.0
|
|
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
#
|
|
# SPDX-License-Identifier: EPL-2.0
|
|
#
|
|
# Contributors:
|
|
# Red Hat, Inc. - initial API and implementation
|
|
#
|
|
|
|
export USER_ID=$(id -u)
|
|
export GROUP_ID=$(id -g)
|
|
if ! grep -Fq "${USER_ID}" /etc/passwd; then
|
|
# current user is an arbitrary
|
|
# user (its uid is not in the
|
|
# container /etc/passwd). Let's fix that
|
|
cat ${HOME}/.passwd.template | \
|
|
sed "s/\${USER_ID}/${USER_ID}/g" | \
|
|
sed "s/\${GROUP_ID}/${GROUP_ID}/g" > /etc/passwd
|
|
|
|
cat ${HOME}/.group.template | \
|
|
sed "s/\${USER_ID}/${USER_ID}/g" | \
|
|
sed "s/\${GROUP_ID}/${GROUP_ID}/g" > /etc/group
|
|
fi
|
|
|
|
exec "$@"
|