ifup/down broken!!!

David Henderson dhenderson at digital-pipe.com
Wed Sep 28 12:46:52 UTC 2016


Good morning Denys, thanks for your input!  Yes, once the script had
an 'exit 0' appended to it, ifup/down began to work correctly.
However, as noted, it appears that the script was having an 'exit 1'
even though it was going through all the lines and should have been
exiting 0.  Once one of the lines further up in the script was
commented out, it would exit correctly.  For some reason the script
wasn't giving an 'exit 0' by running all the way through - as it
should be doing.

Dave


On 9/27/16, Denys Vlasenko <vda.linux at googlemail.com> wrote:
> On Tue, Sep 27, 2016 at 2:44 PM, David Henderson
> <dhenderson at digital-pipe.com> wrote:
>> On 9/27/16, dietmar.schindler at manroland-web.com
>> <dietmar.schindler at manroland-web.com> wrote:
>>>> Von: David Henderson
>>>> Gesendet: Montag, 26. September 2016 17:04
>>>>
>>>> ...  The script is as follows:
>>>>
>>>> #!/bin/sh
>>>> #
>>>> # DEBUG
>>>> echo 'resolv.conf' > /tmp/debug.ifup
>>>> env >> /tmp/debug.ifup
>>>>
>>>> # everything below this point was added recently
>>>> CONFIG=''
>>>>
>>>> # this segment was what was causing an exit 1
>>>> [ -e '/etc/network/interfaces' ] && ( echo "$IFACE" | grep -q ':' ) &&
>>>> {
>>>>         [ "$IF_DNS_DOMAIN" ] && CONFIG="${CONFIG}domain
>>>> ${IF_DNS_DOMAIN}\n"
>>>>         [ "$IF_DNS_SEARCH" ] && CONFIG="${CONFIG}search
>>>> ${IF_DNS_SEARCH}\n"
>>>>         [ "$IF_DNS_SORTLIST" ] && CONFIG="${CONFIG}sortlist
>>>> ${IF_DNS_SORTLIST}\n"
>>>>         for NS in $IF_DNS_NAMESERVER $IF_DNS_NAMESERVERS; do
>>>>                 CONFIG="${CONFIG}nameserver $NS\n"
>>>>         done
>>>> }
>>>> [ "$CONFIG" != '' ] && echo -e "$CONFIG" > /etc/resolv.conf
>>>>
>>>>
>>>> The "[ -e '/etc/network/interfaces' ] && ..." section was the part
>>>> that appears to be causing the 'exit 1' status - most likely from the
>>>> 'grep -q ':'' call.  Does this indicate an issue with /bin/sh as the
>>>> normal exit value of the script should be 0?  It appears that the
>>>> 'grep' call is returning a false response that is being retained and
>>>> causing the 'exit 1' status of the script even though the script
>>>> continues to process until the end (which should be an exit 0 now
>>>> right?)...
>>>
>>> Why does it appear to you that the next-to-last command dictates the
>>> script's exit status? That is implausible. In fact, the last command's
>>> exit
>>> status is also the script's exit status, so most probably the test [
>>> "$CONFIG" != '' ] returns 1 (false) because $CONFIG is empty.
>>> --
>>> Regards,
>>> Dietmar Schindler
>>
>> Good morning Dietmar, thanks for the reply to this.  The reason I
>> believe that is because I commented out the "[ 'CONFIG' != '' ]" line
>> and nothing changed.  I then commented out the next block above it,
>> which did stop the 'exit 1' status from 'ifup'.  I find it wierd that
>> that was the case too, but it was.
>
> Thus, the reason for ifup not working for you was
> /etc/network/if-up.d/000_dns-nameservers
> exiting with nonzero exit code, i.e. it was signaling a failure to ifup,
> which in turn was deciding that "upping eth0 failed",
> and wasn't writing /var/run/ifstate.
>
> Your strace output shows that when that problem is resolved,
> /var/run/ifstate is successfully updated:
>
> 18287 19:38:45.666707 open("/var/run/ifstate", O_RDONLY|O_LARGEFILE) = 3
> 18287 19:38:45.666769 fstat64(3, {st_mode=S_IFREG|0664, st_size=0, ...}) =
> 0
> 18287 19:38:45.666908 read(3, "", 4096) = 0
> 18287 19:38:45.666957 close(3)          = 0
> 18287 19:38:45.667059 open("/var/run/ifstate",
> O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 3
> 18287 19:38:45.667132 fstat64(3, {st_mode=S_IFREG|0664, st_size=0, ...}) =
> 0
> 18287 19:38:45.667261 write(3, "eth0=eth0\n", 10) = 10
> 18287 19:38:45.667319 close(3)          = 0
>


More information about the busybox mailing list