Pass multiple pattern args in logs-deploy.sh
[releng/global-jjb.git] / jenkins-init-scripts / create-jenkins-user.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: 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 OS=$(facter operatingsystem | tr '[:upper:]' '[:lower:]')
13 OS_RELEASE=$(facter lsbdistrelease | tr '[:upper:]' '[:lower:]')
14
15 if [[ "$OS_RELEASE" == "18.04" && "$OS" == 'ubuntu' ]]; then
16   echo 'export PATH=$HOME/.local/bin:$PATH' >> /etc/profile
17 fi
18
19 useradd -m -s /bin/bash jenkins
20
21 if grep -q docker /etc/group; then
22     usermod -a -G docker jenkins
23 fi
24
25 # Used for building RPMs
26 if grep -q mock /etc/group; then
27     usermod -a -G mock jenkins
28 fi
29
30 mkdir /home/jenkins/.ssh
31 cp "/home/${OS}/.ssh/authorized_keys" /home/jenkins/.ssh/authorized_keys
32 chmod 0600 /home/jenkins/.ssh/authorized_keys
33
34 # Generate ssh key for use by Robot jobs
35 echo -e 'y\n' | ssh-keygen -N "" -f /home/jenkins/.ssh/id_rsa -t rsa
36 chown -R jenkins:jenkins /home/jenkins/.ssh
37 chmod 0700 /home/jenkins/.ssh
38
39 # The '/w' volume may already be part of image
40 [[ ! -d '/w' ]] && mkdir /w
41 chown -R jenkins:jenkins /w