-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathpurge-install
executable file
·68 lines (58 loc) · 1.77 KB
/
purge-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
#!/bin/bash
#
# Simple script to clean out ALL zookeeper and Kafka data from the node.
# Useful when trying to restart a system without reinstalling the software.
#
# NOTE: It goes without saying that this should be run only while the
# services are properly shut down.
#
# NOTE 2: The zookeeper id is MAINTAINED ! Otherwise, the zookeeper
# service would restart in standalone mode ... not good for us.
set -x
# OSX brew has a readlink equivalent (installed via
# 'brew install coreutils')
#
READLINK=readlink
which greadlink &> /dev/null && READLINK=greadlink
THIS_SCRIPT="$(${READLINK} -f ${BASH_SOURCE[0]})"
BIN_DIR=$(dirname ${THIS_SCRIPT})
CONF_HOME=$(dirname ${BIN_DIR})
# The tool _may_ be in $CONF_HOME/bin, or simply in a random location.
# Do a quick check to find something rational.
if [ -x $CONF_HOME/bin/kafka-server-start ] ; then
CONF_ETC_TOP=$CONF_HOME/etc
else
if [ -x /opt/confluent/bin/kafka-server-start ] ; then
CONF_HOME=/opt/confluent
CONF_ETC_TOP=$CONF_HOME/etc
elif [ -f /usr/bin/kafka-server-start ] ; then
CONF_HOME=/usr
CONF_ETC_TOP=/etc
fi
fi
CONF_ZK_PROPERTIES=${CONF_ETC_TOP}/kafka/zookeeper.properties
CONF_KAFKA_PROPERTIES=${CONF_ETC_TOP}/kafka/server.properties
CONF_REST_PROPERTIES=${CONF_ETC_TOP}/kafka-rest/kafka-rest.properties
CONF_SCHEMA_PROPERTIES=${CONF_ETC_TOP}/schema-registry/schema-registry.properties
purge_zkdata() {
eval $(grep ^dataDir ${CONF_ZK_PROPERTIES})
[ -d $dataDir/version-2 ] && rm -rf $dataDir/version-2
}
purge_kafka() {
logDirs=$(grep ^log.dirs= ${CONF_KAFKA_PROPERTIES})
logDirs=${logDirs#*=}
if [ -n "$logDirs" ] ; then
for d in ${logDirs//,/ } ; do
if [ $d != "/" ] ; then
if [ -h $d ] ; then
rm -rf $d/*
else
rm -rf $d
fi
fi
done
fi
}
purge_zkdata
purge_kafka
set +x