Make sure that jjb-cleanup.sh allows unbound vars
[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
14 useradd -m -s /bin/bash jenkins
15
16 if grep -q docker /etc/group; then
17     usermod -a -G docker jenkins
18 fi
19
20 # Used for building RPMs
21 if grep -q mock /etc/group; then
22     usermod -a -G mock jenkins
23 fi
24
25 mkdir /home/jenkins/.ssh /w
26 cp -r "/home/${OS}/.ssh/authorized_keys" /home/jenkins/.ssh/authorized_keys
27
28 # Generate ssh key for use by Robot jobs
29 echo -e 'y\n' | ssh-keygen -N "" -f /home/jenkins/.ssh/id_rsa -t rsa
30 chown -R jenkins:jenkins /home/jenkins/.ssh /w
31 chmod 700 /home/jenkins/.ssh