Add VPP 24.06 branch
[ci-management.git] / jenkins-scripts / create_jenkins_user.sh
1 #!/bin/bash
2 # @License EPL-1.0 <http://spdx.org/licenses/EPL-1.0>
3 ##############################################################################
4 # Copyright (c) 2016 The Linux Foundation and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11
12 #######################
13 # Create Jenkins User #
14 #######################
15
16 OS=$(facter operatingsystem | tr '[:upper:]' '[:lower:]')
17
18 groupadd jenkins
19 useradd -m -s /bin/bash -g jenkins jenkins
20
21 # Check if docker group exists
22 grep -q docker /etc/group
23 if [ "$?" == '0' ]
24 then
25   # Add jenkins user to docker group
26   usermod -a -G docker jenkins
27 fi
28
29 # Check if mock group exists
30 grep -q mock /etc/group
31 if [ "$?" == '0' ]
32 then
33   # Add jenkins user to mock group so it can build RPMs using mock if available
34   usermod -a -G mock jenkins
35 fi
36
37 mkdir /home/jenkins/.ssh
38 mkdir /w
39
40 if [ "$OS" = "opensuse" ];
41 then
42   OS_USER="root"
43 else
44   OS_USER="home/${OS}"
45 fi
46 #Generate ssh key for use by Robot jobs
47 cp -r /${OS_USER}/.ssh/authorized_keys /home/jenkins/.ssh/authorized_keys
48 # Generate ssh key for use by Robot jobs
49 echo -e 'y\n' | ssh-keygen -N "" -f /home/jenkins/.ssh/id_rsa -t rsa
50 chown -R jenkins:jenkins /home/jenkins/.ssh /w