using bash features in init scripts

2003-09-28 Thread Manoj Kumar
Is there any reason not to use bash features in init
scripts?
Consider, for example, this fragment from
/etc/sysconfig/network-scripts/ifup-post:

DEVICETYPE=`echo $DEVICE | sed s/[0-9]*$//`
REALDEVICE=`echo $DEVICE | sed 's/:.*//g'`
if echo $DEVICE | grep -q ':' ; then
ISALIAS=yes
else
ISALIAS=no
fi

In bash we can do this much faster with something like
this:

DEVICETYPE=$DEVICE
while [[ $DEVICETYPE == *[0-9] ]]; do
DEVICETYPE=${DEVICETYPE%[0-9]}
done
REALDEVICE=${DEVICE%%:*}
if [[ $DEVICE == *:* ]]; then
ISALIAS=yes
else
ISALIAS=no
fi

Okay, the loop that replaces the first line is messy,
but it saves
a couple of forks and an exec.  The other two changes
are both
simpler and faster.

So why do most init scripts use sed and grep to
process
strings?  It can't be a desire to allow them to work
with the
Bourne shell (why would we want that anyway?) because
some
scripts do use bash features.

[EMAIL PROTECTED]



Yahoo! India Matrimony: Find your partner online.
Go to http://yahoo.shaadi.com


___
Redhat-devel-list mailing list
[EMAIL PROTECTED]
https://www.redhat.com/mailman/listinfo/redhat-devel-list


Re: using bash features in init scripts

2003-09-28 Thread Steven W. Orr
On Sunday, Sep 28th 2003 at 14:31 +0100, quoth Manoj Kumar:

=Is there any reason not to use bash features in init
=scripts?
=Consider, for example, this fragment from
=/etc/sysconfig/network-scripts/ifup-post:
=
=DEVICETYPE=`echo $DEVICE | sed s/[0-9]*$//`
=REALDEVICE=`echo $DEVICE | sed 's/:.*//g'`
=if echo $DEVICE | grep -q ':' ; then
=ISALIAS=yes
=else
=ISALIAS=no
=fi
=
=In bash we can do this much faster with something like
=this:
=
=DEVICETYPE=$DEVICE
=while [[ $DEVICETYPE == *[0-9] ]]; do
=DEVICETYPE=${DEVICETYPE%[0-9]}
=done
=REALDEVICE=${DEVICE%%:*}
=if [[ $DEVICE == *:* ]]; then
=ISALIAS=yes
=else
=ISALIAS=no
=fi
=
=Okay, the loop that replaces the first line is messy, but it saves a
=couple of forks and an exec.  The other two changes are both simpler and
=faster.
=
=So why do most init scripts use sed and grep to process strings?  It
=can't be a desire to allow them to work with the Bourne shell (why would
=we want that anyway?) because some scripts do use bash features.

You have my blessing. 


-- 
-Time flies like the wind. Fruit flies like a banana. Stranger things have -
-happened but none stranger than this. Does your driver's license say Organ
-Donor?Black holes are where God divided by zero. Listen to me! We are all-
-individuals! What if this weren't a hypothetical question?
steveo at syslang.net


___
Redhat-devel-list mailing list
[EMAIL PROTECTED]
https://www.redhat.com/mailman/listinfo/redhat-devel-list


Re: using bash features in init scripts

2003-09-28 Thread Jonathan Bartlett
The reason that normal startup scripts don't, is that there's no guarantee
/bin/sh will point to bash, or even that bash is installed.

If you want to use bash, the first line should be /bin/bash instead of
/bin/sh, so it's obvious it needs bash specifically.

Jon

On Sun, 28 Sep 2003, [iso-8859-1] Manoj Kumar wrote:

 Is there any reason not to use bash features in init
 scripts?
 Consider, for example, this fragment from
 /etc/sysconfig/network-scripts/ifup-post:

 DEVICETYPE=`echo $DEVICE | sed s/[0-9]*$//`
 REALDEVICE=`echo $DEVICE | sed 's/:.*//g'`
 if echo $DEVICE | grep -q ':' ; then
 ISALIAS=yes
 else
 ISALIAS=no
 fi

 In bash we can do this much faster with something like
 this:

 DEVICETYPE=$DEVICE
 while [[ $DEVICETYPE == *[0-9] ]]; do
 DEVICETYPE=${DEVICETYPE%[0-9]}
 done
 REALDEVICE=${DEVICE%%:*}
 if [[ $DEVICE == *:* ]]; then
 ISALIAS=yes
 else
 ISALIAS=no
 fi

 Okay, the loop that replaces the first line is messy,
 but it saves
 a couple of forks and an exec.  The other two changes
 are both
 simpler and faster.

 So why do most init scripts use sed and grep to
 process
 strings?  It can't be a desire to allow them to work
 with the
 Bourne shell (why would we want that anyway?) because
 some
 scripts do use bash features.

 [EMAIL PROTECTED]


 
 Yahoo! India Matrimony: Find your partner online.
 Go to http://yahoo.shaadi.com


 ___
 Redhat-devel-list mailing list
 [EMAIL PROTECTED]
 https://www.redhat.com/mailman/listinfo/redhat-devel-list



