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

Re: [MiNT] boot script



On Mon, 13 May 2013 19:38:14 , "Helmut Karlowski" <helmut.karlowski@ish.de> wrote:
> Peter Slegg, 13.05.2013 19:20:14:
>
> >
> > Can someone tell me why this sh script doesn't behave how
> > I expect it to when the partition doesn't exist ?
> >
> >
> >     for drv in $ext2drives; do
> >         echo; echo "Checking filesystem on drive $drv."
> >         fsck.ext2 -p -C - $drv:
> >         if [ $? -ge 2 ]; then
> >             echo
> >             echo "Warning: e2fsck FAILED ($?)"
> >
> >
> > What I see is:
> >
> >     Warning: e2fsck FAILED (0)
> >
> > Shouldn't the $? -ge 2 mean that the error numbers below 2
> > are not shown ?
>
> Try that:
>
>         for drv in $ext2drives; do
>             echo; echo "Checking filesystem on drive $drv."
>             fsck.ext2 -p -C - $drv:
>             if [ $? -ge 2 ]; then
>          r=$?
>                 echo
>                 echo "Warning: e2fsck FAILED ($r)"
>
> The $? is updated by echo. Also fi and done are missing, but I guess you
> didn't post the complete script.
>
>

Thanks Helmut, that pointed me in the right direction.

    for drv in $ext2drives; do
        echo; echo "Checking filesystem on drive $drv."
        fsck.ext2 -p -C - $drv:
        r=$?
        if [ $r -ge 2 ]; then
            echo
            echo "Warning: e2fsck FAILED ($r)"
            echo "         Starting single user shell. Fix the"
            echo "         filesystem on drive $drv by running fsck.ext2"
            echo "         and REBOOT!"
            echo
            sh -si < /dev/console > /dev/console 2>&1
        fi
    done

This returns an error 8 when the partition doesn't exist.

Regards,

Peter