Skip to content

Commit

Permalink
Merge "Add Gentoo Linux support to utility and setup scripts" from Al…
Browse files Browse the repository at this point in the history
…exys

"These patches add support to setup and operate ScyllaDB on Gentoo Linux.

 * scylla_setup and related scripts
 * node_health_check

 I have kept them as simple as possible and tested them to setup and operate
 succesfully a three nodes cluster running on Gentoo Linux."

* 'gentoo_linux_support' of github.com:ultrabug/scylla:
  scylla_setup: add gentoo linux installation detection
  prometheus node_exporter install: add support for gentoo linux
  raid setup: add support for gentoo linux
  ntp setup: add support for gentoo linux
  kernel check: add support for gentoo linux
  cpuscaling setup: add support for gentoo linux
  coredump setup: add support for gentoo linux
  detect gentoo linux on selinux setup
  add gentoo_variant detection and SYSCONFIG setup
  • Loading branch information
penberg committed May 18, 2017
2 parents 2aa5b3e + fa0944a commit 30b5933
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 20 deletions.
44 changes: 28 additions & 16 deletions dist/common/scripts/node_exporter_install
Expand Up @@ -22,26 +22,37 @@ if [ "`id -u`" -ne 0 ]; then
exit 1
fi

if [ -f /usr/bin/node_exporter ]; then
if [ -f /usr/bin/node_exporter ] || [ -f /usr/bin/prometheus-node_exporter ]; then
echo "node_exporter already installed"
exit 1
fi

version=0.12.0
dir=/usr/lib/scylla/Prometheus/node_exporter
mkdir -p $dir
cd $dir
curl -L https://github.com/prometheus/node_exporter/releases/download/$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 [ "$(cat /proc/1/comm)" = "systemd" ]; then
systemctl enable node-exporter
systemctl start node-exporter
. /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
service prometheus-node_exporter start
fi
else
cat <<EOT >> /etc/init/node_exporter.conf
version=0.12.0
dir=/usr/lib/scylla/Prometheus/node_exporter
mkdir -p $dir
cd $dir
curl -L https://github.com/prometheus/node_exporter/releases/download/$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
Expand All @@ -50,7 +61,8 @@ script
/usr/bin/node_exporter
end script
EOT
service node_exporter start
service node_exporter start
fi
fi

printf "node_exporter successfully installed\n"
2 changes: 1 addition & 1 deletion dist/common/scripts/scylla_coredump_setup
Expand Up @@ -32,7 +32,7 @@ done
if [ "$ID" = "ubuntu" ] && [ "$VERSION_ID" != "16.04" ]; then
apt-get remove -y apport-noui
sysctl -p /etc/sysctl.d/99-scylla.conf
elif [ "$ID" = "debian" ]; then
elif [ "$ID" = "debian" ] || [ "$ID" = "gentoo" ]; then
sysctl -p /etc/sysctl.d/99-scylla.conf
else
if [ "$ID" = "ubuntu" ]; then
Expand Down
10 changes: 10 additions & 0 deletions dist/common/scripts/scylla_cpuscaling_setup
Expand Up @@ -12,6 +12,16 @@ if is_debian_variant; then
systemctl enable cpufrequtils.service
fi
service cpufrequtils start
elif is_gentoo_variant; then
emerge -uq sys-power/cpupower
sed -e 's/--governor ondemand/--governor performance/g' -i /etc/conf.d/cpupower
if is_systemd; then
systemctl enable cpupower-frequency-set.service
systemctl start cpupower-frequency-set.service
else
rc-update add cpupower default
service cpupower start
fi
else
yum install -y cpupowerutils || true
echo 'CPUPOWER_START_OPTS="frequency-set -g performance"' > /etc/sysconfig/cpupower
Expand Down
2 changes: 2 additions & 0 deletions dist/common/scripts/scylla_kernel_check
Expand Up @@ -7,6 +7,8 @@
if [ ! -f /sbin/mkfs.xfs ]; then
if is_debian_variant; then
apt-get install -y xfsprogs
elif is_gentoo_variant; then
emerge -uq sys-fs/xfsprogs
else
yum install -y xfsprogs
fi
Expand Down
6 changes: 5 additions & 1 deletion dist/common/scripts/scylla_lib.sh
Expand Up @@ -9,6 +9,10 @@ is_redhat_variant() {
[ -f /etc/redhat-release ]
}

