Articles
[SCRIPT] Module creator for Smartlink modems
- Details
- Created on 12 January 2011
NOTE: This script is written for Porteus V1.0
Cut + paste main code below and save as 'slmodem.pbuild'
Make it executable: chmod +x slmodem.pbuild
Run the script: ./slmodem.pbuild
#!/bin/bash
#
# slmodemd package for Smartlink Modems
# Download both packages (slmodem and ungrab-winmodem) with wget, ncomment if internet
# connection is not present put a "#" before wget commands
#
#wget http://linmodems.technion.ac.il/packages/smartlink/slmodem-2.9.11-20110321.tar.gz
#sleep 2
#wget http://linmodems.technion.ac.il/packages/smartlink/ungrab-winmodem-20090716.tar.gz
#sleep 2
PKG=slmodem-2.9.11-20110321
TMP=/tmp/slmodem$$
PKG2=ungrab-winmodem-20090716
TMP2=/tmp/ungrab-winmodem$$
#set -e
tar -zxvf $PKG*
tar -zxvf $PKG2*
# copy rc.slmodemd fromm script/slackware packages and make changes to work in porteus
cd $PKG/scripts/slackware/
sed -i '8 s|/dev/slusb0|/dev/slamr0|g' rc.slmodemd
sed -i '8 a /sbin/depmod -a' rc.slmodemd
sed -i '9 a sleep 3' rc.slmodemd
sed -i '13 a if ! -e $SLMODEMD_DEVICE &> /dev/null; then \' rc.slmodemd
sed -i '14 a {\' rc.slmodemd
sed -i '15 a \\t mkdir -p /dev' rc.slmodemd
sed -i '16 a \\t mknod -m 600 /dev/slamr0 c 242 0 ; mknod -m 600 /dev/slamr1 c 242 1 ;' rc.slmodemd
sed -i '17 a \\t mknod -m 600 /dev/slamr2 c 242 2 ; mknod -m 600 /dev/slamr3 c 242 3 ;' rc.slmodemd
sed -i '18 a \\t echo -n' rc.slmodemd
sed -i '19 a \\t mknod -m 600 /dev/slusb0 c 243 0 ; mknod -m 600 /dev/slusb1 c 243 1 ;' rc.slmodemd
sed -i '20 a \\t mknod -m 600 /dev/slusb2 c 243 2 ; mknod -m 600 /dev/slusb3 c 243 3 ;' rc.slmodemd
sed -i '21 a \\t echo -n ||' rc.slmodemd
sed -i '22 a \\t {' rc.slmodemd
sed -i '23 a \\t echo "failed."' rc.slmodemd
sed -i '24 a \\t exit -1' rc.slmodemd
sed -i '25 a \\t }' rc.slmodemd
sed -i '26 a }' rc.slmodemd
sed -i '27 a fi' rc.slmodemd
sed -i '28 a\' rc.slmodemd
sed -i '28 a \\t cat /proc/modules | grep 'ungrab_winmodem' >/dev/null ||' rc.slmodemd
sed -i '29 a \\t {' rc.slmodemd
sed -i '30 a \\t echo -n "Ungrabbing winmodem from kernel ... "' rc.slmodemd
sed -i '31 a \\t modprobe ungrab-winmodem && echo "done." ||' rc.slmodemd
sed -i '32 a \\t {' rc.slmodemd
sed -i '33 a \\t echo "failed."' rc.slmodemd
sed -i '34 a \\t exit -1' rc.slmodemd
sed -i '35 a \\t }' rc.slmodemd
sed -i '36 a \\t }' rc.slmodemd
sed -i '37 a \\t cat /proc/modules | grep 'slamr' >/dev/null ||' rc.slmodemd
sed -i '38 a \\t {' rc.slmodemd
sed -i '39 a \\t echo -n "Loading SmartLink Modem driver into kernel ... "' rc.slmodemd
sed -i '40 a \\t modprobe slamr && echo "done." ||' rc.slmodemd
sed -i '41 a \\t {' rc.slmodemd
sed -i '42 a \\t echo "failed."' rc.slmodemd
sed -i '43 a \\t exit -1' rc.slmodemd
sed -i '44 a \\t }' rc.slmodemd
sed -i '45 a \\t }' rc.slmodemd
# end of long sed expression
mkdir -p $TMP/etc/rc.d/
cp rc.slmodemd $TMP/etc/rc.d/
chmod +x $TMP/etc/rc.d/rc.slmodemd
cd ..
cd ..
# return to base directory
sleep 3
make KERNEL_DIR=/lib/modules/`uname -r`/build
make all
make install DESTDIR=$TMP
sleep 3
cd ..
# take care of ungrab-winmodem
cd $PKG2
make
make install
mkdir -p $TMP/lib/modules/`uname -r`/extra
cp -ra /lib/modules/`uname -r`/extra/ungrab-winmodem.ko $TMP/lib/modules/`uname -r`/extra
sleep 5
rm -Rf $TMP2
# delete slamr.ko and ungrab-winmodem.ko
rm -rf /lib/modules/`uname -r`/extra/slamr.ko
rm -rf /lib/modules/`uname -r`/extra/ungrab-winmodem.ko
# copy build script
cd ..
mkdir -p $TMP/usr/src/pbuilds/
cp $0 $TMP/usr/src/pbuilds/
find $TMP -type d | xargs chmod -v 755
find $TMP | grep .gz | xargs gunzip
find $TMP | xargs file | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded
dir2xzm $TMP $PKG.xzm
rm -Rf $TMP
rm -Rf $PKG
rm -Rf $PKG2
chmod 755 $PKG.xzm