Mailing List Archive

PATCH for datadisk and drbd_common
List,

Here's a patch to illustrate what I described in the previous post.
Please note that while I tested each addition separately (in isolated shell
scripts), I havn't tested them with a drbd system.
This patch should apply to Rev 1.32 and can be applied by:

cd /path/to/drbdCVS/scripts
patch -p0 < /path/to/datadisk-drbd.patch

Best Regards,
Omar Kilani
Re: PATCH for datadisk and drbd_common [ In reply to ]
> List,
>
> Here's a patch to illustrate what I described in the previous post.
> Please note that while I tested each addition separately (in isolated
shell
> scripts), I havn't tested them with a drbd system.
> This patch should apply to Rev 1.32 and can be applied by:
>
> cd /path/to/drbdCVS/scripts
> patch -p0 < /path/to/datadisk-drbd.patch
>
> Best Regards,
> Omar Kilani

Index: datadisk
===================================================================

# See how we were called.
-case "$ACTION" in
+case "$OPTION" in

was already fixed ..

+
+ getSafe $RESOURCE
+

move the setLocal call to this position must fix the bug ..

+ read -p "Do you want to continue or reboot [C/R] " ACTION
+ ACTION=`echo $ACTION | cut -c1`

Ok, removed the -r 1 ....
Can't see why the second line

- rm $STATE/"$RESOURCE"_safe 2> /dev/null
+ rm -f $STATE/"$RESOURCE"_safe

is now
rm -f $STATE/"$RESOURCE"_safe 2> /dev/null

- rm $STATE/"$RESOURCE"_safe 2> /dev/null
+ rm -f $STATE/"$RESOURCE"_safe

idem

restart)
- $0 stop
- $0 start
+ $0 $RESOURCE stop
+ $0 $RESOURCE start

Ok .. ;*)

===================================================================
RCS file: /cvshome/drbd/drbd/scripts/drbd_common,v
retrieving revision 1.2
diff -u -r1.2 drbd_common
--- drbd_common 2000/12/01 09:31:41 1.2
+++ drbd_common 2000/12/01 12:01:37
@@ -308,6 +308,14 @@
done
}

+# Check wether SAFE is enabled for this drbd device
+# Paramaters:
+# DRBD Device
+getSafe()
+{
+ SAFE=`grep GLOBAL_SAFE $CONFIG/$1 | cut -f2 -d'='`
+}

Not usefull

-have_env SAFE $SAFE

Still here ...

if [ "$2" != "" ]; then
- OPTION=$1
- RESOURCE=$2
+ OPTION=$2
+ RESOURCE=$1
else
- OPTION=$1
- RESOURCE=""
+ failed "Usage: $0 [resource] {start|stop|restart|status}"
fi

Not changed .. Can't understand why the else is wrong.

Thomas
Re: PATCH for datadisk and drbd_common [ In reply to ]
At 09:37 AM 4/12/2000 +0000, Thomas Mangin wrote:
> > List,
> >
> > Here's a patch to illustrate what I described in the previous post.
> > Please note that while I tested each addition separately (in isolated
>shell
> > scripts), I havn't tested them with a drbd system.
> > This patch should apply to Rev 1.32 and can be applied by:
> >
> > cd /path/to/drbdCVS/scripts
> > patch -p0 < /path/to/datadisk-drbd.patch
> >
> > Best Regards,
> > Omar Kilani
>
>Index: datadisk
>===================================================================
>
> # See how we were called.
>-case "$ACTION" in
>+case "$OPTION" in
>
>was already fixed ..

I sent the patch to the list before it was fixed.
It took the patch ~24 hours to appear on the list :-)

>+
>+ getSafe $RESOURCE
>+
>
>move the setLocal call to this position must fix the bug ..

I still don't know where SAFE is coming from.
That's why I added this code.
Is SAFE supposed to be a pre-defined environment variable?
Or is it being sources/parsed from somewhere?

>+ read -p "Do you want to continue or reboot [C/R] " ACTION
>+ ACTION=`echo $ACTION | cut -c1`
>
>Ok, removed the -r 1 ....
>Can't see why the second line

To make sure the input is only one character.

>- rm $STATE/"$RESOURCE"_safe 2> /dev/null
>+ rm -f $STATE/"$RESOURCE"_safe
>
>is now
>rm -f $STATE/"$RESOURCE"_safe 2> /dev/null

The -f gets rid of the need for the redirection to /dev/null.