is_gentoo_variant() {
[ -f /etc/gentoo-release ]
}

is_systemd() {
grep -q '^systemd$' /proc/1/comm
}
Expand All @@ -26,7 +30,7 @@ ec2_is_supported_instance_type() {
}

. /etc/os-release
if is_debian_variant; then
if is_debian_variant || is_gentoo_variant; then
SYSCONFIG=/etc/default
else
SYSCONFIG=/etc/sysconfig
Expand Down
10 changes: 10 additions & 0 deletions dist/common/scripts/scylla_ntp_setup
Expand Up @@ -35,6 +35,16 @@ if is_debian_variant; then
fi
ntpdate `cat /etc/ntp.conf |egrep "^server"|head -n1|awk '{print $2}'`
service ntp start
elif is_gentoo_variant; then
emerge -uq net-misc/ntp
pidof ntpd &>/dev/null || ntpdate `cat /etc/ntp.conf |grep "^server"|head -n1|awk '{print $2}'`
if is_systemd; then
systemctl enable sntpd.service
systemctl start sntpd.service
else
rc-update add ntpd default
service ntpd start
fi
else
yum install -y ntp ntpdate || true
if [ "$DOMAIN" != "" ]; then
Expand Down
2 changes: 2 additions & 0 deletions dist/common/scripts/scylla_raid_setup
Expand Up @@ -88,6 +88,8 @@ fi

if is_debian_variant; then
env DEBIAN_FRONTEND=noninteractive apt-get -y install mdadm xfsprogs
elif is_gentoo_variant; then
emerge -uq sys-fs/mdadm sys-fs/xfsprogs
else
yum -y install mdadm xfsprogs
fi
Expand Down
4 changes: 3 additions & 1 deletion dist/common/scripts/scylla_selinux_setup
Expand Up @@ -4,7 +4,9 @@

. /usr/lib/scylla/scylla_lib.sh

if ! is_debian_variant; then
if is_debian_variant || is_gentoo_variant; then
echo "scylla_selinux_setup only supports Red Hat variants"
else
if [ "`sestatus | awk '{print $3}'`" != "disabled" ]; then
setenforce 0
sed --follow-symlinks -i -e "s/^SELINUX=enforcing/SELINUX=disabled/" /etc/sysconfig/selinux
Expand Down
9 changes: 8 additions & 1 deletion dist/common/scripts/scylla_setup
Expand Up @@ -74,6 +74,8 @@ interactive_ask_service() {
verify_package() {
if is_debian_variant; then
dpkg -s $1 > /dev/null 2>&1 &&:
elif is_gentoo_variant; then
find /var/db/pkg/dev-db -type d -name "${1}-*" | egrep -q ".*"
else
rpm -q $1 > /dev/null 2>&1 &&:
fi
Expand Down Expand Up @@ -269,6 +271,9 @@ if [ $ENABLE_SERVICE -eq 1 ]; then
if is_systemd; then
systemctl enable scylla-server.service
systemctl enable collectd.service
elif is_gentoo_variant; then
rc-update add scylla-server default
rc-update add collectd default
fi
if [ $INTERACTIVE -eq 1 ] && [ ! -f /etc/scylla.d/housekeeping.cfg ]; then
interactive_ask_service "Do you want to enable ScyllaDB version check?" "Answer yes to automatically start Scylla-housekeeping service that checks for a newer version periodically; answer no to skip this step." "yes" &&:
Expand Down Expand Up @@ -304,7 +309,9 @@ if [ "$CUR_VERSION" != "" ]; then
fi

# scylla_selinux_setup only supports Red Hat variants
if ! is_debian_variant; then
if is_debian_variant || is_gentoo_variant; then
echo "scylla_selinux_setup only supports Red Hat variants"
else
if [ $INTERACTIVE -eq 1 ]; then
interactive_ask_service "Do you want to disable SELinux?" "Answer yes to disable SELinux and improve performance; answer no to keep it activated." "yes" &&:
SELINUX_SETUP=$?
Expand Down

0 comments on commit 30b5933

Please sign in to comment.