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 | |
| 36 | mkdir /home/jenkins/.ssh |
| 37 | mkdir /w |
| 38 | cp -r /home/${OS}/.ssh/authorized_keys /home/jenkins/.ssh/authorized_keys |
| 39 | # Generate ssh key for use by Robot jobs |
| 40 | echo -e 'y\n' | ssh-keygen -N "" -f /home/jenkins/.ssh/id_rsa -t rsa |
| 41 | chown -R jenkins:jenkins /home/jenkins/.ssh /w |