___
Redhat-devel-list mailing list
[EMAIL PROTECTED]
https://www.redhat.com/mailman/listinfo/redhat-devel-list


Re: using bash features in init scripts

2003-09-28 Thread Vilius Puidokas

also you would wanna add requires: bash for initscripts rpm.

not sure how portable initscripts package was designed to be, would anyone
ever use it outside redhat? if not making a commitment to bash could be
reasonable.

just my .02
v

On Sun, 28 Sep 2003, Jonathan Bartlett wrote:

 The reason that normal startup scripts don't, is that there's no guarantee
 /bin/sh will point to bash, or even that bash is installed.
 
 If you want to use bash, the first line should be /bin/bash instead of
 /bin/sh, so it's obvious it needs bash specifically.
 
 Jon
 
 On Sun, 28 Sep 2003, [iso-8859-1] Manoj Kumar wrote:
 
  Is there any reason not to use bash features in init
  scripts?
  Consider, for example, this fragment from
  /etc/sysconfig/network-scripts/ifup-post:
 
  DEVICETYPE=`echo $DEVICE | sed s/[0-9]*$//`
  REALDEVICE=`echo $DEVICE | sed 's/:.*//g'`
  if echo $DEVICE | grep -q ':' ; then
  ISALIAS=yes
  else
  ISALIAS=no
  fi
 
  In bash we can do this much faster with something like
  this:
 
  DEVICETYPE=$DEVICE
  while [[ $DEVICETYPE == *[0-9] ]]; do
  DEVICETYPE=${DEVICETYPE%[0-9]}
  done
  REALDEVICE=${DEVICE%%:*}
  if [[ $DEVICE == *:* ]]; then
  ISALIAS=yes
  else
  ISALIAS=no
  fi
 
  Okay, the loop that replaces the first line is messy,
  but it saves
  a couple of forks and an exec.  The other two changes
  are both
  simpler and faster.
 
  So why do most init scripts use sed and grep to
  process
  strings?  It can't be a desire to allow them to work
  with the
  Bourne shell (why would we want that anyway?) because
  some
  scripts do use bash features.
 
  [EMAIL PROTECTED]
 
 
  
  Yahoo! India Matrimony: Find your partner online.
  Go to http://yahoo.shaadi.com
 
 
  ___
  Redhat-devel-list mailing list
  [EMAIL PROTECTED]
  https://www.redhat.com/mailman/listinfo/redhat-devel-list
 
 
 
 ___
 Redhat-devel-list mailing list
 [EMAIL PROTECTED]
 https://www.redhat.com/mailman/listinfo/redhat-devel-list
 


___
Redhat-devel-list mailing list
[EMAIL PROTECTED]
https://www.redhat.com/mailman/listinfo/redhat-devel-list


FW: Automatic Reconstruction for RedHat partitions

2003-09-28 Thread Trevor
Hello,

A common problem is corrupt software.  This can be due to improper
shutdowns, careless administrators/developers, etc.  Many times hardware is
not to blame and reinstalling the OS is all that is needed.

I would like to use Parted to reconstruct several partions from image files
in the event that a server goes down and an administrator wants to restore
it back to factory condition.

I don't know if it is possible, but a I could write a howto that would be
ideal for many folks.

Below is a rough diagram of what I am talking about.  It very briefly
explains that in the event of a software meltdown, the admin could boot up
on a different boot partion and automatically run reconstuction tools
(parted):

http://www.gnuguy.com/linux/partedplan.gif

http://www.gnu.org/software/parted/

I know that many laptop makers (HP, Dell, etc.) use this to restore Win
partitions.  I'm pretty sure that the same can be done for linux ext3
partitions.

Has anybody done this before?  Anybody think about doing this at one time?
Give me your thoughts and feedback on this project.

Trevor.


___
Redhat-devel-list mailing list
[EMAIL PROTECTED]
https://www.redhat.com/mailman/listinfo/redhat-devel-list