-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrol.sh
More file actions
executable file
·105 lines (85 loc) · 3.1 KB
/
Copy pathcontrol.sh
File metadata and controls
executable file
·105 lines (85 loc) · 3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash
set -x
set -e
# This shell script is used both to create the docker image and as the entrypoint for the docker image.
# The current working directory, WORKDIR in the Dockerfile, should be set before theis assumed to be the same when the docker image is created and when
# the entry point is executed.
# openjdk is the latest tested but I think oracle will work as well
#java=oracle
# for openjdk the jdk will be installed to compile the play program and create the package
# then the jdk will be uninstalled and the jre installed for use to run the program
java=openjdk
# if no parameters this is the default entry point. The dist command (see below)
# put the name of the play executable into playexe
if [[ $# == 0 ]]; then
x=$( cat playexe )
exec ./$x
fi
# the entry point can be -- whatever to debug. Try: -- bash
if [ "$1" == "--" ]; then
echo $*
shift
exec "$*"
fi
# install all the pre-requisites to run a play program, git the play program,
# dist the play program and unzip the results so it is ready to run.
# then clean up everything else.
cleanup="false"
if [ "$1" == "dist" ]; then
cleanup="true"
fi
apt-get update -qq
apt-get --no-install-recommends install -qq git wget unzip > /dev/null
# set up the temp dir to be deleted during clean up
tmpDir=/tmp/tmp
mkdir $tmpDir
pushd $tmpDir
# Install play
wget -nv http://downloads.typesafe.com/typesafe-activator/$ACTIVATOR_VERSION/typesafe-activator-$ACTIVATOR_VERSION.zip
unzip typesafe-activator-$ACTIVATOR_VERSION.zip
activatorBin=$tmpDir/activator-$ACTIVATOR_VERSION/activator
case $java in
oracle)
# Install Java and dependencies
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections
add-apt-repository -y ppa:webupd8team/java
apt-get --no-install-recommends install -qq oracle-java8-installer > /dev/null
;;
openjdk)
apt-get --no-install-recommends install -qq openjdk-7-jdk > /dev/null
;;
esac
# git the code and cd into the play directory
playDir="playprojectdir"
git clone $PLAY_REPOSITORY $playDir
cd $playDir
# tell activator to store ivy and sbt caches in the tmpDir
export _JAVA_OPTIONS=-Duser.home=$tmpDir
# build the tar ball
$activatorBin universal:packageZipTarball
# the distribution was all done in tmp/tmp get the names, come home, and finish up...
# The output of activator are some funny escaped character sequences so after getting to the last word
# strip off the first and last 4 characters
x=$( $activatorBin universal:normalizedName )
normalizedName=${x##* }
normalizedName=${normalizedName:4:-4}
x=$( $activatorBin universal:name )
name=${x##* }
name=${name:4:-4}
popd
tar xvf $tmpDir/$playDir/target/universal/$name.tgz
echo $name/bin/$normalizedName > playexe
if [ $cleanup == "true" ]; then
apt-get remove --purge --auto-remove -qq git wget unzip
case $java in
openjdk)
apt-get remove --purge --auto-remove -qq openjdk-7-jdk
apt-get install -qq openjdk-7-jre-headless > /dev/null
;;
oracle)
rm -rf /var/cache/oracle-jdk8-installer
;;
esac
rm -rf $tmpDir
rm -rf /var/lib/apt/lists/*
fi