aboutsummaryrefslogtreecommitdiffstats
path: root/packages/pre-remove
blob: c565148d29c9628e7c6203c029638467e0dd60d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/sh -e

killall -v -s 9 nginx | true
service vpp stop

removed=

# Unbind user-mode PCI drivers
pci_dirs=`find /sys/bus/pci/drivers -type d -name igb_uio -o -name uio_pci_generic -o -name vfio-pci`
for d in $pci_dirs; do
    for f in ${d}/*; do
        [ -e "${f}/config" ] || continue
        echo ${f##*/} > ${d}/unbind
        basename `dirname ${f}` | xargs echo -n "Removing driver"; echo " for PCI ID" `basename ${f}`
        removed=y
    done
done
if [ -n "${removed}" ]; then
    echo "There are changes in PCI drivers, rescaning"
    echo 1 > /sys/bus/pci/rescan
else
    echo "There weren't PCI devices binded"
fi