blob: bbc524c10b158047531007250061297e2e113e82 [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
Linux Foundation Administrators0fae4092018-01-29 10:58:36 -080037cp -r /home/${OS}/.ssh/authorized_keys /home/jenkins/.ssh/authorized_keys
Zack Williamse05f7542021-02-09 17:14:21 -070038
Linux Foundation Administrators0fae4092018-01-29 10:58:36 -080039# Generate ssh key for use by Robot jobs
40echo -e 'y\n' | ssh-keygen -N "" -f /home/jenkins/.ssh/id_rsa -t rsa
Zack Williamsc5296732021-02-09 17:50:09 -070041chown -R jenkins:jenkins /home/jenkins/.ssh