Skip to content

Commit

Permalink
Run tests in Docker as current user (apache#5086)
Browse files Browse the repository at this point in the history
* Run tests in Docker as current user

* chmod lib directory
  • Loading branch information
lxn2 authored and piiswrong committed Feb 21, 2017
1 parent 94de855 commit 2a7d6f2
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/jenkins/run_as_user.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

if [[ ! $1 || ! $2 || ! $3 || ! $4 || ! $5 ]];
then
echo "USAGE: " $(basename $"0") "USER_ID USER_NAME GROUP_ID GROUP_NAME SCRIPT"
exit 1
fi

USER_ID=$1
USER_NAME=$2
GROUP_ID=$3
GROUP_NAME=$4
SCRIPT=$5

HOME_DIR=/home/${USER_NAME}

groupadd -f -g ${GROUP_ID} ${GROUP_NAME}
useradd -m -u ${USER_ID} -g ${GROUP_NAME} ${USER_NAME}
chown -R ${USER_NAME}:${GROUP_NAME} ${HOME_DIR}
chown -R ${USER_NAME}:${GROUP_NAME} /usr/local/lib/
su -m ${USER_NAME} -c "export HOME=${HOME_DIR}; ${SCRIPT}"

0 comments on commit 2a7d6f2

Please sign in to comment.