1 #!/bin/sh |
|
2 |
|
3 PREFIX=/usr/local |
|
4 |
|
5 # help text |
|
6 printhelp() |
|
7 { |
|
8 echo "Usage: $0 [PREFIX=<path>]" |
|
9 echo |
|
10 echo "Default PREFIX: /usr/local" |
|
11 } |
|
12 |
|
13 # error function |
|
14 exit_on_error() |
|
15 { |
|
16 echo "$1" |
|
17 exit 1 |
|
18 } |
|
19 |
|
20 # |
|
21 # parse arguments |
|
22 # |
|
23 for arg in "$@" |
|
24 do |
|
25 case "$arg" in |
|
26 "PREFIX="*) PREFIX=${arg#PREFIX=} ;; |
|
27 "--help"*) printhelp; exit 1 ;; |
|
28 "-"*) echo "unknown option: $arg"; exit 1 ;; |
|
29 esac |
|
30 done |
|
31 |
|
32 # |
|
33 # create install dir |
|
34 # |
|
35 echo "mkdir -p $PREFIX/lib/uwproj $PREFIX/bin" |
|
36 mkdir -p "$PREFIX/lib/uwproj" "$PREFIX/bin" \ |
|
37 || exit_on_error "Creating install directory failed." |
|
38 |
|
39 # |
|
40 # install the JAR file |
|
41 # |
|
42 echo "cp ../target/uwproj-0.1-jar-with-dependencies.jar $PREFIX/lib/uwproj/uwproj-0.1.jar" |
|
43 cp "../target/uwproj-0.1-jar-with-dependencies.jar" "$PREFIX/lib/uwproj/uwproj-0.1.jar" \ |
|
44 || exit_on_error "Installing JAR file failed." |
|
45 |
|
46 # |
|
47 # create a run script in the bin dir |
|
48 # |
|
49 echo "cp bin/uwproj $PREFIX/bin" |
|
50 sed "s:%%PREFIX%%:$PREFIX:g" "bin/uwproj" > "$PREFIX/bin/uwproj" \ |
|
51 || exit_on_error "Creating run script failed." |
|
52 |
|
53 echo "chmod 0555 $PREFIX/bin/uwproj" |
|
54 chmod 0755 "$PREFIX/bin/uwproj" \ |
|
55 || exit_on_error "Changing permissions for run script failed." |
|
56 |
|
57 echo |
|
58 echo "uwproj has been successfully installed." |
|