Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
udev tule that will run in the background
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
DaggyStyle
Watchman
Watchman


Joined: 22 Mar 2006
Posts: 5587

PostPosted: Wed Sep 16, 2020 11:48 am    Post subject: udev tule that will run in the background Reply with quote

Greetings,

I have an tap interface that takes a bit of time to init.
I have a udev rule that triggers the script that inits it, see:
Code:

 cat /etc/udev/rules.d/99-veth.rules
SUBSYSTEM=="net", ACTION=="add", KERNEL=="veth*", RUN+="/usr/local/bin/handle_tap start %k"
SUBSYSTEM=="net", ACTION=="remove", KERNEL=="veth*", RUN+="/usr/local/bin/handle_tap stop %k"


the script looks like this:
Code:

#!/bin/bash -x

exec 2>/tmp/err

action=$1
nic=$2

function start_nic {
        i=0
        while [ ${i} -lt 60 ]; do
                sleep 1s
                /lib/udev/net.sh net.sh ${nic} start

                ifconfig ${nic} | grep -q "inet "
                if [ $? -eq 0 ]; then
                        break
                fi

                /lib/udev/net.sh net.sh ${nic} stop
                i=$((i+1))
        done
}

if [ ${action} != "start" -a ${action} != "stop" ]; then
        echo "Error: unsupported action ${action}"
        exit 1
fi

/lib/udev/net.sh net.sh ${nic} stop

if [ ${action} = "start" ]; then
        start_nic &
fi

exit 0


I've expected it to work, because from the start of the int of the tap and up until it can provide link less than one sec happens.
so I assume I'm doing something wrong.
so what is the proper way to spawn a process from udev call that will continue run in the background of the boot?
_________________
Only two things are infinite, the universe and human stupidity and I'm not sure about the former - Albert Einstein
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum