-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_pulsar.sh
executable file
·54 lines (41 loc) · 1.45 KB
/
install_pulsar.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
#!/bin/bash
#title :pulsar_install.sh
#description :The script to install pulsar
#author :Motty Cohen
#date :05-Feb-2015
#usage :/bin/bash install_pulsar.sh
#PULSAR_VERSION=$1
PULSAR_FILENAME=apache-pulsar-$PULSAR_VERSION
PULSAR_ARCHIVE_NAME=${PULSAR_FILENAME}-bin.tar.gz
#https://repo.huaweicloud.com/apache/pulsar/pulsar-2.11.0/apache-pulsar-2.11.0-bin.tar.gz
PULSAR_DOWNLOAD_ADDRESS=https://repo.huaweicloud.com/apache/pulsar/pulsar-$PULSAR_VERSION/$PULSAR_ARCHIVE_NAME
INSTALL_DIR=/opt
PULSAR_FULL_DIR=$INSTALL_DIR/$PULSAR_FILENAME
PULSAR_DIR=$INSTALL_DIR/pulsar
PULSAR_SERVICE=pulsar
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root."
exit 1
fi
echo "Downloading: $PULSAR_DOWNLOAD_ADDRESS..."
[ -e "$PULSAR_ARCHIVE_NAME" ] && echo 'pulsar archive already exists.'
if [ ! -e "$PULSAR_ARCHIVE_NAME" ]; then
curl -fsSLO --compressed $PULSAR_DOWNLOAD_ADDRESS
if [ $? -ne 0 ]; then
echo "Not possible to download pulsar."
exit 1
fi
fi
echo "Cleaning up..."
rm -f "$PULSAR_DIR"
rm -rf "$PULSAR_FULL_DIR"
rm -rf "/var/run/$PULSAR_SERVICE/"
rm -f "/etc/init.d/$PULSAR_SERVICE"
echo "Installation to $PULSAR_FULL_DIR ..."
mkdir $PULSAR_FULL_DIR
tar -zxvf $PULSAR_ARCHIVE_NAME -C $INSTALL_DIR
echo "Creating symbolic link: to $PULSAR_DIR ..."
ln -s $PULSAR_FULL_DIR/ $PULSAR_DIR
echo "Cleaning archive..."
rm -f "$PULSAR_ARCHIVE_NAME"