2019-09-04 01:30:35 +02:00
|
|
|
#!/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)
|
2019-09-04 02:33:40 +02:00
|
|
|
--nonroot shortcut of '--disttype nonroot'
|
2019-09-04 01:54:01 +02:00
|
|
|
--sysconfdir /etc/sysconfig specify sysconfig directory name
|
2020-02-27 01:16:09 +01:00
|
|
|
--packaging use install.sh for packaging
|
2019-09-04 01:30:35 +02:00
|
|
|
--help this helpful message
|
|
|
|
EOF
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
root=/
|
2019-09-04 01:54:01 +02:00
|
|
|
sysconfdir=/etc/sysconfig
|
2019-09-04 02:33:40 +02:00
|
|
|
nonroot=false
|
2020-02-27 01:16:09 +01:00
|
|
|
packaging=false
|
2019-09-04 01:30:35 +02:00
|
|
|
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
case "$1" in
|
|
|
|
"--root")
|
|
|
|
root="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
"--prefix")
|
|
|
|
prefix="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
2019-09-04 02:33:40 +02:00
|
|
|
"--nonroot")
|
|
|
|
nonroot=true
|
|
|
|
shift 1
|
|
|
|
;;
|
2019-09-04 01:54:01 +02:00
|
|
|
"--sysconfdir")
|
|
|
|
sysconfdir="$2"
|
2019-09-04 01:30:35 +02:00
|
|
|
shift 2
|
|
|
|
;;
|
2020-02-27 01:16:09 +01:00
|
|
|
"--packaging")
|
|
|
|
packaging=true
|
|
|
|
shift 1
|
|
|
|
;;
|
2019-09-04 01:30:35 +02:00
|
|
|
"--help")
|
|
|
|
shift 1
|
|
|
|
print_usage
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
print_usage
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2020-10-05 11:15:19 +02:00
|
|
|
check_usermode_support() {
|
|
|
|
user=$(systemctl --help|grep -e '--user')
|
|
|
|
[ -n "$user" ]
|
|
|
|
}
|
|
|
|
|
2020-02-27 01:16:09 +01:00
|
|
|
if ! $packaging; then
|
|
|
|
has_java=false
|
|
|
|
if [ -x /usr/bin/java ]; then
|
|
|
|
javaver=$(/usr/bin/java -version 2>&1|head -n1|cut -f 3 -d " ")
|
2020-08-26 04:44:46 +02:00
|
|
|
if [[ "$javaver" =~ ^\"1.8.0 || "$javaver" =~ ^\"11.0. ]]; then
|
2020-02-27 01:16:09 +01:00
|
|
|
has_java=true
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if ! $has_java; then
|
2020-08-26 04:44:46 +02:00
|
|
|
echo "Please install openjdk-8 or openjdk-11 before running install.sh."
|
2020-02-27 01:16:09 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2019-09-04 02:33:40 +02:00
|
|
|
if [ -z "$prefix" ]; then
|
|
|
|
if $nonroot; then
|
|
|
|
prefix=~/scylladb
|
|
|
|
else
|
|
|
|
prefix=/opt/scylladb
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
rprefix=$(realpath -m "$root/$prefix")
|
|
|
|
if ! $nonroot; then
|
|
|
|
retc="$root/etc"
|
|
|
|
rsysconfdir="$root/$sysconfdir"
|
|
|
|
rusr="$root/usr"
|
|
|
|
rsystemd="$rusr/lib/systemd/system"
|
|
|
|
else
|
|
|
|
retc="$rprefix/etc"
|
|
|
|
rsysconfdir="$rprefix/$sysconfdir"
|
2020-09-28 10:21:59 +02:00
|
|
|
rsystemd="$HOME/.config/systemd/user"
|
2019-09-04 02:33:40 +02:00
|
|
|
fi
|
2019-09-04 01:30:35 +02:00
|
|
|
|
2019-09-04 01:54:01 +02:00
|
|
|
install -d -m755 "$rsysconfdir"
|
2019-09-04 02:33:40 +02:00
|
|
|
install -d -m755 "$rsystemd"
|
2019-09-04 01:30:35 +02:00
|
|
|
install -d -m755 "$rprefix/scripts" "$rprefix/jmx" "$rprefix/jmx/symlinks"
|
|
|
|
|
2019-09-04 01:54:01 +02:00
|
|
|
install -m644 dist/common/sysconfig/scylla-jmx -Dt "$rsysconfdir"
|
2019-09-04 02:33:40 +02:00
|
|
|
install -m644 dist/common/systemd/scylla-jmx.service -Dt "$rsystemd"
|
|
|
|
if ! $nonroot; then
|
|
|
|
if [ "$sysconfdir" != "/etc/sysconfig" ]; then
|
|
|
|
install -d -m755 "$retc"/systemd/system/scylla-jmx.service.d
|
|
|
|
cat << EOS > "$retc"/systemd/system/scylla-jmx.service.d/sysconfdir.conf
|
2019-09-04 01:54:01 +02:00
|
|
|
[Service]
|
|
|
|
EnvironmentFile=
|
|
|
|
EnvironmentFile=$sysconfdir/scylla-jmx
|
|
|
|
EOS
|
2019-09-04 02:33:40 +02:00
|
|
|
fi
|
|
|
|
else
|
2020-09-28 10:21:59 +02:00
|
|
|
install -d -m755 "$rsystemd"/scylla-jmx.service.d
|
|
|
|
cat << EOS > "$rsystemd"/scylla-jmx.service.d/nonroot.conf
|
2019-09-04 02:33:40 +02:00
|
|
|
[Service]
|
|
|
|
EnvironmentFile=
|
|
|
|
EnvironmentFile=$retc/sysconfig/scylla-jmx
|
|
|
|
ExecStart=
|
|
|
|
ExecStart=$rprefix/jmx/scylla-jmx \$SCYLLA_JMX_PORT \$SCYLLA_API_PORT \$SCYLLA_API_ADDR \$SCYLLA_JMX_ADDR \$SCYLLA_JMX_FILE \$SCYLLA_JMX_LOCAL \$SCYLLA_JMX_REMOTE \$SCYLLA_JMX_DEBUG
|
|
|
|
User=
|
|
|
|
Group=
|
2020-12-28 14:49:47 +01:00
|
|
|
WorkingDirectory=$rprefix
|
2019-09-04 02:33:40 +02:00
|
|
|
EOS
|
2019-09-04 01:54:01 +02:00
|
|
|
fi
|
2019-09-04 01:30:35 +02:00
|
|
|
|
|
|
|
install -m644 scylla-jmx-1.0.jar "$rprefix/jmx"
|
|
|
|
install -m755 scylla-jmx "$rprefix/jmx"
|
|
|
|
ln -sf /usr/bin/java "$rprefix/jmx/symlinks/scylla-jmx"
|
2020-01-16 14:51:39 +01:00
|
|
|
if ! $nonroot; then
|
|
|
|
install -m755 -d "$rusr"/lib/scylla/jmx/symlinks
|
|
|
|
ln -srf "$rprefix"/jmx/scylla-jmx-1.0.jar "$rusr"/lib/scylla/jmx/
|
|
|
|
ln -srf "$rprefix"/jmx/scylla-jmx "$rusr"/lib/scylla/jmx/
|
|
|
|
ln -sf /usr/bin/java "$rusr"/lib/scylla/jmx/symlinks/scylla-jmx
|
|
|
|
fi
|
2019-09-04 02:33:40 +02:00
|
|
|
|
|
|
|
if $nonroot; then
|
|
|
|
sed -i -e "s#/var/lib/scylla#$rprefix#g" "$rsysconfdir"/scylla-jmx
|
|
|
|
sed -i -e "s#/etc/scylla#$rprefix/etc/scylla#g" "$rsysconfdir"/scylla-jmx
|
|
|
|
sed -i -e "s#/opt/scylladb/jmx#$rprefix/jmx#g" "$rsysconfdir"/scylla-jmx
|
2020-10-05 11:15:19 +02:00
|
|
|
if check_usermode_support; then
|
|
|
|
systemctl --user daemon-reload
|
|
|
|
fi
|
2019-09-04 02:33:40 +02:00
|
|
|
echo "Scylla-JMX non-root install completed."
|
2020-02-27 01:16:09 +01:00
|
|
|
elif ! $packaging; then
|
|
|
|
systemctl --system daemon-reload
|
2019-09-04 02:33:40 +02:00
|
|
|
fi
|