>- rm $STATE/"$RESOURCE"_safe 2> /dev/null
>+ rm -f $STATE/"$RESOURCE"_safe
>
>idem

ditto ;-)

> restart)
>- $0 stop
>- $0 start
>+ $0 $RESOURCE stop
>+ $0 $RESOURCE start
>
>Ok .. ;*)

WOOHOO! :-)

>===================================================================
>RCS file: /cvshome/drbd/drbd/scripts/drbd_common,v
>retrieving revision 1.2
>diff -u -r1.2 drbd_common
>--- drbd_common 2000/12/01 09:31:41 1.2
>+++ drbd_common 2000/12/01 12:01:37
>@@ -308,6 +308,14 @@
> done
> }
>
>+# Check wether SAFE is enabled for this drbd device
>+# Paramaters:
>+# DRBD Device
>+getSafe()
>+{
>+ SAFE=`grep GLOBAL_SAFE $CONFIG/$1 | cut -f2 -d'='`
>+}
>
>Not usefull
>
>-have_env SAFE $SAFE
>Still here ...

Once again, what's the point of the GLOBAL_SAFE definition in each
/etc/sysconfig/drbd/drbdX file if that's not what's being used to tell
wether the user wants SAFE for that particular DRBD device?

Where is SAFE coming from?!

> if [ "$2" != "" ]; then
>- OPTION=$1
>- RESOURCE=$2
>+ OPTION=$2
>+ RESOURCE=$1
> else
>- OPTION=$1
>- RESOURCE=""
>+ failed "Usage: $0 [resource] {start|stop|restart|status}"
> fi
>
>Not changed .. Can't understand why the else is wrong.

You already fixed this before.
Patch arrived too late :-)

>Thomas

Omar Kilani
Re: PATCH for datadisk and drbd_common [ In reply to ]
Thomas Mangin wrote:

>
>
> move the setLocal call to this position must fix the bug ..
>
> + read -p "Do you want to continue or reboot [C/R] " ACTION
> + ACTION=`echo $ACTION | cut -c1`
>
> Ok, removed the -r 1 ....

Sorry, but there is no option -p for read under RedHat 6.2 with bash
1.14.7
This is excerpt from bash man:

read [-r] [name ...]
One line is read from the standard input, and the
first word is assigned to the first name, the sec?
ond word to the second name, and so on, with left?
over words assigned to the last name. Only the
characters in IFS are recognized as word delim?
iters. If no names are supplied, the line read is
assigned to the variable REPLY. The return code is
zero, unless end-of-file is encountered. If the -r
option is given, a backslash-newline pair is not
ignored, and the backslash is considered to be part
of the line.
Re: PATCH for datadisk and drbd_common [ In reply to ]
Dim,

At 10:55 AM 4/12/2000 +0100, Dim Segebart wrote:
>Thomas Mangin wrote:
>
> >
> >
> > move the setLocal call to this position must fix the bug ..
> >
> > + read -p "Do you want to continue or reboot [C/R] " ACTION
> > + ACTION=`echo $ACTION | cut -c1`
> >
> > Ok, removed the -r 1 ....
>
>Sorry, but there is no option -p for read under RedHat 6.2 with bash
>1.14.7


- read -p "Do you want to continue or reboot [C/R] " ACTION
+ echo -n "Do you want to continue or reboot [C/R] "
+ read ACTION

RH6.2 compatible ? :-)

>This is excerpt from bash man:
>
>read [-r] [name ...]
> One line is read from the standard input, and the
> first word is assigned to the first name, the sec?
> ond word to the second name, and so on, with left?
> over words assigned to the last name. Only the
> characters in IFS are recognized as word delim?
> iters. If no names are supplied, the line read is
> assigned to the variable REPLY. The return code is
> zero, unless end-of-file is encountered. If the -r
> option is given, a backslash-newline pair is not
> ignored, and the backslash is considered to be part
> of the line.
>
>
>_______________________________________________
>DRBD-devel mailing list
>DRBD-devel@example.com
>http://lists.sourceforge.net/mailman/listinfo/drbd-devel
Re: PATCH for datadisk and drbd_common [ In reply to ]
> - read -p "Do you want to continue or reboot [C/R] " ACTION
> + echo -n "Do you want to continue or reboot [C/R] "
> + read ACTION
>
> RH6.2 compatible ? :-)

Yes it would be if I was using bash2 as shell in the #! line.
But in order to only rely on sh and bash one I used
echo -n "stuff "
read ACTION

EOT