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