23
23
# SIGNAL-handler
24
24
term_handler () {
25
25
26
- # remove cifx0 interface from system
27
- killall cifx0deamon
28
- ip link delete cifx0
26
+ # remove cifx0 interface from system if created by the container
27
+ if ps -A | grep -q " cifx0daemon" ; then
28
+ killall cifx0deamon
29
+ ip link delete cifx0
30
+ fi
29
31
30
32
exit 143; # 128 + 15 -- SIGTERM
31
33
}
@@ -36,21 +38,26 @@ trap 'kill ${!}; term_handler' SIGINT SIGKILL SIGTERM SIGQUIT SIGTSTP SIGSTOP SI
36
38
# check presence of device spi0.0 and net device register
37
39
if [[ -e " /dev/spidev0.0" ]]&& [[ -e " /dev/net/tun" ]]; then
38
40
39
- echo " Provisioning 'cifx0' interface now."
40
41
41
- # pre-configure GPIO 24 to serve as interrupt pin between netX chip and BCM CPU
42
- if [[ ! -e " /sys/class/gpio/gpio24" ]]; then
43
- echo 24 > /sys/class/gpio/export
44
- fi
45
- echo rising > /sys/class/gpio/gpio24/edge
46
- echo in > /sys/class/gpio/gpio24/direction
47
- echo 1 > /sys/class/gpio/gpio24/active_low
42
+ # check if cifx0 interface is not running already
43
+ if ! ip addr show | grep -q " cifx0" ; then
44
+
45
+ echo " Provisioning 'cifx0' interface now."
48
46
49
- # create netx "cifx0" ethernet network interface
50
- /opt/cifx/cifx0daemon
47
+ # pre-configure GPIO 24 to serve as interrupt pin between netX chip and BCM CPU
48
+ if [[ ! -e " /sys/class/gpio/gpio24" ]]; then
49
+ echo 24 > /sys/class/gpio/export
50
+ fi
51
+ echo rising > /sys/class/gpio/gpio24/edge
52
+ echo in > /sys/class/gpio/gpio24/direction
53
+ echo 1 > /sys/class/gpio/gpio24/active_low
54
+
55
+ # create netx "cifx0" ethernet network interface
56
+ /opt/cifx/cifx0daemon
51
57
52
- # bring interface up now
53
- ip link set cifx0 up
58
+ # bring interface up now
59
+ ip link set cifx0 up
60
+ fi
54
61
55
62
else
56
63
echo " 'cifx0' interface cannot be provisioned."
0 commit comments