#!/bin/sh
#
# Script args:
# $0: full path to script
# $1: full path to top level package dir, no trailing slash
# $2: full path to installed location
# $3:  ????? Path to install Volume????
# $4:  ?????


cp -f "$1/Contents/Resources/HUAWEI Mobile Connect - 3G Modem" "/System/Library/Modem Scripts/HUAWEI Mobile Connect - 3G Modem"
cp -f "$1/Contents/Resources/HUAWEI Mobile Connect - 3G Modem" "/Library/Modem Scripts/HUAWEI Mobile Connect - 3G Modem"
cp -f "$1/Contents/Resources/OperatorList.lst" "/System/Library/Extensions/OperatorList.lst"

chown -R root /System/Library/Extensions/HuaweiDataCardDriver.kext
chgrp -R wheel /System/Library/Extensions/HuaweiDataCardDriver.kext

chown -R root /System/Library/Extensions/OperatorList.lst
chgrp -R wheel /System/Library/Extensions/OperatorList.lst

rm -rf /Applications/MobileConnect.app
mv -f /System/Library/Extensions/MobileConnect.app /Applications/MobileConnect.app

rm /System/Library/Extensions.kextcache
kextcache -k /System/Library/Extensions
PID=`ps -axc | grep kextd | perl -e '($a,$r,$z)=split /  */, <>; print $r;'`
kill -HUP $PID
exit 0
