| 
1 | 1 | #!/bin/bash  | 
2 | 2 | 
 
  | 
3 |  | -# By default Ubuntu sets an arbitrary UID value, that is different from host  | 
4 |  | -# system. When CI passes default UID value of 1001, some of LLVM tools fail to  | 
5 |  | -# discover user home directory and fail a few LIT tests. Fixes UID and GID to  | 
6 |  | -# 1001, that is used as default by GitHub Actions.  | 
7 |  | -groupadd -g 1001 sycl && useradd sycl -u 1001 -g 1001 -m -s /bin/bash  | 
8 |  | -# Add sycl user to video/irc groups so that it can access GPU  | 
9 |  | -usermod -aG video sycl  | 
10 |  | -usermod -aG irc sycl  | 
11 |  | - | 
12 |  | -# group 109 is required for sycl user to access PVC card.  | 
13 |  | -groupadd -g 109 render  | 
14 |  | -usermod -aG render sycl  | 
15 |  | - | 
16 |  | -if [[ -f /run/secrets/sycl_passwd ]]; then  | 
17 |  | -  # When running in our CI environment, we restrict access to root.  | 
18 |  | - | 
19 |  | -  # Set password for sycl user  | 
20 |  | -  cat /run/secrets/sycl_passwd | passwd -s sycl  | 
21 |  | - | 
22 |  | -  # Allow sycl user to run as sudo, but only with password  | 
23 |  | -  echo "sycl  ALL=(root) PASSWD:ALL" >> /etc/sudoers  | 
 | 3 | +set -e  | 
 | 4 | + | 
 | 5 | +if [[ $# -eq 0 ]]; then  | 
 | 6 | +  # When launched without arguments, we assume that it was launched as part of  | 
 | 7 | +  # CI workflow and therefore a different kind of user is created  | 
 | 8 | +  USER_NAME=sycl_ci  | 
 | 9 | +  SET_PASSWD=true  | 
 | 10 | + | 
 | 11 | +  # By default Ubuntu sets an arbitrary UID value, that is different from host  | 
 | 12 | +  # system. When CI passes default UID value of 1001, some of LLVM tools fail to  | 
 | 13 | +  # discover user home directory and fail a few LIT tests. Fixes UID and GID to  | 
 | 14 | +  # 1001, that is used as default by GitHub Actions.  | 
 | 15 | +  USER_ID=1001  | 
24 | 16 | else  | 
25 |  | -  # Otherwise, we allow password-less root to simplify building other  | 
26 |  | -  # containers on top.  | 
 | 17 | +  if [[ "${1:-}" != "--regular" ]]; then  | 
 | 18 | +    echo "The only supported argument is --regular!"  | 
 | 19 | +    exit 1  | 
 | 20 | +  fi  | 
 | 21 | +  USER_NAME=sycl  | 
 | 22 | +  SET_PASSWD=false  | 
 | 23 | + | 
 | 24 | +  # Some user id which is different from the one assigned to sycl_ci user  | 
 | 25 | +  USER_ID=1234  | 
 | 26 | +fi  | 
 | 27 | + | 
 | 28 | +groupadd -g $USER_ID $USER_NAME && useradd $USER_NAME -u $USER_ID -g $USER_ID -m -s /bin/bash  | 
 | 29 | +# Add user to video/irc groups so that it can access GPU  | 
 | 30 | +usermod -aG video $USER_NAME  | 
 | 31 | +usermod -aG irc $USER_NAME  | 
27 | 32 | 
 
  | 
28 |  | -  # Allow sycl user to run as sudo passwrod-less  | 
29 |  | -  echo "sycl  ALL=(root) NOPASSWD:ALL" >> /etc/sudoers  | 
 | 33 | +# group 109 is required for user to access PVC card.  | 
 | 34 | +groupadd -f -g 109 render  | 
 | 35 | +usermod -aG render $USER_NAME  | 
 | 36 | + | 
 | 37 | +if [[ $SET_PASSWD == true ]]; then  | 
 | 38 | +  if [[ ! -f /run/secrets/sycl_ci_passwd ]]; then  | 
 | 39 | +    echo "Password is requested, but /run/secrtes/sycl_ci_passwd doesn't exists!"  | 
 | 40 | +    exit 2  | 
 | 41 | +  fi  | 
 | 42 | + | 
 | 43 | +  # Set password for user  | 
 | 44 | +  echo "$USER_NAME:$(cat /run/secrets/sycl_ci_passwd)" | chpasswd  | 
 | 45 | + | 
 | 46 | +  # Allow user to run as sudo, but only with password  | 
 | 47 | +  echo "$USER_NAME  ALL=(ALL) PASSWD:ALL" >> /etc/sudoers  | 
 | 48 | +else  | 
 | 49 | +  echo "$USER_NAME  ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers  | 
30 | 50 | fi  | 
0 commit comments