[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: interfaces und mapping script



Jörg Schütter <joerg@schuetter.org> wrote:
> Hallo,
>
> ich habe für die Konfiguration meiner Netzwerkkarte ein
> Mapping-Script geschrieben. Allerdings bin ich mit dem Ergebnis
> nicht zufrieden. Da man wohl dem Script keine Parameter übergeben
> kann,

Doch. Schau dir mal man interfaces an. Da ist gleich zu Anfang ein
Beispiel gemacht.

> --- cut /etc/network/interfaces ---
> mapping eth0
>     script /usr/local/bin/map-scheme
>     # dhcp_normal dhcp_company dmz fixed1 fixed2 home home_wlan


s/#/map/

> Hier mal das komplette Script
> --- cut ---
> #!/bin/bash

s/ba//

> interfaces=/etc/network/interfaces
> dialogfile=/tmp/dialog.$$

dialogfile=$(mktemp)

> last_selection_file=/etc/network/.last-selection

nicht nach /etc schreiben!
http://panopticon.csustan.edu/thood/readonly-root.html

> timeout=30
> width=70

mithilfe von $COLUMNS bzw. stty -a |grep columns bzw. dialog
--print-maxsize

> items=`grep -E "[[:space:]]script[[:space:]]{1,}$0[[:space:]]*$" -m 1 -A 1 $interfaces | tail -n 1 | cut -d "#" -f 2-`

Das könnte ein sed sein.

> itemcount=`echo "$items" | wc -w`
> height=$((itemcount + 6))

analog width

> [ $height -gt 21 ] && height=21
> preselect=`cat $last_selection_file 2> /dev/null`
>
> echo "$items" | grep -q "\b$preselect\b"
> if [ $? -eq 0 ]; then

if echo "$items" | grep -q "\b$preselect\b"; then

>     echo "--timeout $timeout --stdout --no-cancel \
>         --radiolist \"Select interface config (timeout = $timeout seconds)\" \
>         $height $width $itemcount " > $dialogfile
> else
>     echo "--stdout --no-cancel \
>         --radiolist \"Select interface config\" \
>         $height $width $itemcount " > $dialogfile
> fi
>
> for c in $items; do
>     comment=`grep "^iface $c inet" -m 1 -A 1 $interfaces | tail -n 1 | cut -d "#" -f 2- | sed -e 's/^ *//g'`

das könnte ein sed sein.

>     /bin/grep -q "^$c$" $last_selection_file > /dev/null 2>&1

grep -q hat keine Ausgabe. Es gibt nix zum Umleiten.

>     if [ $? -eq 0 ]; then

if grep ...;then

>         echo $c \"$comment\" on >> $dialogfile
>     else
>         echo $c \"$comment\" off >> $dialogfile
>     fi
> done
>
> result=`/usr/bin/dialog --file $dialogfile 2> /dev/null`
>
> result=`echo $result | sed -e 's/^"//' | sed -e 's/"$//'`

sed -e 's/^"//' -e 's/"$//'

Schöne Nacht noch, Jörg.

-- 
Was der Bauer nicht kennt, das frißt er nicht. Würde der Städter kennen,
was er frißt, er würde umgehend Bauer werden.
                                                       Oliver Hassencamp



Reply to: