This is an automated email from the ASF dual-hosted git repository.

jbarrett pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-native.git


The following commit(s) were added to refs/heads/develop by this push:
     new 44b5b7c  Reverts changes to use ec2-user for build. (#317)
44b5b7c is described below

commit 44b5b7c930f1868b8ad0b9f16f21906af825a06c
Author: Blake Bender <[email protected]>
AuthorDate: Fri Jul 13 13:54:27 2018 -0700

    Reverts changes to use ec2-user for build. (#317)
    
    * Revert "Fix location of bashrc in install scripts so build tools get 
properly added to path"
    
    This reverts commit 842f84dfadaf69901d6861ee7b17f952e6f36e18.
    
    * Revert "remove creation/setup of 'build' user from RHEL-7 image"
    
    This reverts commit 37ebe4f846f6243641a31a59041c86f9b91aee77.
    
    * Revert "Switch Linux from 'build' to 'ec2-user' account for building, and 
eliminate creation of 'build' user on Linux."
    
    This reverts commit 10eb064fccbc80505811b1bbb687b5e629ab0003.
---
 packer/build-linux.json                            | 15 +++++++
 ...install-scl-devtoolset.sh => add-user-build.sh} | 11 +++--
 packer/rhel/files/etc/init-user.sh                 | 51 ++++++++++++++++++++++
 packer/rhel/install-scl-devtoolset.sh              |  2 +-
 packer/rhel/install-scl-python27.sh                |  2 +-
 packer/test-rhel-7.json                            | 17 +++++++-
 6 files changed, 89 insertions(+), 9 deletions(-)

diff --git a/packer/build-linux.json b/packer/build-linux.json
index aa69695..4adbae0 100644
--- a/packer/build-linux.json
+++ b/packer/build-linux.json
@@ -39,6 +39,20 @@
     },
     {
       "type":"file",
+      "source":"rhel/files",
+      "destination":"/tmp"
+    },
+    {
+      "type":"shell",
+      "execute_command":"{{.Vars}} sudo -E -S bash '{{.Path}}'",
+      "inline":[
+        "cp -rv /tmp/files/* /",
+        "rm -rf /tmp/files",
+        "chmod +x /etc/init-user.sh"
+      ]
+    },
+    {
+      "type":"file",
       "source":"rhel/init-hosts.rc.local",
       "destination":"/tmp/init-hosts.rc.local"
     },
