Re: /etc/netstart diff

2012-02-20 Thread Markus
On Fri, 17  14:18 , Stuart Henderson wrote:
 I only see this as being marginally useful as-is. Why would you
 want to configure every network interface individually? You might
 as well just use a separate script in that case.

The use case is to have a default configuration of a wireless
interface, call it /etc/hostname.athn0.

Apart from that, there's a number of places where a different wifi
configuration is necessary, call them /etc/hostname.athn0.apX.

Being at one of these places, typing sh /etc/netstart athn0.apX 
suffices to have a working setup.

I can of course wrap nearly everything into some script, doing one 
and the same thing over and over again (or script the scripting). 
However avoiding additional overhead by applying a change once is 
just the idea of the patch.

But it doesn't really sound like this idea is attractive to
anyone.

 I'd rather have an option to specify this be used for *all*
 hostname.if files so you could sh /etc/netstart -s mobile etc.
 
 Or maybe easier to have netstart -d /etc/net/home etc to look in
 a different directory (though this has implications for /etc/security
 and changelist).
 
 With either of these, it would probably make sense to add netstart_flags
 support to rc.conf/rc as well.

The latter might be a proper solution as well, but is not as 
minimally invasive as intended.

All the best,
/Markus



Re: /etc/netstart diff

2012-02-20 Thread Brett
 Apart from that, there's a number of places where a different wifi
 configuration is necessary, call them /etc/hostname.athn0.apX.
 
 Being at one of these places, typing sh /etc/netstart athn0.apX 
 suffices to have a working setup.
 

Another way is to have a different command for each place you visit:

#! /bin/ksh
int=rum0
ifconfig $int down
ifconfig $int nwid id wpa wpakey password
sleep 2
dhclient $int

Then if you go to a new place, just copy the script, changing id and password, 
and instantly connect.



Re: /etc/netstart diff

2012-02-17 Thread Stuart Henderson
On 2012-02-16, Markus li...@neuronenwerk.de wrote:
 On Thu, 16  16:53 , Jan Stary wrote:
   What's the
   advantage over symlinking /etc/hostname.athn0 appropriately, if you want
   to use netstart?
  
  It's easier to issue a sh /etc/netstart athn0.home on the
  commandline than unlinking and relinking files before calling
  netstart. 
 
 So, you find it a reasonable price to have an unsupported /etc/netstart
 for not having to painstakingly type this?
 
 # ln -sf /etc/hostname.athn0.here /etc/hstanme.athn0
 # sh /etc/netstart

 Well, as you might have gathered by the fact that I sent a diff,
 I took into account that this small change could go into
 netstart to just support such operations out of the box.

 It's however not up to me to decide this. If the majority of
 relevant people do think this is bloat, I can get along with
 it. Consider it a suggestion. On the other hand, it would not 
 harm nor complicate netstart really.

I only see this as being marginally useful as-is. Why would you
want to configure every network interface individually? You might
as well just use a separate script in that case.

I'd rather have an option to specify this be used for *all*
hostname.if files so you could sh /etc/netstart -s mobile etc.

Or maybe easier to have netstart -d /etc/net/home etc to look in
a different directory (though this has implications for /etc/security
and changelist).

With either of these, it would probably make sense to add netstart_flags
support to rc.conf/rc as well.



/etc/netstart diff

2012-02-16 Thread Markus
Hi list,

occasionally I'm in the situation where having multiple
configurations for a single network interface are handy to have.

Admittedly, this doesn't affect servers as much as notebooks,
where using severals wifi nets/logins is the average case.

Most seamlessly, this could be handled by using an
arbitrary extension to the hostname.if files, separated by
and additional dot (e.g. hostname.athn0.home,
hostname.em0.bak20120223).
 
Below a diff to /etc/netstart is attached, that strips the
suffix including the dot from hostname.if.suffix (if it is 
present) and otherwise allows such files to be used. I tried 
to change the code of netstart as minimally as possible.

An interesting side-effect is the ease with which wifi cell
changes can now be handled by ifstated.

I'd suppose that this must scratch the itch of other users, too. 
However as this is only a rough guess, I'm curious to hear some
opinions on it.

