aboutsummaryrefslogtreecommitdiffstats
path: root/jenkins-scripts/create_jenkins_user.sh
diff options
context:
space:
mode:
authorJan-Simon Möller <jsmoeller@linuxfoundation.org>2016-08-16 18:26:19 +0200
committerJan-Simon Möller <jsmoeller@linuxfoundation.org>2016-08-17 13:27:14 +0200
commit46ae6ad6151e3a05d80a0d7cfd9e44841fb4bcfd (patch)
tree1b2c52cd19639f490c2b56cde493e0a959885fc0 /jenkins-scripts/create_jenkins_user.sh
parent245ec5ec552c8c97e867c03aa9645834886cbf2b (diff)
Initial version of the ci-management repo
Based on the open-o template. Modified for AGL. v2 fixed host key and only pushing ci-management jobs. - fix macro vs. definition in file Change-Id: I2de02a572a5d8ca1bf6b7a56bfd2e30bfe18fa9a Signed-off-by: Jan-Simon Möller <jsmoeller@linuxfoundation.org>
Diffstat (limited to 'jenkins-scripts/create_jenkins_user.sh')
-rwxr-xr-xjenkins-scripts/create_jenkins_user.sh41
1 files changed, 41 insertions, 0 deletions
diff --git a/jenkins-scripts/create_jenkins_user.sh b/jenkins-scripts/create_jenkins_user.sh
new file mode 100755
index 00000000..86a5c92d
--- /dev/null
+++ b/jenkins-scripts/create_jenkins_user.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+# @License EPL-1.0 <http://spdx.org/licenses/EPL-1.0>
+##############################################################################
+# Copyright (c) 2016 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+
+#######################
+# Create Jenkins User #
+#######################
+
+OS=$(facter operatingsystem | tr '[:upper:]' '[:lower:]')
+
+useradd -m -s /bin/bash jenkins
+
+# Check if docker group exists
+grep -q docker /etc/group
+if [ "$?" == '0' ]
+then
+ # Add jenkins user to docker group
+ usermod -a -G docker jenkins
+fi
+
+# Check if mock group exists
+grep -q mock /etc/group
+if [ "$?" == '0' ]
+then
+ # Add jenkins user to mock group so they can build Int/Pack's RPMs
+ usermod -a -G mock jenkins
+fi
+
+mkdir /home/jenkins/.ssh
+mkdir /w
+cp -r /home/${OS}/.ssh/authorized_keys /home/jenkins/.ssh/authorized_keys
+# Generate ssh key for use by Robot jobs
+echo -e 'y\n' | ssh-keygen -N "" -f /home/jenkins/.ssh/id_rsa -t rsa
+chown -R jenkins:jenkins /home/jenkins/.ssh /w