-
Notifications
You must be signed in to change notification settings - Fork 87
/
install.sh
executable file
·146 lines (129 loc) · 4.08 KB
/
install.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/bash
#
# Copyright (C) 2019 ScyllaDB
#
#
# This file is part of Scylla.
#
# Scylla is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Scylla is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Scylla. If not, see <http://www.gnu.org/licenses/>.
#
set -e
print_usage() {
cat <<EOF
Usage: install.sh [options]
Options:
--root /path/to/root alternative install root (default /)
--prefix /prefix directory prefix (default /usr)
--etcdir /etc specify etc directory path (default /etc)
--nonroot install Scylla without required root priviledge
--help this helpful message
EOF
exit 1
}
root=/
etcdir=/etc
nonroot=false
while [ $# -gt 0 ]; do
case "$1" in
"--root")
root="$2"
shift 2
;;
"--prefix")
prefix="$2"
shift 2
;;
"--etcdir")
etcdir="$2"
shift 2
;;
"--nonroot")
nonroot=true
shift 1
;;
"--help")
shift 1
print_usage
;;
*)
print_usage
;;
esac
done
if [ -z "$prefix" ]; then
if $nonroot; then
prefix=~/scylladb
else
prefix=/opt/scylladb
fi
fi
install() {
command install -Z "$@"
}
scylla_version=$(cat SCYLLA-VERSION-FILE)
scylla_release=$(cat SCYLLA-RELEASE-FILE)
rprefix=$(realpath -m "$root/$prefix")
if ! $nonroot; then
retc="$root/$etcdir"
rusr="$root/usr"
else
retc="$rprefix/$etcdir"
fi
install -d -m755 "$rprefix"/share/cassandra/bin
if ! $nonroot; then
install -d -m755 "$rusr"/bin
fi
thunk="#!/usr/bin/env bash
b=\"\$(basename \"\$0\")\"
bindir=\"$prefix/share/cassandra/bin\"
exec -a \"\$0\" \"\$bindir/\$b\" \"\$@\""
# scylla-tools-core
install -d -m755 "$retc"/scylla/cassandra
install -d -m755 "$rprefix"/share/cassandra/lib
install -d -m755 "$rprefix"/share/cassandra/doc
install -d -m755 "$rprefix"/share/cassandra/doc/cql3
install -m644 conf/cassandra-env.sh "$retc"/scylla/cassandra
install -m644 conf/logback.xml "$retc"/scylla/cassandra
install -m644 conf/logback-tools.xml "$retc"/scylla/cassandra
install -m644 conf/jvm*.options "$retc"/scylla/cassandra
install -m644 lib/*.jar "$rprefix"/share/cassandra/lib
install -m644 doc/cql3/CQL.css doc/cql3/CQL.html "$rprefix"/share/cassandra/doc/cql3
ln -srf "$rprefix"/share/cassandra/lib/apache-cassandra-$scylla_version-$scylla_release.jar "$rprefix"/share/cassandra/lib/apache-cassandra.jar
install -m644 dist/common/cassandra.in.sh "$rprefix"/share/cassandra/bin
if $nonroot; then
sed -i -e "s#/var/lib/scylla#$rprefix#g" "$rprefix"/share/cassandra/bin/cassandra.in.sh
sed -i -e "s#/etc/scylla#$retc/scylla#g" "$rprefix"/share/cassandra/bin/cassandra.in.sh
sed -i -e "s#/opt/scylladb/#$rprefix/#g" "$rprefix"/share/cassandra/bin/cassandra.in.sh
fi
install_tool_bin () {
bin_src=$1
if [ $# -eq 1 ]; then
bin_dest=$(basename "$bin_src")
else
bin_dest=$2
fi
install -m755 "$bin_src" "$rprefix"/share/cassandra/bin/"$bin_dest"
if ! $nonroot; then
echo "$thunk" > "$rusr"/bin/"$bin_dest"
chmod 755 "$rusr"/bin/"$bin_dest"
fi
}
# scylla-tools
for i in bin/{sstableloader,scylla-sstableloader} tools/bin/{cassandra-stress,cassandra-stressd,sstabledump,sstablelevelreset,sstablemetadata,sstablerepairedset}; do
install_tool_bin "$i"
done
# Don't create the thunk in $rusr/bin for nodetool, this command is now only
# available as a backup in $rprefix/share/cassandra/bin/nodetool, in case the
# native nodetool doesn't work.
install -m755 bin/nodetool "$rprefix"/share/cassandra/bin/nodetool