question: protected String wrapLinuxCommand ( String command ) throws IOException , InterruptedException { String setGroup = "export GROUP_NAME=`(getent group " + getGid ( ) + " || (groupadd -g " + getGid ( ) + " user && echo user:x:" + getGid ( ) + ")) | cut -d: -f1`" ; String setUser = "export USER_NAME=`(getent passwd " + getUid ( ) + " || (useradd -u " + getUid ( ) + " -g ${GROUP_NAME} user && echo user:x:" + getGid ( ) + ")) | cut -d: -f1`" ; String chownCommand = "chown --silent -R ${USER_NAME}.${GROUP_NAME} /usr/src/app || true" ; return setGroup + " && " + setUser + " && " + chownCommand + " && " + command + " && " + chownCommand ; }
target:  Wrap the given command into a command with chown. Also add group/user that match host environment if not exists