diff mbox

init.d script dirty hack

Message ID 20130207.122721.55387722.yasu@soe.ucsc.edu (mailing list archive)
State New, archived
Headers show

Commit Message

Yasuhiro Ohara Feb. 7, 2013, 8:27 p.m. UTC

I know that Ceph is going to use more sophisticated version of
start-up mechanisms, but in case if anyone is interested,
here I share my tweak on the Ceph's init.d script.

We're using Fedora and it switched to systemd from upstart.
Ceph does not seem to support systemd yet, so I needed to use
the old init.d script.

Since I wanted to use a different name in the configuration file,
such as node-1, node-2 (set as a DNS alias using CNAME),
instead of the real hostname such as 'saturn' and 'jupiter',
I made a few modifications to the script.
The modifications work like this: acquire the IP address
by the reverse DNS lookup using 'dig' command,
and if the IP addresses from both the hostname of the host
and the hostname from the configuration are identical,
overwrite 'hostname' variable to the one from the configuration file.

Also, system start up mechanism nowadays seems work in parallel:
we may not have the hostname properly set yet when the init script issued.
So I made a sleep cycle in the script.

diff mbox


--- etc-init.d-ceph.bak	2013-02-05 16:05:56.246138380 -0800
+++ 2013-02-05-ceph-sysvinit/etc-init.d-ceph	2013-02-05 16:07:30.586927312 -0800
@@ -34,6 +34,17 @@ 
+while [ `hostname -s` = "localhost" ]; do
+    echo "$0: hostname not yet, sleeping $waitsec seconds."
+    sleep "$waitsec"
+    waitsec=`expr $waitsec \* 2`
+    if [ $waitsec -gt 30 ]; then
+        echo "$0: hostname not yet, give up."
+        exit
+    fi
 . $LIBDIR/ceph_common.sh