]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - src/rc.d/rc.conexantpciadsl
git-svn-id: http://svn.ipfire.org/svn/ipfire/IPFire/source@16 ea5c0bd1-69bd-2848...
[ipfire-2.x.git] / src / rc.d / rc.conexantpciadsl
diff --git a/src/rc.d/rc.conexantpciadsl b/src/rc.d/rc.conexantpciadsl
new file mode 100644 (file)
index 0000000..3eb2dec
--- /dev/null
@@ -0,0 +1,80 @@
+#!/bin/bash
+#
+# $Id: rc.conexantpciadsl,v 1.1.2.11 2005/07/07 20:11:58 franck78 Exp $
+#
+
+# Debugging. Comment it out to stop logging
+DEBUG="yes"
+msg() {
+       if [ "z$DEBUG" != "z" ] ; then
+               /usr/bin/logger -t red "CnxPCI ADSL: $*"
+       fi
+       /bin/echo "$*"
+}
+
+function wait_for_showtime() {
+  msg "waiting for sync"
+  count=0
+  while [ ! $count = 45 ]; do
+       /bin/sleep 2
+       if ( /usr/sbin/cnxadslstatus | /bin/grep -q -F 'Showtime.' ); then
+               msg "sync done"
+               return 0
+       fi
+       ((++count))
+  done
+  return 1
+}
+
+# See how we were called.
+case "$1" in
+  start)
+       msg "starting"
+       # if the driver is not already loaded then
+       if ( /sbin/lsmod | /bin/grep -q CnxADSL ); then
+                       msg "already loaded"
+       else
+               if ( ! /bin/cat /proc/pci | /bin/grep -q '14f1' ); then
+                       msg "no conexant modem"
+                       exit 1
+               fi
+               /sbin/modprobe CnxADSL
+               RETVAL=$?
+               if [ $RETVAL -ne 0 ] ; then
+                       msg "error when loading, card present?"
+               fi
+               if ( /bin/cat /proc/pci | /bin/grep -q '14f1:1611' ); then
+                       # Tigris model
+                       /bin/ln -f -s /etc/Conexant/CnxTgF.hex CONFIG_ROOT/cnx_pci/firmware.hex
+               else
+                       if ( /bin/cat /proc/pci | /bin/grep -q '14f1:1622' ); then
+                               # Yukon model
+                               /bin/ln -f -s /etc/Conexant/CnxYkF.hex CONFIG_ROOT/cnx_pci/firmware.hex
+                       else
+                               msg "don't know this model"
+                               exit 1
+                       fi
+               fi
+
+               # Initialize the firmware and start training
+               /bin/ln -f -s /etc/Conexant/cnxadsl.conf CONFIG_ROOT/cnx_pci/cnxadsl.conf
+               /etc/Conexant/cnxadslload CONFIG_ROOT/cnx_pci
+       fi
+       wait_for_showtime
+       exit $?
+       ;;
+stop)
+       msg "stop"
+       ;;
+cleanup)
+       msg "cleanup"
+       /bin/killall cnxadslload 2>/dev/null
+       /sbin/modprobe -r CnxADSL
+       ;;
+  *)
+       echo "Usage: $0 {start|stop|cleanup}"
+       exit 1
+       ;;
+esac
+
+exit 0