blob: e69bbeeaccd39f297a8939742efacae312b9d835 [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
Zack Williams895ea202021-02-09 18:02:49 -070036# create SSH config
Linux Foundation Administrators0fae4092018-01-29 10:58:36 -080037mkdir /home/jenkins/.ssh
Linux Foundation Administrators0fae4092018-01-29 10:58:36 -080038cp -r /home/${OS}/.ssh/authorized_keys /home/jenkins/.ssh/authorized_keys
Zack Williamse05f7542021-02-09 17:14:21 -070039
Linux Foundation Administrators0fae4092018-01-29 10:58:36 -080040# Generate ssh key for use by Robot jobs
41echo -e 'y\n' | ssh-keygen -N "" -f /home/jenkins/.ssh/id_rsa -t rsa
Zack Williams895ea202021-02-09 18:02:49 -070042
43# /w is used as the Jenkins "Remote FS root" in the config
44mkdir /w
45
46# Have jenkins user own the ssh and remote fs root
47chown -R jenkins:jenkins /home/jenkins/.ssh /w