polish test vm
[plcapi.git] / tests / ci / setup / create_user.sh
old mode 100644 (file)
new mode 100755 (executable)
index b92951d..33553d2
@@ -1,20 +1,21 @@
 #!/bin/sh
 
-# @todo set up the same user for running tests as on travis (ie. 'travis'), or maybe user 'user' ?
-# @todo make the GID & UID of the user variable
+# @todo make the GID & UID of the user variable (we picked 2000 as it is the one used by default by Travis)
 
 set -e
 
-USERNAME="${1:-test}"
+USERNAME="${1:-docker}"
 
-addgroup --gid 1013 ${USERNAME}
-adduser --system --uid=1013 --gid=1013 --home /home/${USERNAME} --shell /bin/bash ${USERNAME}
-adduser ${USERNAME} ${USERNAME}
+addgroup --gid 2000 "${USERNAME}"
+adduser --system --uid=2000 --gid=2000 --home "/home/${USERNAME}" --shell /bin/bash "${USERNAME}"
+adduser "${USERNAME}" "${USERNAME}"
 
-mkdir -p /home/${USERNAME}/.ssh
-cp /etc/skel/.[!.]* /home/${USERNAME}
+mkdir -p "/home/${USERNAME}/.ssh"
+cp /etc/skel/.[!.]* "/home/${USERNAME}"
 
-adduser ${USERNAME} sudo
-sed -i "\$ a ${USERNAME}   ALL=\(ALL:ALL\) NOPASSWD: ALL" /etc/sudoers
+chown -R "${USERNAME}:${USERNAME}" "/home/${USERNAME}"
 
-chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}
+if [ -f /etc/sudoers ]; then
+    adduser "${USERNAME}" sudo
+    sed -i "\$ a ${USERNAME}   ALL=\(ALL:ALL\) NOPASSWD: ALL" /etc/sudoers
+fi