SOURCES: o2cb.init, ocfs2.init - very first steps to pldize
zbyniu
zbyniu at pld-linux.org
Sat Mar 31 12:32:37 CEST 2007
Author: zbyniu Date: Sat Mar 31 10:32:37 2007 GMT
Module: SOURCES Tag: HEAD
---- Log message:
- very first steps to pldize
---- Files affected:
SOURCES:
o2cb.init (1.1 -> 1.2) , ocfs2.init (1.1 -> 1.2)
---- Diffs:
================================================================
Index: SOURCES/o2cb.init
diff -u SOURCES/o2cb.init:1.1 SOURCES/o2cb.init:1.2
--- SOURCES/o2cb.init:1.1 Tue Oct 17 02:25:59 2006
+++ SOURCES/o2cb.init Sat Mar 31 12:32:32 2007
@@ -1,52 +1,18 @@
-#!/bin/sh
+#!/bin/bash
+#
# init fragment for O2CB.
#
-# chkconfig: 2345 24 20
-# description: Load O2CB cluster services at system boot.
+# chkconfig: 2345 24 20
+# description: Load O2CB cluster services at system boot.
#
-### BEGIN INIT INFO
-# Provides: o2cb
-# Required-Start: $network
-# Should-Start:
-# Required-Stop:
-# Default-Start: 2 3 5
-# Default-Stop:
-# Description: Load O2CB cluster services at system boot.
-### END INIT INFO
-
-# Force LC_ALL=C
-export LC_ALL=C
-CLUSTERCONF=/etc/ocfs2/cluster.conf
+# Source function library
+. /etc/rc.d/init.d/functions
-if [ -f /etc/sysconfig/o2cb ]
-then
- # Red Hat and Novell
- CONFIGURATION=/etc/sysconfig/o2cb
-elif [ -f /etc/default/o2cb ]
-then
- # Debian
- CONFIGURATION=/etc/default/o2cb
-elif [ -d /etc/sysconfig ]
-then
- CONFIGURATION=/etc/sysconfig/o2cb
-else
- CONFIGURATION=/etc/default/o2cb
-fi
+# Try get config
+[ -f /etc/sysconfig/o2cb ] && . /etc/sysconfig/o2cb
-# Source configuration,
-[ -f "${CONFIGURATION}" ] && . "${CONFIGURATION}"
-
-configfs_path()
-{
- # Note that this is only valid *after* configfs is loaded
- if [ -d /sys/kernel/config ]
- then
- echo /sys/kernel/config
- else
- echo /config
- fi
-}
+CLUSTERCONF=/etc/ocfs2/cluster.conf
#
# This is a tricky bit of eval work. There are many steps involved in
@@ -71,7 +37,7 @@
# appropriate place. Be careful, eval requires quoting to be right.
#
LOAD_ACTIONS=("load_module configfs"
- "mount_fs configfs "'$(configfs_path)'
+ "mount_fs configfs /sys/kernel/config"
"load_module ocfs2_nodemanager"
"load_module ocfs2_dlm"
"load_module ocfs2_dlmfs"
@@ -105,178 +71,13 @@
exit 1
}
-
-#
-# write_sysconfig()
-#
-# Writes the system configuration out
-#
-write_sysconfig()
-{
- echo -n "Writing O2CB configuration: "
- cat >"${CONFIGURATION}" <<EOF
-#
-# This is a configuration file for automatic startup of the O2CB
-# driver. It is generated by running /etc/init.d/o2cb configure.
-# Please use that method to modify this file
-#
-
-# O2CB_ENABELED: 'true' means to load the driver on boot.
-O2CB_ENABLED=${O2CB_ENABLED:-false}
-
-# O2CB_BOOTCLUSTER: If not empty, the name of a cluster to start.
-O2CB_BOOTCLUSTER=${O2CB_BOOTCLUSTER}
-
-# O2CB_HEARTBEAT_THRESHOLD: Iterations before a node is considered dead.
-O2CB_HEARTBEAT_THRESHOLD=${O2CB_HEARTBEAT_THRESHOLD}
-
-EOF
-
- if [ $? != 0 ]
- then
- return 1
- fi
- return 0
-}
-
-#
-# configure_ask()
-#
-# Ask configuration questions, setting the shell vars.
-#
-configure_ask()
-{
- cat <<EOF
-Configuring the O2CB driver.
-
-This will configure the on-boot properties of the O2CB driver.
-The following questions will determine whether the driver is loaded on
-boot. The current values will be shown in brackets ('[]'). Hitting
-<ENTER> without typing an answer will keep that current value. Ctrl-C
-will abort.
-
-EOF
-
- while :
- do
- if [ "$O2CB_ENABLED" = "true" ]
- then
- CUR=y
- else
- CUR=n
- fi
- echo -n "Load O2CB driver on boot (y/n) [$CUR]: "
- read LINE
- case "$LINE" in
- "")
- break
- ;;
- y|Y)
- O2CB_ENABLED=true
- break
- ;;
- n|N)
- O2CB_ENABLED=false
- break
- ;;
- *)
- echo "Invalid answer: $LINE" >&2
- ;;
- esac
- done
-
- while :
- do
- echo -n "Cluster to start on boot (Enter \"none\" to clear) [$O2CB_BOOTCLUSTER]: "
- read LINE
- case "$LINE" in
- "")
- break
- ;;
- none)
- O2CB_BOOTCLUSTER=
- break
- ;;
-
- *[^a-zA-Z0-9]*)
- echo "Invalid cluster name: $LINE" >&2
- ;;
- *)
- O2CB_BOOTCLUSTER="$LINE"
- break
- ;;
- esac
- done
-
- # XXX ask about mount point base
-}
-
-
-#
-# make_dir()
-#
-# Create $1
-# Returns 0 on success, 1 on error, 2 if it already exists.
-#
-make_dir()
-{
- if [ "$#" -lt "1" -o -z "$1" ]
- then
- echo "make_dir(): Requires an argument" >&2
- return 1
- fi
- DIR="$1"
- if [ -e "$DIR" ]
- then
- if [ -d "$DIR" ]
- then
- return 2
- fi
- echo "make_dir(): File $DIR is not a directory" >&2
- return 1
- fi
-
- echo -n "Creating directory '$DIR': "
- mkdir -p "$DIR" 2>/dev/null
- if [ $? != 0 ]
- then
- echo "Unable to create directory '$DIR'" >&2
- return 1
- fi
- return 0
-}
-
-
#
# load_module()
# Load a module
#
-# 0 is success, 1 is error, 2 is already loaded
-#
load_module()
{
- if [ "$#" -lt "1" -o -z "$1" ]
- then
- echo "load_module(): Requires an argument" >&2
- return 1
- fi
- MODNAME="$1"
-
- MODOUT="`awk '$1 ~ /^'$MODNAME'$/{print $1;exit}' < /proc/modules 2>/dev/null`"
- if [ -n "$MODOUT" ]
- then
- return 2
- fi
-
- echo -n "Loading module \"$MODNAME\": "
- modprobe -s "$MODNAME"
- if [ "$?" != 0 ]
- then
- echo "Unable to load module \"$MODNAME\"" >&2
- return 1
- fi
-
- return 0
+ _modprobe single $1
}
#
@@ -286,19 +87,18 @@
#
check_heartbeat()
{
- if [ "$#" -lt "1" -o -z "$1" ]
- then
+ if [ "$#" -lt "1" -o -z "$1" ]; then
echo "check_heartbeat(): Requires an argument" >&2
return 1
fi
CLUSTER="$1"
RC=0
- if [ -d "$(configfs_path)/cluster/${CLUSTER}/heartbeat/" ]
+ if [ -d "/sys/kernel/config/cluster/${CLUSTER}/heartbeat/" ]
then
- ls -1 "$(configfs_path)/cluster/${CLUSTER}/heartbeat/" | while read HBUUID
+ ls -1 "/sys/kernel/config/cluster/${CLUSTER}/heartbeat/" | while read HBUUID
do
- if [ -d "$(configfs_path)/cluster/${CLUSTER}/heartbeat/${HBUUID}" ]
+ if [ -d "/sys/kernel/config/cluster/${CLUSTER}/heartbeat/${HBUUID}" ]
then
return 2;
fi
@@ -316,10 +116,8 @@
# clean_heartbeat()
# Removes the inactive heartbeat regions
#
-clean_heartbeat()
-{
- if [ "$#" -lt "1" -o -z "$1" ]
- then
+clean_heartbeat() {
+ if [ "$#" -lt "1" -o -z "$1" ]; then
echo "clean_heartbeat(): Requires an argument" >&2
return 1
fi
@@ -327,15 +125,15 @@
echo -n "Cleaning heartbeat on ${CLUSTER}: "
- if [ ! -d "$(configfs_path)/cluster/${CLUSTER}/heartbeat/" ]
+ if [ ! -d "/sys/kernel/config/cluster/${CLUSTER}/heartbeat/" ]
then
echo "OK"
return
fi
- ls -1 "$(configfs_path)/cluster/${CLUSTER}/heartbeat/" | while read HBUUID
+ ls -1 "/sys/kernel/config/cluster/${CLUSTER}/heartbeat/" | while read HBUUID
do
- if [ ! -d "$(configfs_path)/cluster/${CLUSTER}/heartbeat/${HBUUID}" ]
+ if [ ! -d "/sys/kernel/config/cluster/${CLUSTER}/heartbeat/${HBUUID}" ]
then
continue
fi
@@ -371,10 +169,8 @@
#
# 0 is success, 1 is error, 2 is not loaded
#
-unload_module()
-{
- if [ "$#" -lt "1" -o -z "$1" ]
- then
+unload_module() {
+ if [ "$#" -lt "1" -o -z "$1" ]; then
echo "unload_module(): Requires an argument" >&2
return 1
fi
@@ -397,10 +193,9 @@
;;
esac
- echo -n "Unloading module \"$MODNAME\": "
+ echo "Unloading module \"$MODNAME\": "
modprobe -rs "$MODNAME"
- if [ "$?" != 0 ]
- then
+ if [ "$?" != 0 ]; then
echo "Unable to unload module \"$MODNAME\"" >&2
return 1
fi
@@ -413,8 +208,7 @@
#
# 0 is not loaded, 1 is error, 2 is already loaded
#
-check_load_module()
-{
+check_load_module() {
if [ "$#" -lt "1" -o -z "$1" ]
then
echo "check_load_module(): Requires an argument" >&2
@@ -440,9 +234,8 @@
#
# 0 is success, 1 is error, 2 is already mounted
#
-mount_fs()
-{
- TYPE="$1"
+mount_fs() {
+ TYPE=$1
FULL_MOUNT="$2"
FULL_MOUNTSEARCH="`echo "$FULL_MOUNT" | sed -e 's/\//\\\\\//g'`"
MOUNTOUT="`awk '$2 ~ /^'$FULL_MOUNTSEARCH'$/{print $2; exit}' < /proc/mounts 2>/dev/null`"
@@ -452,20 +245,7 @@
return 2
fi
- # XXX some policy?
- if [ ! -e "$FULL_MOUNT" ]; then
- make_dir $FULL_MOUNT
- if_fail "$?"
- fi
-
- echo -n "Mounting ${TYPE} filesystem at $FULL_MOUNT: "
- mount -t ${TYPE} ${TYPE} $FULL_MOUNT
- if [ $? != 0 ]
- then
- echo "Unable to mount ${TYPE} filesystem" >&2
- return 1
- fi
-
+ run_cmd "Mounting ${TYPE} filesystems" mount -t ${TYPE} ${TYPE} $FULL_MOUNT
return 0
}
@@ -474,8 +254,7 @@
#
# 0 is not mounted, 1 is error, 2 is already mounted
#
-check_mount_fs()
-{
+check_mount_fs() {
TYPE="$1"
FULL_MOUNT="$2"
FULL_MOUNTSEARCH="`echo "$FULL_MOUNT" | sed -e 's/\//\\\\\//g'`"
@@ -497,10 +276,9 @@
#
# 0 is success, 1 is error, 2 is not mounted
#
-unmount_fs()
-{
- TYPE="$1"
- FULL_MOUNT="$2"
+unmount_fs() {
+ TYPE=$1
+ FULL_MOUNT=$2
FULL_MOUNTSEARCH="`echo "$FULL_MOUNT" | sed -e 's/\//\\\\\//g'`"
MOUNTOUT="`awk '$2 ~ /^'$FULL_MOUNTSEARCH'$/{print $2; exit}' < /proc/mounts 2>/dev/null`"
@@ -509,35 +287,23 @@
return 2
fi
- echo -n "Unmounting ${TYPE} filesystem: "
- umount $FULL_MOUNT
- if [ $? != 0 ]
- then
- echo "Unable to unmount ${TYPE} filesystem" >&2
- return 1
- fi
-
- return 0
+ run_cmd "Unmounting ${TYPE} filesystem" umount $FULL_MOUNT
}
-load()
-{
+load() {
for i in $(seq 0 $((${#LOAD_ACTIONS[*]} - 1)) ); do
eval ${LOAD_ACTIONS[i]}
- if_fail "$?"
done
}
-load_status()
-{
+load_status() {
for i in $(seq 0 $((${#LOAD_ACTIONS[*]} - 1)) ); do
eval "check_${LOAD_ACTIONS[i]}"
done
return "$?"
}
-online()
-{
+online() {
CLUSTER="${1:-${O2CB_BOOTCLUSTER}}"
if [ -z "$CLUSTER" ]
then
@@ -563,7 +329,7 @@
if [ $? = 0 ]
then
O2CB_HEARTBEAT_THRESHOLD_FILE_OLD=/proc/fs/ocfs2_nodemanager/hb_dead_threshold
- O2CB_HEARTBEAT_THRESHOLD_FILE=$(configfs_path)/cluster/${CLUSTER}/heartbeat/dead_threshold
+ O2CB_HEARTBEAT_THRESHOLD_FILE=/sys/kernel/config/cluster/${CLUSTER}/heartbeat/dead_threshold
if [ -n "$O2CB_HEARTBEAT_THRESHOLD" ]; then
if [ -f "$O2CB_HEARTBEAT_THRESHOLD_FILE" ]; then
echo "$O2CB_HEARTBEAT_THRESHOLD" > "$O2CB_HEARTBEAT_THRESHOLD_FILE"
@@ -591,8 +357,7 @@
#
# 0 is not online, 1 is error, 2 is online
#
-check_online()
-{
+check_online() {
if [ "$#" -lt "1" -o -z "$1" ]
then
echo "check_online(): Requires an argument" >&2
@@ -601,11 +366,11 @@
CLUSTER="$1"
RC=0
- if [ -d "$(configfs_path)/cluster/${CLUSTER}/node/" ]
+ if [ -d "/sys/kernel/config/cluster/${CLUSTER}/node/" ]
then
- ls -1 "$(configfs_path)/cluster/${CLUSTER}/node/" | while read NODE
+ ls -1 "/sys/kernel/config/cluster/${CLUSTER}/node/" | while read NODE
do
- LOCAL="`cat \"$(configfs_path)/cluster/${CLUSTER}/node/${NODE}/local\"`"
+ LOCAL="`cat \"/sys/kernel/config/cluster/${CLUSTER}/node/${NODE}/local\"`"
if [ $LOCAL = 1 ]
then
return 2
@@ -619,15 +384,14 @@
return $RC
}
-offline()
-{
+offline() {
CLUSTER="${1:-${O2CB_BOOTCLUSTER}}"
if [ -z "$CLUSTER" ]
then
return
fi
- if [ ! -e "$(configfs_path)/cluster/${CLUSTER}" ]
+ if [ ! -e "/sys/kernel/config/cluster/${CLUSTER}" ]
then
return
fi
@@ -649,8 +413,7 @@
if_fail "$?"
}
-start()
-{
+start() {
if [ "$O2CB_ENABLED" != "true" ]
then
exit 0
@@ -660,11 +423,9 @@
online "$1"
}
-unload()
-{
- if [ -d "$(configfs_path)/cluster/" ]
- then
- ls -1 $(configfs_path)/cluster/ | while read CLUSTER
+unload() {
+ if [ -d /sys/kernel/config/cluster/ ]; then
+ ls -1 /sys/kernel/config/cluster/ | while read CLUSTER
do
echo "Unable to unload modules as Cluster ${CLUSTER} is still online" >&2
exit 1
@@ -677,25 +438,15 @@
for i in $(seq $((${#LOAD_ACTIONS[*]} - 1)) -1 0); do
eval "un${LOAD_ACTIONS[i]}"
- if_fail "$?"
done
}
-stop()
-{
+stop() {
offline "$1"
unload
}
-configure()
-{
- configure_ask
- write_sysconfig
- if_fail "$?" "Unable to write the driver configuration"
-}
-
-status()
-{
+status() {
load_status
if [ $? != 2 ]
then
@@ -816,33 +567,9 @@
unload
;;
- configure)
- configure
- if [ "$O2CB_ENABLED" = "true" ]
- then
- start
- else
- stop
- fi
- ;;
-
- enable)
- O2CB_ENABLED=true
- write_sysconfig
- if_fail "$?" "Unable to write the driver configuration"
- start
- ;;
-
- disable)
- O2CB_ENABLED=false
- write_sysconfig
- if_fail "$?" "Unable to write the driver configuration"
- stop
- ;;
-
*)
- echo "Usage: $0 {start|stop|restart|force-reload|enable|disable|configure|load|unload|online|offline|status}"
- exit 1
+ msg_usage "$0 {start|stop|restart|force-reload|load|unload|online|offline|status}"
+ exit 3
;;
esac
================================================================
Index: SOURCES/ocfs2.init
diff -u SOURCES/ocfs2.init:1.1 SOURCES/ocfs2.init:1.2
--- SOURCES/ocfs2.init:1.1 Tue Oct 17 02:25:59 2006
+++ SOURCES/ocfs2.init Sat Mar 31 12:32:32 2007
@@ -1,94 +1,41 @@
-#! /bin/bash
+#!/bin/sh
# Copyright (c) 2005 Oracle
# All rights reserved.
<<Diff was trimmed, longer than 597 lines>>
---- CVS-web:
http://cvs.pld-linux.org/SOURCES/o2cb.init?r1=1.1&r2=1.2&f=u
http://cvs.pld-linux.org/SOURCES/ocfs2.init?r1=1.1&r2=1.2&f=u
More information about the pld-cvs-commit
mailing list