Files
scylladb/dist/common/scripts/node_exporter_install
Alexys Jacob 604bc40d8a dist: migrate gentoo variant setup scripts from /sbin/service to /sbin/rc-service
the 'service' binary has been removed from gentoo as per news 2017-10-13:
https://gitweb.gentoo.org/data/gentoo-news.git/plain/2017-10-13-openrc-service-binary-removal/2017-10-13-openrc-service-binary-removal.en.txt

this patch updates the scylla setup related scripts where it was used and
make use of the 'rc-service' binary instead

Signed-off-by: Alexys Jacob <ultrabug@gentoo.org>
Message-Id: <20180119161310.15435-1-ultrabug@gentoo.org>
2018-01-21 17:15:26 +02:00

69 lines
2.1 KiB
Bash
Executable File

#!/bin/sh
#
# Copyright 2016 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/>.
if [ "`id -u`" -ne 0 ]; then
echo "Requires root permission."
exit 1
fi
if [ -f /usr/bin/node_exporter ] || [ -f /usr/bin/prometheus-node_exporter ]; then
echo "node_exporter already installed"
exit 1
fi
. /usr/lib/scylla/scylla_lib.sh
if is_gentoo_variant; then
emerge -uq net-analyzer/prometheus-node_exporter
if is_systemd; then
echo "net-analyzer/prometheus-node_exporter does not install systemd service files, please fill a bug if you need them."
else
rc-update add prometheus-node_exporter default
rc-service prometheus-node_exporter start
fi
else
version=0.14.0
dir=/usr/lib/scylla/Prometheus/node_exporter
mkdir -p $dir
cd $dir
curl -L https://github.com/prometheus/node_exporter/releases/download/v$version/node_exporter-$version.linux-amd64.tar.gz -o $dir/node_exporter-$version.linux-amd64.tar.gz
tar -xvzf $dir/node_exporter-$version.linux-amd64.tar.gz
rm $dir/node_exporter-$version.linux-amd64.tar.gz
ln -s $dir/node_exporter-$version.linux-amd64/node_exporter /usr/bin
. /etc/os-release
if is_systemd; then
systemctl enable node-exporter
systemctl start node-exporter
else
cat <<EOT >> /etc/init/node_exporter.conf
# Run node_exporter
start on startup
script
/usr/bin/node_exporter
end script
EOT
service node_exporter start
fi
fi
printf "node_exporter successfully installed\n"