@@ -54,6 +68,7 @@
       "execute_command":"{{.Vars}} sudo -E -S bash '{{.Path}}'",
       "scripts":[
         "rhel/disable-selinux.sh",
+        "rhel/add-user-build.sh",
         "rhel/install-repos.sh",
         "rhel/install-scl-devtoolset.sh",
         "rhel/install-scl-python27.sh",
diff --git a/packer/rhel/install-scl-devtoolset.sh 
b/packer/rhel/add-user-build.sh
old mode 100644
new mode 100755
similarity index 81%
copy from packer/rhel/install-scl-devtoolset.sh
copy to packer/rhel/add-user-build.sh
index 9c774bb..fce6cbb
--- a/packer/rhel/install-scl-devtoolset.sh
+++ b/packer/rhel/add-user-build.sh
@@ -6,18 +6,17 @@
 # The ASF licenses this file to You under the Apache License, Version 2.0
 # (the "License"); you may not use this file except in compliance with
 # the License.  You may obtain a copy of the License at
-#
+# 
 #      http://www.apache.org/licenses/LICENSE-2.0
-#
+# 
 # Unless required by applicable law or agreed to in writing, software
 # distributed under the License is distributed on an "AS IS" BASIS,
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-set -x -e -o pipefail
+#set -x -e -o pipefail
 
-yum-config-manager --enable rhui-REGION-rhel-server-rhscl
-yum -y install devtoolset-4-gcc-c++
+useradd build
 
-echo "source scl_source enable devtoolset-4" >> /etc/bashrc
+(crontab -l -u build ; echo "@reboot /etc/init-user.sh") | sort - | uniq - | 
crontab -u build -
diff --git a/packer/rhel/files/etc/init-user.sh 
b/packer/rhel/files/etc/init-user.sh
new file mode 100644
index 0000000..2ceff71
--- /dev/null
+++ b/packer/rhel/files/etc/init-user.sh
@@ -0,0 +1,51 @@
+#!/usr/bin/env bash
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+# 
+#      http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+ATTEMPTS=5
+FAILED=0
+# Fetch public key using HTTP
+while [ ! -f ~/.ssh/authorized_keys ]; do
+    tmp_keys=`mktemp -p . -t authorized_keys.XXXXX` || exit $?
+    curl -f http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key 
> $tmp_keys 2>/dev/null
+    if [ $? -eq 0 ]; then
+        grep -f $tmp_keys ~/.ssh/authorized_keys 2>/dev/null
+        if [ $? -eq 0 ]; then
+            echo "AWS public key was already in authorized_keys, not adding it 
again"
+        else
+            if [ ! -d ~/.ssh ]; then
+                mkdir ~/.ssh
+                               chmod 700 ~/.ssh
+                               restorecon ~/.ssh
+            fi
+            cat $tmp_keys >> ~/.ssh/authorized_keys
+            chmod 0600 ~/.ssh/authorized_keys
+            restorecon ~/.ssh/authorized_keys
+            echo "Successfully retrieved AWS public key from instance metadata"
+        fi
+    else
+        FAILED=$(($FAILED + 1))
+        if [ $FAILED -ge $ATTEMPTS ]; then
+            echo "Failed to retrieve AWS public key after $FAILED attempts, 
quitting"
+            rm -f
+            break
+        fi
+        echo "Could not retrieve AWS public key (attempt #$FAILED/$ATTEMPTS), 
retrying in 5 seconds..."
+        sleep 5
+    fi
+    rm -f $tmp_keys
+done
diff --git a/packer/rhel/install-scl-devtoolset.sh 
b/packer/rhel/install-scl-devtoolset.sh
index 9c774bb..f165e44 100644
--- a/packer/rhel/install-scl-devtoolset.sh
+++ b/packer/rhel/install-scl-devtoolset.sh
@@ -20,4 +20,4 @@ set -x -e -o pipefail
 yum-config-manager --enable rhui-REGION-rhel-server-rhscl
 yum -y install devtoolset-4-gcc-c++
 
-echo "source scl_source enable devtoolset-4" >> /etc/bashrc
+echo "source scl_source enable devtoolset-4" >> ~build/.bashrc
diff --git a/packer/rhel/install-scl-python27.sh 
b/packer/rhel/install-scl-python27.sh
index 99c800b..666a3e9 100644
--- a/packer/rhel/install-scl-python27.sh
+++ b/packer/rhel/install-scl-python27.sh
@@ -21,4 +21,4 @@ yum-config-manager --enable rhui-REGION-rhel-server-rhscl
 yum -y install python27-python-pip
 scl enable python27 'pip install --upgrade pip'
 
-echo "source scl_source enable python27" >> /etc/bashrc
+echo "source scl_source enable python27" >> ~build/.bashrc
diff --git a/packer/test-rhel-7.json b/packer/test-rhel-7.json
index c8ba0ed..7ca6705 100644
--- a/packer/test-rhel-7.json
+++ b/packer/test-rhel-7.json
@@ -39,6 +39,20 @@
     },
     {
       "type":"file",
+      "source":"rhel/files",
+      "destination":"/tmp"
+    },
+    {
+      "type":"shell",
+      "execute_command":"{{.Vars}} sudo -E -S bash '{{.Path}}'",
+      "inline":[
+        "cp -rv /tmp/files/* /",
+        "rm -rf /tmp/files",
+        "chmod +x /etc/init-user.sh"
+      ]
+    },
+    {
+      "type":"file",
       "source":"rhel/init-hosts.rc.local",
       "destination":"/tmp/init-hosts.rc.local"
     },
@@ -54,6 +68,7 @@
       "execute_command":"{{.Vars}} sudo -E -S bash '{{.Path}}'",
       "scripts":[
         "rhel/disable-selinux.sh",
+        "rhel/add-user-build.sh",
         "rhel/install-repos.sh",
         "rhel/install-jdk-1.8.sh",
         "rhel/install-cmake.sh"
@@ -80,4 +95,4 @@
       ]
     }
   ]
-}
+}
\ No newline at end of file

Reply via email to