41965086ba65a8a90be7d6689d66c14ea6a42979
[plcapi.git] / tests / ci / setup / create_user.sh
1 #!/bin/sh
2
3 # @todo set up the same user for running tests as on travis (ie. 'travis'), or maybe user 'user' ?
4 # @todo make the GID & UID of the user variable (we picked 2000 as it is the one used by default by Travis)
5
6 set -e
7
8 USERNAME="${1:-test}"
9
10 addgroup --gid 2000 "${USERNAME}"
11 adduser --system --uid=2000 --gid=2000 --home "/home/${USERNAME}" --shell /bin/bash "${USERNAME}"
12 adduser "${USERNAME}" "${USERNAME}"
13
14 mkdir -p "/home/${USERNAME}/.ssh"
15 cp /etc/skel/.[!.]* "/home/${USERNAME}"
16
17 chown -R "${USERNAME}:${USERNAME}" "/home/${USERNAME}"
18
19 if [ -f /etc/sudoers ]; then
20     adduser "${USERNAME}" sudo
21     sed -i "\$ a ${USERNAME}   ALL=\(ALL:ALL\) NOPASSWD: ALL" /etc/sudoers
22 fi