Skip to content

Commit

Permalink
Fixed home dir if skipper is called from root
Browse files Browse the repository at this point in the history
  • Loading branch information
RazRegev authored and eranco74 committed Sep 17, 2020
1 parent 257223b commit d9a1588
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions skipper/data/skipper-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
#!/usr/bin/env bash

if ! [ -z "${SKIPPER_DOCKER_GID}" ];then

if [ ${SKIPPER_USERNAME} == root ]; then
HOME_DIR=/root
else
HOME_DIR=/home/${SKIPPER_USERNAME}
fi

SKIP_HOME_DIR_PARAM=""

# if home directory already exists, useradd should not try to create it
[ -d /home/${SKIPPER_USERNAME} ] && SKIP_HOME_DIR_PARAM="--no-create-home"
[ -d ${HOME_DIR} ] && SKIP_HOME_DIR_PARAM="--no-create-home"

getent passwd ${SKIPPER_USERNAME} > /dev/null
if [ x"$?" != x"0" ]; then
useradd -u ${SKIPPER_UID} --non-unique ${SKIP_HOME_DIR_PARAM} "${SKIPPER_USERNAME}"
fi

chown ${SKIPPER_USERNAME}:${SKIPPER_USERNAME} /home/${SKIPPER_USERNAME}
chown ${SKIPPER_USERNAME}:${SKIPPER_USERNAME} ${HOME_DIR}

if [ $(getent group docker) ]; then
groupmod -o -g ${SKIPPER_DOCKER_GID} docker
Expand Down

0 comments on commit d9a1588

Please sign in to comment.