blob: 86a5c92d0b29320fc1aa9733b55962bf204199d9 [file] [log] [blame]
Linux Foundation Administrators0fae4092018-01-29 10:58:36 -08001#!/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
16OS=$(facter operatingsystem | tr '[:upper:]' '[:lower:]')
17
18useradd -m -s /bin/bash jenkins
19
20# Check if docker group exists
21grep -q docker /etc/group
22if [ "$?" == '0' ]
23then
24 # Add jenkins user to docker group
25 usermod -a -G docker jenkins
26fi
27
28# Check if mock group exists
29grep -q mock /etc/group
30if [ "$?" == '0' ]
31then
32 # Add jenkins user to mock group so they can build Int/Pack's RPMs
33 usermod -a -G mock jenkins
34fi
35
36mkdir /home/jenkins/.ssh
37mkdir /w
38cp -r /home/${OS}/.ssh/authorized_keys /home/jenkins/.ssh/authorized_keys
39# Generate ssh key for use by Robot jobs
40echo -e 'y\n' | ssh-keygen -N "" -f /home/jenkins/.ssh/id_rsa -t rsa
41chown -R jenkins:jenkins /home/jenkins/.ssh /w