-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall-plugin.sh
executable file
·76 lines (70 loc) · 2.24 KB
/
uninstall-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
#!/bin/bash
#Author: Edward De Faria <[email protected]>
if [ -z "$LOGSTASH_HOME" ] ; then
export LOGSTASH_HOME=/opt/logstash
fi
export GEM_HOME=vendor/bundle/jruby/1.9
export GEM_PATH=$GEN_HOME
export USE_JRUBY=1
gem_list () {
pushd $LOGSTASH_HOME > /dev/null
if [ -d "vendor/jar" ] ; then
local vendor_path=$(find vendor/jar -iname jruby-complete*.jar)
java -jar $vendor_path -S gem list -i $GEM_HOM
elif [ -d "vendor/jruby" ] ; then
./vendor/jruby/bin/jruby -S gem list
else
echo "Error: jruby dependancy missing!"
fi
popd > /dev/null
}
rake_update () {
pushd $LOGSTASH_HOME > /dev/null
if [ -f "Rakefile" ] ; then
echo "exec in $PWD: rake vendor:gems"
rake vendor:gems
else
echo "logstash package installation found, skipping rake"
fi
popd > /dev/null
}
plugin_uninstall () {
local name="$1"
local action="$2"
cd $LOGSTASH_HOME
[ -z "$action" ] && local action=uninstall
if [ -x "bin/plugin" -o -x "bin/logstash-plugin" ] ; then
if [ -x "bin/logstash-plugin" ] ; then
echo "exec in $PWD: ( bin/logstash-plugin $action $name )"
bin/logstash-plugin $action $name
else
echo "exec in $PWD: ( bin/plugin $action $name )"
bin/plugin $action $name
fi
else
echo "Error: plugin exec missing!"
exit 1
fi
}
gem_uninstall () {
local home="$1"
local gem_name="$2"
cd $LOGSTASH_HOME
local action=uninstall
if [ -d "vendor/jar" ] ; then
local vendor_path=$(find vendor/jar -iname jruby-complete*.jar)
echo "exec in $PWD: java -jar $vendor_path -S gem $action -i $GEM_HOME $gem_name"
java -jar $vendor_path -S gem $action -i $GEM_HOME $gem_name || { echo "gem uninstall failed" ; exit 1 ; }
elif [ -d "vendor/jruby" ] ; then
echo "exec in $PWD: ./vendor/jruby/bin/jruby -S gem $action $gem_name"
./vendor/jruby/bin/jruby -S gem $action $gem_name || { echo "gem uninstall failed" ; exit 1 ; }
else
echo "Error: jruby dependancy missing!"
exit 1
fi
}
# Uninstall some logstash plugin
for plugin in logstash-input-exec logstash-output-exec logstash-input-file logstash-output-csv logstash-output-file logstash-input-pipe logstash-output-pipe logstash-output-graphite logstash-input-unix logstash-filter-ruby
do
plugin_uninstall $plugin
done