github.com/cloudcredo/cloudrocker@v0.0.0-20160108110610-1320f8cc2dfd/rocker/fixtures/runtime/buildpacks/cf-test-buildpack/bin/compile (about) 1 #!/usr/bin/env bash 2 3 echo "Running cache test..." 4 5 BUILD_DIR=$1 6 CACHE_DIR=$2 7 BUILD_PACK_DIR=$(dirname $(dirname $0)) 8 9 if [ ! -d "$BUILD_DIR" ]; then 10 echo "Build directory [$BUILD_DIR] does not exist, creating" 11 mkdir -p "$BUILD_DIR" 12 else 13 echo "Build directory [$BUILD_DIR] exists" 14 echo "Build directory contents..." 15 ls -lRh $BUILD_DIR 16 fi 17 18 if [ ! -d "$CACHE_DIR" ]; then 19 echo "Cache directory [$CACHE_DIR] does not exist, creating" 20 mkdir -p "$CACHE_DIR" 21 else 22 echo "Cache directory [$CACHE_DIR] exists" 23 fi 24 25 echo "The compile script is at [$0]" 26 echo "The build pack is situated at [$BUILD_PACK_DIR]" 27 28 echo "Moving to the cache dir..." 29 cd "$CACHE_DIR" 30 echo "Now in [$(pwd)]" 31 32 echo "Directory listing:" 33 ls -la 34 35 echo "Listing Build Pack Directory:" 36 ls -la /tmp/buildpacks 37 38 echo "Listing Build Pack Cache:" 39 ls -la "$BUILDPACK_CACHE" 40 41 echo "Listing Environment:" 42 env 43 44 echo "Listing OS Info:" 45 cat /etc/issue 46 47 echo "Listing script versions:" 48 python -V 49 echo 50 ruby -v 51 echo 52 perl -v 53 54 echo "User Limits:" 55 ulimit -a 56 echo 57 58 echo "Check for FUSE support" 59 /sbin/mount.fuse -h 60 ls -l /usr/share/doc/fuse-utils 61 62 echo "CPU Info" 63 cat /proc/cpuinfo 64 65 echo "Look for staging_info.yml file" 66 cat "$BUILD_DIR/staging_info.yml" 67 68 cd ../ 69 echo "Creating start script" 70 cat > "$BUILD_DIR/start.sh" <<EOF 71 #!/bin/bash 72 # 73 # Start Python Web Server & SSH Reverse Tunnel 74 # 75 # Copy SSH keys if included with the app 76 if [ -d "/app/.ssh" ]; then 77 echo "Copied SSH keys" 78 cp -R /app/.ssh /home/vcap/ 79 # Start reverse SSH Tunnel 80 echo "Starting SSH Reverse Tunnel" 81 ssh -f -N -T -R 2222:localhost:\$VCAP_APP_PORT daniel@\$SSH_HOST 82 fi 83 84 # Validate args were passed through from parent process 85 if [ "\$1" != "TESTARG" ]; then 86 exit 1 87 fi 88 89 # Start Python Server 90 echo "Starting Web Server" 91 python /app/boot.py / 92 93 # Start Web Socket Server 94 #echo "Starting WebSocketD" 95 #curl -s https://raw.github.com/dmikusa-pivotal/cf-debug-console/master/debug.sh | bash 96 EOF 97 chmod 755 "$BUILD_DIR/start.sh" 98 99 echo "Creating script to start a small Python Web server" 100 cat > "$BUILD_DIR/boot.py" <<EOF 101 #!/usr/bin/env python 102 # 103 # Simple HTTP Server for accessing files in target director 104 # 105 import SimpleHTTPServer 106 import SocketServer 107 import os 108 import sys 109 110 fin = open('/proc/cpuinfo', 'rt') 111 fout = open('cpuinfo', 'wt') 112 fout.write(fin.read()) 113 fin.close() 114 fout.close() 115 116 if len(sys.argv) == 2: 117 print 'Serving files from [%s]' % sys.argv[1] 118 os.chdir(sys.argv[1]) 119 else: 120 print 'Service files from [%s]' % os.getcwd() 121 122 from socket import socket, SOCK_DGRAM, AF_INET 123 s = socket(AF_INET, SOCK_DGRAM) 124 s.connect(('google.com', 0)) 125 localHostPort = s.getsockname() 126 127 httpd = SocketServer.TCPServer( 128 (localHostPort[0], 8080), 129 SimpleHTTPServer.SimpleHTTPRequestHandler) 130 httpd.serve_forever() 131 EOF 132