Files
scylladb/dist/common/scripts/scylla_sysconfig_setup
Takuya ASADA f98997120a dist: #!/bin/bash for all scripts
We choosed #!/bin/sh for shebang when we started to implement installer scripts, not bash.
After we started to work on Ubuntu, we found that we mistakenly used bash syntax on AMI script, it caused error since /bin/sh is dash on Ubuntu.
So we changed shebang to /bin/bash for the script, from that time we have both sh scripts and bash scripts.
(2f39e2e269)
If we use bash syntax on sh scripts, it won't work on Ubuntu but works on Fedora/CentOS, could be very easy to confusing.
So switch all scripts to #!/bin/bash. It will much safer.

Signed-off-by: Takuya ASADA <syuu@scylladb.com>
Message-Id: <1460594643-30666-1-git-send-email-syuu@scylladb.com>
2016-04-14 12:01:28 +03:00

97 lines
2.7 KiB
Bash
Executable File

#!/bin/bash -e
#
# Copyright (C) 2015 ScyllaDB
print_usage() {
echo "scylla-sysconfig-setup --nic eth0 --mode posix --nr-hugepages 64 --user scylla --group scylla --homedir /var/lib/scylla --confdir /etc/scylla --setup-nic"
echo " --nic specify NIC"
echo " --mode network mode (posix, dpdk)"
echo " --nr-hugepages number of hugepages"
echo " --user user (dpdk requires root)"
echo " --group group (dpdk requires root)"
echo " --homedir scylla home directory"
echo " --confdir scylla config directory"
echo " --setup-nic setup NIC's interrupts, RPS, XPS"
echo " --ami AMI instance mode"
exit 1
}
. /etc/os-release
if [ "$ID" = "ubuntu" ]; then
SYSCONFIG=/etc/default
else
SYSCONFIG=/etc/sysconfig
fi
. $SYSCONFIG/scylla-server
if [ $# -eq 0 ]; then
print_usage
fi
while [ $# -gt 0 ]; do
case "$1" in
"--nic")
NIC="$2"
shift 2
;;
"--mode")
NETWORK_MODE="$2"
shift 2
;;
"--nr-hugepages")
NR_HUGEPAGES="$2"
shift 2
;;
"--user")
USER="$2"
shift 2
;;
"--group")
GROUP="$2"
shift 2
;;
"--homedir")
SCYLLA_HOME="$2"
shift 2
;;
"--confdir")
SCYLLA_CONF="$2"
shift 2
;;
"--setup-nic")
SET_NIC=yes
shift 1
;;
"--ami")
AMI=yes
shift 1
;;
*)
print_usage
;;
esac
done
echo Setting parameters on $SYSCONFIG/scylla-server
ETHDRV=`/usr/lib/scylla/dpdk_nic_bind.py --status | grep if=$NIC | sed -e "s/^.*drv=//" -e "s/ .*$//"`
ETHPCIID=`/usr/lib/scylla/dpdk_nic_bind.py --status | grep if=$NIC | awk '{print $1}'`
NR_CPU=`cat /proc/cpuinfo |grep processor|wc -l`
if [ "$AMI" = "yes" ] && [ $NR_CPU -ge 8 ] && [ "$SET_NIC" = "no" ]; then
NR=$((NR_CPU - 1))
SET_NIC="yes"
SCYLLA_ARGS="$SCYLLA_ARGS --cpuset 1-$NR --smp $NR"
fi
sed -e s#^NETWORK_MODE=.*#NETWORK_MODE=$NETWORK_MODE# \
-e s#^ETHDRV=.*#ETHDRV=$ETHDRV# \
-e s#^ETHPCIID=.*#ETHPCIID=$ETHPCIID# \
-e s#^NR_HUGEPAGES=.*#NR_HUGEPAGES=$NR_HUGEPAGES# \
-e s#^USER=.*#USER=$USER# \
-e s#^GROUP=.*#GROUP=$GROUP# \
-e s#^SCYLLA_HOME=.*#SCYLLA_HOME=$SCYLLA_HOME# \
-e s#^SCYLLA_CONF=.*#SCYLLA_CONF=$SCYLLA_CONF# \
-e s#^SET_NIC=.*#SET_NIC=$SET_NIC# \
-e "s#^SCYLLA_ARGS=.*#SCYLLA_ARGS=\"$SCYLLA_ARGS\"#" \
-e s#^AMI=.*#AMI=$AMI# \
$SYSCONFIG/scylla-server > /tmp/scylla-server
mv /tmp/scylla-server $SYSCONFIG/scylla-server