-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·95 lines (81 loc) · 2.3 KB
/
install
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
#!/bin/bash
installationPath=/usr/local/bin
configurationFileProperty=""
installHit=""
function permission-check() {
file=$1
# Handle non-absolute paths
if ! [[ "$file" == /* ]] ; then
path=.
fi
dirname "$file" | tr '/' $'\n' | while read part ; do
path="$path/$part"
if ! [[ -x "$path" ]] ; then
echo "Forbidden"
return
fi
done
if ! [[ -w "$file" ]] ; then
echo "Forbidden"
fi
}
function get-version() {
cat pom.xml | grep -oP "<version>(.*?)</version>" | head -n1 | tr -d "<version>" | tr -d "</version>"
}
function show-help () {
echo "Usage: install [OPTIONS]"
echo " Options:"
echo " --installation-path <DIRECTORY> Path where karaf-runner binary would be installed"
echo " --configuration-file <PATH> Path where base karaf-runner configuration would be"
}
while [[ "$#" != "0" ]]; do
case "$1" in
"help" | "--help" | "-h")
show-help
exit
;;
"--installation-path")
installationPath=$2
shift 2
;;
"--configuration-file")
configurationFileProperty=" -Dkaraf-runner.configurationFile=$2"
shift 2
;;
"install")
installHit="true"
shift 1
;;
"version" | "--version" | "-V")
echo "karaf-runner installer v$(get-version)"
echo "Copyright (c) 2016 Kirill Saksin"
echo "Licensed under The MIT License"
exit
;;
* )
echo "Unsupported option "'"'"$1"'"'
exit
;;
esac
done
if [[ "$installHit" == "" ]]; then
echo "Error: no command specified"
show-help
exit
fi
installationPath=$(realpath $installationPath)
if ! [[ -w $installationPath ]]; then
echo "You don't have permission to write to $installationPath"
exit
fi
cd $(dirname $0)
echo "Building sources"
(mvn clean install -Dmaven.test.skip=true >> /dev/null) || ( echo "Failed to build sources" && exit -1 )
cd target
echo "Building runnable binary"
echo "#!/usr/bin/java -jar $configurationFileProperty" > karaf-runner
cat karaf-runner.jar >> karaf-runner
chmod +x karaf-runner
echo "Installing to $installationPath"
cp karaf-runner $installationPath
echo "Installation complete"