summaryrefslogtreecommitdiffstats
path: root/cluster/ocfs2-tools
diff options
context:
space:
mode:
authorVlad Glagolev2011-01-15 07:43:47 +0300
committerVlad Glagolev2011-01-15 07:43:47 +0300
commitaee22c9695e07e8d19f3c0fb0f772a967ccbf238 (patch)
treea10cdf8d7ee49d1cf36194207af008cc38024a67 /cluster/ocfs2-tools
parent5d62eda50e17aa406234e60663daeb7e9f051202 (diff)
ocfs2-tools: added init system
Diffstat (limited to 'cluster/ocfs2-tools')
-rwxr-xr-xcluster/ocfs2-tools/DETAILS6
-rw-r--r--cluster/ocfs2-tools/HISTORY5
-rwxr-xr-xcluster/ocfs2-tools/INSTALL11
-rwxr-xr-xcluster/ocfs2-tools/init.d/ocfs296
-rw-r--r--cluster/ocfs2-tools/init.d/ocfs2.conf3
5 files changed, 118 insertions, 3 deletions
diff --git a/cluster/ocfs2-tools/DETAILS b/cluster/ocfs2-tools/DETAILS
index 8cdc0a6396..ca2e19486b 100755
--- a/cluster/ocfs2-tools/DETAILS
+++ b/cluster/ocfs2-tools/DETAILS
@@ -9,12 +9,12 @@ SOURCE_DIRECTORY="${BUILD_DIRECTORY}/${SPELL}-${VERSION}"
ENTERED=20060711
LICENSE[0]=GPL
KEYWORDS="cluster filesystem"
- SHORT="Tools for OCFS2 cluster filesystem"
+ SHORT="tools for OCFS2 cluster filesystem"
cat << EOF
OCFS2 is a general purpose extent based shared disk cluster file system
with many similarities to ext3. It supports 64 bit inode numbers, and has
automatically extending metadata groups which may also make it attractive
for non-clustered use.
-This spell provides tools for creating, checking, mounting and tuning OCFS2 file-
-systems.
+This spell provides tools for creating, checking, mounting and tuning OCFS2
+file-systems.
EOF
diff --git a/cluster/ocfs2-tools/HISTORY b/cluster/ocfs2-tools/HISTORY
index 0ad9532cd1..2db2e9f43b 100644
--- a/cluster/ocfs2-tools/HISTORY
+++ b/cluster/ocfs2-tools/HISTORY
@@ -1,3 +1,8 @@
+2011-01-15 Vlad Glagolev <stealth@sourcemage.org>
+ * init.d/ocfs2{,.conf}: added init script and config (adopted from
+ official vendor-based script in distribution tarball, though without
+ fuser support)
+
2010-12-08 Vlad Glagolev <stealth@sourcemage.org>
* DETAILS: updated spell to 1.6.3
diff --git a/cluster/ocfs2-tools/INSTALL b/cluster/ocfs2-tools/INSTALL
new file mode 100755
index 0000000000..afe023ded4
--- /dev/null
+++ b/cluster/ocfs2-tools/INSTALL
@@ -0,0 +1,11 @@
+default_install &&
+
+install -vm 755 -d "$INSTALL_ROOT/etc/ocfs2" &&
+
+if [[ $INIT_INSTALLED ]]; then
+ install_config_file "$SOURCE_DIRECTORY/documentation/samples/cluster.conf" \
+ "$INSTALL_ROOT/etc/ocfs2/cluster.conf" &&
+
+ install_config_file "$SPELL_DIRECTORY/init.d/ocfs2.conf" \
+ "$INSTALL_ROOT/etc/sysconfig/ocfs2"
+fi
diff --git a/cluster/ocfs2-tools/init.d/ocfs2 b/cluster/ocfs2-tools/init.d/ocfs2
new file mode 100755
index 0000000000..ff05e17299
--- /dev/null
+++ b/cluster/ocfs2-tools/init.d/ocfs2
@@ -0,0 +1,96 @@
+#!/bin/bash
+
+# Copyright (c) 2005 Oracle
+# All rights reserved.
+#
+# Copyright (c) 2011 Source Mage Team
+# Vlad Glagolev
+
+. /etc/sysconfig/ocfs2
+
+PROGRAM=/bin/false
+RUNLEVEL=3
+NEEDS="+local_fs +network"
+
+. /etc/init.d/smgl_init
+
+MOUNT="/bin/mount"
+UMOUNT="/bin/umount"
+O2CB_CTL="/sbin/o2cb_ctl"
+
+OCFS2_CLUSTER=$( sed -re 's/[[:space:]]+//g' $OCFS2_CONFIG | grep -A4 "cluster:" | grep 'name=' | cut -d= -f2 )
+
+function check_pseudofs() {
+ if [ -z "`$MOUNT -l -t configfs`" ] || [ -z "`$MOUNT -l -t ocfs2_dlmfs`" ]; then
+ echo "One or more pseudo-filesystems required for OCFS2 are not mounted."
+ echo "Make sure you have following lines in your /etc/fstab:"
+ echo "none /config configfs defaults 0 0"
+ echo "none /dlm ocfs2_dlmfs defaults 0 0"
+
+ return 1
+ fi
+}
+
+function ocfs2mounts() {
+ LC_ALL=C awk '$3 == "ocfs2" { print $2 }' /proc/mounts
+}
+
+function ocfs2fstab() {
+ LC_ALL=C awk '!/^#/ && $3 == "ocfs2" && $4 !~ /noauto/ { print $2 }' /etc/fstab
+}
+
+start() {
+ check_pseudofs || exit 1
+
+ echo "Starting OCFS2 cluster..."
+
+ for cluster in ${OCFS2_CLUSTER}; do
+ $O2CB_CTL -H -n ${cluster} -t cluster -a online=yes >/dev/null 2>&1
+ evaluate_retval
+ done
+}
+
+stop() {
+ echo "Unmounting OCFS2 filesystems..."
+
+ remaining="`ocfs2mounts`"
+ retry=3
+
+ while [ -n "$remaining" -a "$retry" -gt 0 ]; do
+ $UMOUNT -a -t ocfs2 2>/dev/null
+ sleep 1
+
+ remaining="`ocfs2mounts`"
+
+ [ -z "$remaining" ] && break
+
+ retry=$(($retry - 1))
+ done
+
+ if [ ! -z "$remaining" ]; then
+ print_status failure
+ exit 1
+ fi
+
+ echo "Stopping OCFS2 cluster..."
+
+ for cluster in ${OCFS2_CLUSTER}; do
+ $O2CB_CTL -H -n ${cluster} -t cluster -a online=no >/dev/null 2>&1
+ evaluate_retval
+ done
+}
+
+restart() {
+ echo "Restarting OCFS2 cluster..."
+
+ stop
+ sleep 1
+ start
+}
+
+status() {
+ if [ -f /proc/mounts ]; then
+ [ -n "`ocfs2fstab`" ] && echo "Configured OCFS2 mountpoints: " `ocfs2fstab`
+ [ -n "`ocfs2mounts`" ] && echo "Active OCFS2 mountpoints: " `ocfs2mounts`
+ fi
+}
diff --git a/cluster/ocfs2-tools/init.d/ocfs2.conf b/cluster/ocfs2-tools/init.d/ocfs2.conf
new file mode 100644
index 0000000000..d8210aa253
--- /dev/null
+++ b/cluster/ocfs2-tools/init.d/ocfs2.conf
@@ -0,0 +1,3 @@
+# Full path to OCFS2 cluster configuration file
+
+OCFS2_CONFIG="/etc/ocfs2/cluster.conf"