#!/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