Skip to content
This repository has been archived by the owner on Feb 2, 2022. It is now read-only.

Commit

Permalink
Added entrypoint.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicklas2751 authored Jan 18, 2019
1 parent 14e8a6e commit f5018b7
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions recipes/ubuntu_jdk11/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash
# Copyright (c) 2012-2018 Red Hat, Inc.
# This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v2.0
# which is available at http://www.eclipse.org/legal/epl-2.0.html
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation

set -e

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" | \
sed "s/\${HOME}/\/home\/user/g" > /etc/passwd

cat ${HOME}/group.template | \
sed "s/\${USER_ID}/${USER_ID}/g" | \
sed "s/\${GROUP_ID}/${GROUP_ID}/g" | \
sed "s/\${HOME}/\/home\/user/g" > /etc/group
fi

if test "${USER_ID}" = 0; then
# current user is root
/usr/sbin/sshd -D &
elif sudo -n true > /dev/null 2>&1; then
# current user is a suoder
sudo /usr/sbin/sshd -D &
fi

exec "$@"

0 comments on commit f5018b7

Please sign in to comment.