CP init scripts to jenkins-init-scripts
[releng/builder.git] / jenkins-init-scripts / system_type.sh
diff --git a/jenkins-init-scripts/system_type.sh b/jenkins-init-scripts/system_type.sh
new file mode 100755 (executable)
index 0000000..c5b141a
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/bash
+# SPDX-License-Identifier: 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
+##############################################################################
+
+HOST=$(/bin/hostname)
+SYSTEM_TYPE=''
+
+IFS=','
+for i in "java-builder,builder" \
+         "builder,builder" \
+         "devstack,devstack" \
+         "docker,docker" \
+         "gbp,ubuntu-docker-ovs" \
+         "kubernetes,mininet-ubuntu" \
+         "robot,robot" \
+         "mininet,mininet-ubuntu"
+do set -- $i
+    if [[ $HOST == *"$1"* ]]; then
+        SYSTEM_TYPE="$2"
+        break
+    fi
+done
+
+# Write out the system type to an environment file to then be sourced
+echo "SYSTEM_TYPE=${SYSTEM_TYPE}" > /tmp/system_type.sh
+
+# vim: sw=4 ts=4 sts=4 et :