All the best,
/Markus
--- /etc/netstart   Tue Dec 20 18:54:07 2011
+++ netstartThu Feb 16 11:15:14 2012
@@ -18,7 +18,7 @@
_n=$1
while [ ${#_n} != 0 ]; do
case $_n in
-   [A-Za-z0-9]*)   ;;
+   [A-Za-z0-9.]*)  ;;
*)  return 1;;
esac
_n=${_n#?}
@@ -26,6 +26,14 @@
return 0
 }
 
+# Strips everything from the first dot, if applicable
+raw() {
+   local_r
+   _r=$1
+   _r=${_r%%.*}
+   echo $_r
+}
+
 # Start the $1 interface
 ifstart() {
if=$1
@@ -47,9 +55,9 @@
chmod -LR o-rwx $file
chown -LR root.wheel $file
fi
-   if ! ifconfig $if  /dev/null 21; then
+   if ! ifconfig `raw $if`  /dev/null 21; then
# Try to create interface if it does not exist
-   if ! ifconfig $if create  /dev/null 21; then
+   if ! ifconfig `raw $if` create  /dev/null 21; then
return
fi
fi
@@ -83,13 +91,13 @@
[ $name = NONE ]  name=
[ $mask = NONE ]  mask=
[ $bcaddr = NONE ]  bcaddr=
-   cmd=ifconfig $if $name $mask $bcaddr $ext1 $ext2 down
-   cmd=$cmd;dhclient $if
-   dhcpif=$dhcpif $if
+   cmd=ifconfig `raw $if` $name $mask $bcaddr $ext1 $ext2 
down
+   cmd=$cmd;dhclient `raw $if`
+   dhcpif=$dhcpif `raw $if`
;;
rtsol)
-   rtsolif=$rtsolif $if
-   cmd=ifconfig $if $name $mask $bcaddr $ext1 $ext2 up
+   rtsolif=$rtsolif `raw $if`
+   cmd=ifconfig `raw $if` $name $mask $bcaddr $ext1 $ext2 
up
;;
*)
read dt dtaddr
@@ -104,7 +112,7 @@
else
alias=
fi
-   cmd=ifconfig $if $af $alias $name
+   cmd=ifconfig 4raw $if4 $af $alias $name
case $dt in
dest)
cmd=$cmd $dtaddr
@@ -149,7 +157,8 @@
 #   don't start $2 interfaces
 ifmstart() {
for sif in ${1:-ALL}; do
-   for hn in /etc/hostname.*; do
+   # Only loop over real interfaces
+   for hn in /etc/hostname.*([A-Za-z0-9]); do
# Strip off /etc/hostname. prefix
if=${hn#/etc/hostname.}
test $if = *  continue



Re: /etc/netstart diff

2012-02-16 Thread Joachim Schipper
On Thu, Feb 16, 2012 at 11:49:03AM +0100, Markus wrote:
 occasionally I'm in the situation where having multiple
 configurations for a single network interface are handy to have.

 Most seamlessly, [multiple wifi networks] could be handled by using an
 arbitrary extension to the hostname.if files, separated by and
 additional dot (e.g. hostname.athn0.home, hostname.em0.bak20120223).
  
 Below a diff to /etc/netstart is attached, that strips the
 suffix including the dot from hostname.if.suffix (if it is 
 present) and otherwise allows such files to be used. I tried 
 to change the code of netstart as minimally as possible.
 
 An interesting side-effect is the ease with which wifi cell
 changes can now be handled by ifstated.
 
 I'd suppose that this must scratch the itch of other users, too. 
 However as this is only a rough guess, I'm curious to hear some
 opinions on it.

I'm sorry, but how does this work? It reads as if netstart now
recognizes /etc/hostname.athn0.home as an alternative to
/etc/hostname.athn0, but how does it figure out whether to use
/etc/hostname.athn0.home or /etc/hostname.athn0.work? What's the
advantage over symlinking /etc/hostname.athn0 appropriately, if you want
to use netstart?

Maybe I just don't get it.

 @@ -104,7 +112,7 @@
   else
   alias=
   fi
 - cmd=ifconfig $if $af $alias $name
 + cmd=ifconfig 4raw $if4 $af $alias $name
  ^   ^
   case $dt in
   dest)
   cmd=$cmd $dtaddr


Those should be `, obviously.

Joachim

-- 
PotD: graphics/libkexiv2 - kde wrapper around exiv2
http://www.joachimschipper.nl/



Re: /etc/netstart diff

2012-02-16 Thread Markus
On Thu, 16  13:03 , Joachim Schipper wrote:
 
 I'm sorry, but how does this work? It reads as if netstart now
 recognizes /etc/hostname.athn0.home as an alternative to
 /etc/hostname.athn0, but how does it figure out whether to use
 /etc/hostname.athn0.home or /etc/hostname.athn0.work? 

The idea is to be able to issue sh /etc/netstart athn0.home
and start the interface in question with the configuration
preseent in /etc/hostname.athn0.home.

It does not find out anything by itself. Unless you call
netstart explicitly with those suffixed names, it will always take
hostname.athn0 by default. This way, this approach doesn't
interfere with the expected behaviour, yet provides a way to use
subconfigurations of interfaces in a convenient way.

 What's the
 advantage over symlinking /etc/hostname.athn0 appropriately, if you want
 to use netstart?

It's easier to issue a sh /etc/netstart athn0.home on the
commandline than unlinking and relinking files before calling
netstart. 

  @@ -104,7 +112,7 @@
  else
  alias=
  fi
  -   cmd=ifconfig $if $af $alias $name
  +   cmd=ifconfig 4raw $if4 $af $alias $name
   ^   ^
  case $dt in
  dest)
  cmd=$cmd $dtaddr
 
 
 Those should be `, obviously.

Interesting. That must have been wrapped up after I attached the 
diff. See the original at http://flash.target23.de/doc/netstart.diff

Regards,
/Markus



Re: /etc/netstart diff

2012-02-16 Thread Jan Stary
On Feb 16 15:16:51, Markus wrote:
 On Thu, 16  13:03 , Joachim Schipper wrote:
  
  I'm sorry, but how does this work? It reads as if netstart now
  recognizes /etc/hostname.athn0.home as an alternative to
  /etc/hostname.athn0, but how does it figure out whether to use
  /etc/hostname.athn0.home or /etc/hostname.athn0.work? 
 
 The idea is to be able to issue sh /etc/netstart athn0.home
 and start the interface in question with the configuration
 preseent in /etc/hostname.athn0.home.
 
 It does not find out anything by itself. Unless you call
 netstart explicitly with those suffixed names, it will always take
 hostname.athn0 by default. This way, this approach doesn't
 interfere with the expected behaviour, yet provides a way to use
 subconfigurations of interfaces in a convenient way.
 
  What's the
  advantage over symlinking /etc/hostname.athn0 appropriately, if you want
  to use netstart?
 
 It's easier to issue a sh /etc/netstart athn0.home on the
 commandline than unlinking and relinking files before calling
 netstart. 

So, you find it a reasonable price to have an unsupported /etc/netstart
for not having to painstakingly type this?

# ln -sf /etc/hostname.athn0.here /etc/hstanme.athn0
# sh /etc/netstart



   @@ -104,7 +112,7 @@
 else
 alias=
 fi
   - cmd=ifconfig $if $af $alias $name
   + cmd=ifconfig 4raw $if4 $af $alias $name
^   ^
 case $dt in
 dest)
 cmd=$cmd $dtaddr
  
  
  Those should be `, obviously.
 
 Interesting. That must have been wrapped up after I attached the 
 diff. See the original at http://flash.target23.de/doc/netstart.diff
 
 Regards,
 /Markus



Re: /etc/netstart diff

2012-02-16 Thread Markus
On Thu, 16  16:53 , Jan Stary wrote:
   What's the
   advantage over symlinking /etc/hostname.athn0 appropriately, if you want
   to use netstart?
  
  It's easier to issue a sh /etc/netstart athn0.home on the
  commandline than unlinking and relinking files before calling
  netstart. 
 
 So, you find it a reasonable price to have an unsupported /etc/netstart
 for not having to painstakingly type this?
 
 # ln -sf /etc/hostname.athn0.here /etc/hstanme.athn0
 # sh /etc/netstart

Well, as you might have gathered by the fact that I sent a diff,
I took into account that this small change could go into
netstart to just support such operations out of the box.

It's however not up to me to decide this. If the majority of
relevant people do think this is bloat, I can get along with
it. Consider it a suggestion. On the other hand, it would not 
harm nor complicate netstart really.

Regards,
/Markus