summaryrefslogtreecommitdiff
path: root/recipes-kernel/rs9113/files/rs9113/mts-rm-rs9113
blob: a7a30c29f44a20f16774e28437b53901ecd3fd12 (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
### BEGIN INIT INFO
# Provides: mts-rm-rs9113
# Default-Start:  S
# Default-Stop:
# Short-Description: remove the rs9113 driver if no rs9113 present
# Description: If mts-io capability wifi exists, test it and remove
#	       the rs9113 related packages if present and no wifi
#	       capability.  Must run after mts-io but before rs9113.
### END INIT INFO

# update-rc.d mts-rm-rs9113 start 40 S .   

sysdir=/sys/devices/platform/mts-io
remount=0

function cleanup {
    if ((remount == 1)) ; then
            mount -o ro,remount /
    fi
}

trap cleanup EXIT

if [[ -f ${sysdir}/capability/wifi ]] ; then
    if [[ -f /opt/rs9113/onebox_wlan_nongpl.ko ]] && (( $(cat ${sysdir}/capability/wifi) == 0)) ; then
        logger -sp daemon.info 'Attempting to remove rs9113 drivers from non-wifi device'
        rmount=$(grep '^/dev/root' /proc/mounts)
        remount=0
        if [[ $rmount =~ [[:space:],]ro[[:space:],] ]] ; then
                remount=1
                mount -o rw,remount /
        fi
        plist="rs9113-autostart rs9113-misc rs9113-noarch rs9113-util rs9113-utils-extra kernel-module-rs9113"
        for p in $plist ; do
            opkg remove $p
        done
        
        rlist=$(opkg list-installed | grep rs9113)

        for p in $plist ; do
            # Hopefully the packages have been removed.
            if [[ $rlist =~ (^|[[:space:]])${p}[[:space:]] ]] ; then
                exit 1
            fi
        done

    fi

    update-rc.d -f mts-rm-rs9113 remove
fi