Files
scylladb/dist/common/scripts/scylla_ntp_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

42 lines
1.0 KiB
Bash
Executable File

#!/bin/bash -e
#
# Copyright (C) 2015 ScyllaDB
print_usage() {
echo "scylla_ntp_setup --subdomain centos"
echo " --subdomain specify subdomain of pool.ntp.org (ex: centos, fedora or amazon)"
exit 1
}
while [ $# -gt 0 ]; do
case "$1" in
"--subdomain")
DOMAIN="$2"
shift 2
;;
*)
print_usage
;;
esac
done
. /etc/os-release
if [ "$NAME" = "Ubuntu" ]; then
apt-get install -y ntp ntpdate
service ntp stop
ntpdate `cat /etc/ntp.conf |grep "^server"|head -n1|awk '{print $2}'`
service ntp start
else
yum install -y ntp ntpdate || true
if [ "$DOMAIN" != "" ]; then
sed -e "s#\..*\.pool\.ntp\.org#.$DOMAIN.pool.ntp.org#" /etc/ntp.conf > /tmp/ntp.conf
mv /tmp/ntp.conf /etc/ntp.conf
fi
if [ "`systemctl is-active ntpd`" = "active" ]; then
systemctl stop ntpd.service
fi
ntpdate `cat /etc/ntp.conf |grep "^server"|head -n1|awk '{print $2}'`
systemctl enable ntpd.service
systemctl start ntpd.service
fi