-
Notifications
You must be signed in to change notification settings - Fork 60
/
create_package
executable file
·68 lines (60 loc) · 2.65 KB
/
create_package
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
#!/bin/sh
script=$0
if [ -h $script ]; then
script=`readlink $script`
fi
dir=`dirname $script`
java_version=`java -version 2>&1 | head -n 1 | cut -d\" -f 2 | cut -d. -f 2`
hannibal_dir="`cd $dir; pwd`"
working_dir=$PWD
if [ $java_version != "6" ]; then
echo "Please use Java 6 SDK";
exit 1
fi
if [ "" = "$HANNIBAL_HBASE_VERSION" ]; then
HANNIBAL_HBASE_VERSION="0.90"
echo "creating Hannibal package for HBase $HANNIBAL_HBASE_VERSION (may be altered by assigning 0.90, 0.92, 0.94, 0.96 or 0.98 to HANNIBAL_HBASE_VERSION)"
else
echo "creating Hannibal package for HBase $HANNIBAL_HBASE_VERSION (as defined by HANNIBAL_HBASE_VERSION)"
fi
echo "1. building ..."
cd $hannibal_dir
#./activator universal:package-zip-tarball
./activator stage
if [ "$?" != "0" ]; then
echo "error during build";
exit 1
fi
echo "2. preparing hannibal folder ..."
temp_dir=`mktemp -d -t hannibal.XXX`
if [ ! -d $temp_dir ]; then
echo "could not create temp dir: $temp_dir";
exit 1
fi
mkdir -p $temp_dir
cp -R $hannibal_dir/target/universal/stage $temp_dir/hannibal
cp $hannibal_dir/LICENSE $temp_dir/hannibal
echo "3. generting startscript ..."
touch $temp_dir/hannibal/start
chmod +x $temp_dir/hannibal/start
echo "#!/bin/sh" >> $temp_dir/hannibal/start
echo "export HANNIBAL_HBASE_VERSION=$HANNIBAL_HBASE_VERSION" >> $temp_dir/hannibal/start
echo 'if [ "" = "$HANNIBAL_HTTP_PORT" ]; then' >> $temp_dir/hannibal/start
echo 'HANNIBAL_HTTP_PORT="9000"' >> $temp_dir/hannibal/start
echo 'echo " starting Hannibal for HBase '$HANNIBAL_HBASE_VERSION' on Port 9000 (may be altered by assigning another port-number to HANNIBAL_HTTP_PORT)"' >> $temp_dir/hannibal/start
echo 'else' >> $temp_dir/hannibal/start
echo 'echo " starting Hannibal for HBase '$HANNIBAL_HBASE_VERSION' on Port $HANNIBAL_HTTP_PORT (as defined by HANNIBAL_HTTP_PORT)"' >> $temp_dir/hannibal/start
echo 'fi' >> $temp_dir/hannibal/start
echo 'HBASE_CLASSPATH=`hbase classpath`' >> $temp_dir/hannibal/start
echo '# Only use the hbase classpath if the command is available and ran successfully' >> $temp_dir/hannibal/start
echo 'if [ $? -ne 0 ]; then' >> $temp_dir/hannibal/start
echo ' HBASE_CLASSPATH=""' >> $temp_dir/hannibal/start
echo 'fi' >> $temp_dir/hannibal/start
echo 'exec java -DapplyEvolutions.default=true -Dhttp.port=$HANNIBAL_HTTP_PORT -cp "`dirname $0`/conf:`dirname $0`/lib/*:$HBASE_CLASSPATH" play.core.server.NettyServer `dirname $0`' >> $temp_dir/hannibal/start
pkgname=hannibal-hbase$HANNIBAL_HBASE_VERSION.tgz
echo "4. create package: $pkgname ..."
cd $temp_dir
tar -czf $hannibal_dir/target/$pkgname hannibal
cd $working_dir
rm -rf $temp_dir
echo "DONE: package created at: $hannibal_dir/target/$pkgname"