Linux Foundation Administrators | 0fae409 | 2018-01-29 10:58:36 -0800 | [diff] [blame] | 1 | #!/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 | |
| 16 | OS=$(facter operatingsystem | tr '[:upper:]' '[:lower:]') |
| 17 | |
| 18 | useradd -m -s /bin/bash jenkins |
| 19 | |
| 20 | # Check if docker group exists |
| 21 | grep -q docker /etc/group |
| 22 | if [ "$?" == '0' ] |
| 23 | then |
| 24 | # Add jenkins user to docker group |
| 25 | usermod -a -G docker jenkins |
| 26 | fi |
| 27 | |
| 28 | # Check if mock group exists |
| 29 | grep -q mock /etc/group |
| 30 | if [ "$?" == '0' ] |
| 31 | then |
| 32 | # Add jenkins user to mock group so they can build Int/Pack's RPMs |
| 33 | usermod -a -G mock jenkins |
| 34 | fi |
| 35 | |
Zack Williams | 895ea20 | 2021-02-09 18:02:49 -0700 | [diff] [blame] | 36 | # create SSH config |
Linux Foundation Administrators | 0fae409 | 2018-01-29 10:58:36 -0800 | [diff] [blame] | 37 | mkdir /home/jenkins/.ssh |
Linux Foundation Administrators | 0fae409 | 2018-01-29 10:58:36 -0800 | [diff] [blame] | 38 | cp -r /home/${OS}/.ssh/authorized_keys /home/jenkins/.ssh/authorized_keys |
Zack Williams | e05f754 | 2021-02-09 17:14:21 -0700 | [diff] [blame] | 39 | |
Linux Foundation Administrators | 0fae409 | 2018-01-29 10:58:36 -0800 | [diff] [blame] | 40 | # Generate ssh key for use by Robot jobs |
| 41 | echo -e 'y\n' | ssh-keygen -N "" -f /home/jenkins/.ssh/id_rsa -t rsa |
Zack Williams | 895ea20 | 2021-02-09 18:02:49 -0700 | [diff] [blame] | 42 | |
| 43 | # /w is used as the Jenkins "Remote FS root" in the config |
| 44 | mkdir /w |
| 45 | |
| 46 | # Have jenkins user own the ssh and remote fs root |
| 47 | chown -R jenkins:jenkins /home/jenkins/.ssh /w |