-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin.sh
executable file
·84 lines (66 loc) · 2.07 KB
/
plugin.sh
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
#!/bin/bash
#
# This scripts takes built plugin class (with Ant/netbeans) and updates
# existing plugin JAR file (which has strict structure) with new
# compiled classes to reflect updates to the plugin file.
#
# Warning: JSP page is not updated!
#
# @Author: Ph4r05
#
JAVA_FILE="OpenfireUserservicePlugin.jar"
CG='\e[0;32m'
CR='\e[0;31m'
CN='\e[0m'
echo -e "$CG[+]$CN going to build plugin with Ant"
ant
# extract plugin-userservice from the plugin zip file
echo -e "$CG[+]$CN Extracting subJar file with original classes from the plugin"
cd plugin
unzip userservice.jar lib/plugin-userservice.jar
RT=$?
if (( $RT != 0 )); then
echo -e "$CR[!]$CN Error: plugin/userservice.jar does not exists or has invalid structure"
exit 1
fi
cd ..
# delete old unzip directory
echo -e "$CG[+]$CN Deleting old unzip directory"
/bin/rm -rf dist/unzipped 2> /dev/null
# unzip builded JAR file - obtain classes.
echo -e "$CG[+]$CN Unzipping built JAR archive with new plugin classes"
cd dist
unzip $JAVA_FILE -d unzipped
RT=$?
if (( $RT != 0 )); then
echo -e "$CR[!]$CN Error: dist/$JAVA_FILE (new plugin JAR file) does not exists or has invalid structure"
exit 2
fi
# change directory so zip utility adds correct path to the archive.
cd unzipped
# replace new files in the plugin
echo -e "$CG[+]$CN Going to update plugin classes in sub-jar"
zip -rv ../../plugin/lib/plugin-userservice.jar org/ net/
RT=$?
if (( $RT != 0 )); then
echo -e "$CR[!]$CN Error: Cannot update subJar with new class files!"
exit 2
fi
# update original plugin file
echo -e "$CG[+]$CN Going to update plugin jar file with new classes"
cd ../../plugin/
zip -rv userservice.jar lib
RT=$?
if (( $RT != 0 )); then
echo -e "$CR[!]$CN Error: Cannot update subJar in plugin JAR file!"
exit 2
fi
# update plugin.xml
echo -e "$CG[+]$CN Updating plugin.xml"
cd ../
zip -rv plugin/userservice.jar plugin.xml
# cleanup
echo -e "$CG[+]$CN Cleaning up"
/bin/rm -rf dist/unzipped 2> /dev/null
/bin/rm -rf plugin/lib 2> /dev/null
echo -e "$CG[=]$CN Done, you can upload plugin/userservice.jar to the OpenFire server"