[Ocfs2-tools-commits] jlbec commits r520 - trunk/vendor/common
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Wed Dec 29 13:22:34 CST 2004
Author: jlbec
Date: 2004-12-29 13:22:32 -0600 (Wed, 29 Dec 2004)
New Revision: 520
Modified:
trunk/vendor/common/o2cb.init
Log:
o More command options
Modified: trunk/vendor/common/o2cb.init
===================================================================
--- trunk/vendor/common/o2cb.init 2004-12-29 18:41:23 UTC (rev 519)
+++ trunk/vendor/common/o2cb.init 2004-12-29 19:22:32 UTC (rev 520)
@@ -74,6 +74,107 @@
#
+# write_sysconfig()
+#
+# Writes the system configuration out
+#
+write_sysconfig()
+{
+ echo -n "Writing O2CB configuration: "
+ cat >/etc/sysconfig/o2cb <<EOF
+#
+# This is a configuration file for automatic startup of the O2CB
+# driver. It is generated by running /etc/init.d/oracleasm 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}
+
+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
+}
+
+
+#
# dev_create()
#
# Create $1
@@ -97,7 +198,7 @@
return 1
fi
- echo -n "Creating $DEV mount point "
+ echo -n "Creating $DEV mount point: "
mkdir "$DEV" 2>/dev/null
if [ $? != 0 ]
then
@@ -129,7 +230,7 @@
return 2
fi
- echo -n "Loading module \"$MODNAME\" "
+ echo -n "Loading module \"$MODNAME\": "
modprobe -s "$MODNAME"
if [ "$?" != 0 ]
then
@@ -173,7 +274,7 @@
;;
esac
- echo -n "Unloading module \"$MODNAME\" "
+ echo -n "Unloading module \"$MODNAME\": "
modprobe -rs "$MODNAME"
if [ "$?" != 0 ]
then
@@ -209,7 +310,7 @@
return 2
fi
- echo -n "Mounting ${TYPE} driver filesystem "
+ echo -n "Mounting ${TYPE} driver filesystem: "
mount $OPTS -t ${TYPE} ${TYPE} $FULL_MOUNT
if [ $? != 0 ]
then
@@ -245,7 +346,7 @@
return 2
fi
- echo -n "Unmounting ${TYPE} driver filesystem "
+ echo -n "Unmounting ${TYPE} driver filesystem: "
umount $FULL_MOUNT
if [ $? != 0 ]
then
@@ -278,7 +379,11 @@
online()
{
- CLUSTER="$1"
+ CLUSTER="${1:-${O2CB_BOOTCLUSTER}}"
+ if [ -z "$CLUSTER" ]
+ then
+ return
+ fi
#
# FIXME FIXME FIXME
@@ -291,6 +396,12 @@
if_fail "$?" "$OUTPUT"
}
+start()
+{
+ load
+ online "$2"
+}
+
unload()
{
# Reverse list for unloading
@@ -322,6 +433,18 @@
done
}
+stop()
+{
+ unload
+}
+
+configure()
+{
+ configure_ask
+ write_sysconfig
+ if_fail "$?" "Unable to write the driver configuration"
+}
+
status()
{
echo -n "Checking if O2CB is loaded: "
@@ -371,11 +494,7 @@
case "$1" in
start)
- load
- if [ -n "$2" ]
- then
- online "$2"
- fi
+ start
;;
status)
@@ -383,7 +502,7 @@
;;
stop)
- unload
+ stop
;;
restart)
@@ -406,6 +525,31 @@
unload)
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|enable|disable|load|unload|status}"
exit 1
More information about the Ocfs2-tools-commits
mailing list