3 # Purpose: start device drivers and set /dev/modem link in GRML
4 # Authors: (c) Klaus Knopper Mar 2004, (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports: see http://grml.org/bugs/
6 # License: This file is licensed under the GPL v2.
7 # Latest change: Mit Okt 04 11:51:09 CEST 2006 [mika]
8 ################################################################################
10 PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin"
13 # XDIALOG_HIGH_DIALOG_COMPAT=1
14 # export XDIALOG_HIGH_DIALOG_COMPAT
16 if [ $UID != 0 ] ; then
17 echo Error: become root before starting $0 >& 2
29 # [ -n "$DISPLAY" ] && [ -x /usr/bin/Xdialog ] && DIALOG="Xdialog"
34 [ -r /etc/default/locale ] && . /etc/default/locale
36 # Language-dependent Messages
39 TITLE1="Art der Verbindung"
40 MESSAGE1="Bitte die gewuenschten Verbindungsart auswaehlen:"
41 SERIAL="Serielle Schnittstelle (z.B. Modem)"
42 WINMODEM="Nach nicht-unterstuetzten \"WinModems\" suchen"
43 SIR="Standard SIR (oder USB)"
44 USB="USB Schnittstelle (z.B. Modem)"
45 IRDA="Infrarot Schnittstelle (z.B. fuer Handy/PDA)"
46 BLUETOOTH="Bluetooth Funkadapter (z.B. fuer Handy/PDA)"
47 TITLE_DONGLES="IRDA Adapter-Typ"
48 MESSAGE_DONGLES="Bitte den verwendeten IRDA-Adaptertyp auswaehlen:"
49 TITLE_TEST="Adaptertest - Strg-C zum Beenden des Tests"
50 TITLE_SRVFAIL="FEHLER"
51 MESSAGE_SRVFAIL="Konnte Daemon fuer Geraet nicht starten. Wahrscheinlich wurde die falsche Schnittstelle ausgewaehlt."
52 AUTOSEARCH="ALLE Schnittstellen scannen"
53 TITLE_BLUES="Bluetooth-Geraete"
54 MESSAGE_BLUES="Folgende Bluetooth-Geraete befinden sich in der Umgebung. Bitte eins auswaehlen:"
56 MESSAGE_PIN="Bitte geben Sie eine 4-stellige PIN zur Authentfizierung der Bluetooth-Geraete ein:"
57 TITLE_GAUGE="Device-Scan..."
58 TITLE_LINK="/dev/modem Link erzeugen..."
59 MESSAGE_LINK="Moechten Sie den Symlink /dev/modem auf das neu konfigurierte Geraet setzen? Dies ist notwendig, wenn Sie das Geraet z.B. als Modem fuer kppp oder GPRS benutzen moechten).
61 Verlinken von /dev/modem -> "
63 MESSAGE_RETRY="Das scheint nicht geklappt zu haben. Noch einmal versuchen?"
64 TITLE_BTID="Keine Bluetooth Geraete in Reichweite"
65 MESSAGE_BTID="Auf die Sendeanfrage hat kein Bluetooth-Geraet geantwortet. Bitte geben Sie die Adresse eines entfernten Bluetooth-Geraetes ein."
68 TITLE1="Connection Type"
69 MESSAGE1="Please select type of connection:"
70 WINMODEM="Scan for unsupported \"WinModems\""
71 SERIAL="Serial connector (i.e. Modem)"
72 SIR="Standard SIR (or USB)"
73 USB="USB connector (i.e. Modem)"
74 IRDA="Infrared wireless device (i.e. cellphone/PDA)"
75 BLUETOOTH="Bluetooth wireless device (i.e. cellphone/PDA)"
76 TITLE_DONGLES="IRDA Adapter type"
77 MESSAGE_DONGLES="Please select type of IRDA adapter:"
78 TITLE_TEST="Testing adapter - Hit Ctrl-C to end test."
80 MESSAGE_SRVFAIL="Failed to start device daemon. Probably the selected port is wrong."
81 AUTOSEARCH="scan ALL devices"
82 TITLE_BLUES="Bluetooth Devices"
83 MESSAGE_BLUES="These bluetooth devices exist nearby. Please select:"
85 MESSAGE_PIN="Please chose a 4-digit PIN number for authention of bluetooth devices:"
86 TITLE_GAUGE="Scanning devices..."
87 TITLE_LINK="Create /dev/modem link..."
88 MESSAGE_LINK="Do you want to set the symlink /dev/modem to point to the newly configured device? This is necessary if you want o use the device as modem for kppp, as an example, or for using GPRS).
90 Create link /dev/modem -> "
92 MESSAGE_RETRY="This seems to have failed. Do you want to try again?"
93 TITLE_BTID="No bluetooth devices in range"
94 MESSAGE_BTID="No bluetooth devices responded to our scan. Please enter the address of a remote bluetooth device."
98 # Shortcut description selected
99 TYPES=(serial "$SERIAL" on \
102 bluetooth "$BLUETOOTH" off \
103 winmodem "$WINMODEM" off)
105 type scanmodem >/dev/null 2>&1 || { unset TYPES[14]; unset TYPES[13]; unset TYPES[12]; }
106 type rfcomm >/dev/null 2>&1 || { unset TYPES[11]; unset TYPES[10]; unset TYPES[9]; }
107 type irdadump >/dev/null 2>&1 || { unset TYPES[8]; unset TYPES[7]; unset TYPES[6]; }
110 DONGLES=(auto "$SIR" on \
111 act200l "ACTiSYS Ir-200L dongles" off \
112 actisys "ACTiSYS IR-220L dongle" off \
113 actisys+ "ACTiSYS IR-220L+ dongle" off \
114 airport "Airport dongle" off \
115 ep7211 "IR port driver for the Cirrus Logic EP7211 processor (ARM based)" off \
116 esi "Extended Systems JetEye PC ESI-9680" off \
117 girbil "Greenwich GIrBIL dongle" off \
118 litelink "Parallax LiteLink dongle & Extended Systems JetEye PC ESI-9680B" off \
119 old_belkin "Belkin (old) SmartBeam dongle or any dongle only capable of 9600 bauds" off \
120 ma600 "Mobile Action ma600 dongles" off \
121 mcp2120 "Dongles based on the MCP2120 (Microchip)" off \
122 tekram "Tekram IrMate IR-210B dongle" off)
124 AUTODEVICE=(auto "$AUTOSEARCH" off)
126 SERIALDEVICES=(ttyS0 "(COM1:)" off \
127 ttyS1 "(COM2:)" off \
128 ttyS2 "(COM3:)" off \
129 ttyS3 "(COM4:)" off \
130 ttyS4 "(COM5:)" off \
131 ttyS5 "(COM6:)" off \
132 ttyS6 "(COM7:)" off \
133 ttyS7 "(COM8:)" off \
134 ttyS8 "(COM9:)" off \
135 ttyS9 "(COM10:)" off \
136 ttyS10 "(COM11:)" off \
137 ttyS11 "(COM12:)" off \
138 ttyS12 "(COM13:)" off \
139 ttyS13 "(COM14:)" off \
140 ttyS14 "(COM15:)" off \
141 ttyS15 "(COM16:)" off)
143 USBDEVICES=(ttyACM0 "USB Modem 1" off \
144 ttyACM1 "USB Modem 2" off \
145 ttyACM2 "USB Modem 3" off \
146 ttyACM3 "USB Modem 4" off \
147 ttyUSB0 "USB Serial 0" off \
148 ttyUSB1 "USB Serial 1" off \
149 ttyUSB2 "USB Serial 2" off \
150 ttyUSB3 "USB Serial 3" off)
154 #for ((i=0; i<$num; i++)); do
155 ## Remove non-existing desktops/descriptions from list
157 #d1="$(($i * 3 + 1))"
158 #d2="$(($i * 3 + 2))"
159 #if type "${COMMANDS[$i]}" >/dev/null 2>&1; then
160 #[ "$DESKTOP" = "${DESKTOPS[$(($i * 3))]}" ] && DESKTOPS[$(($i * 3 + 2))]="on" || DESKTOPS[$(($i * 3 + 2))]="off"
172 while [ ! -e "$TMP.done" ]; do echo "$status" ; status="`expr \( 100 - $status \) / 4 + $status`"; sleep 2; done | $DIALOG --title "$TITLE_GAUGE" --gauge "$1" 8 75 0
177 touch "$TMP.done" ; wait ; rm -f "$TMP.done"
182 $DIALOG --clear --title "$TITLE1" --radiolist "$MESSAGE1" 18 75 9 "${TYPES[@]}" 2>"$TMP" || bailout 1
184 TYPE="${TYPE#\"}"; TYPE="${TYPE%\"}"
193 $DIALOG --clear --title "$TITLE_RAWDEVICE" --radiolist "$MESSAGE_RAWDEVICE" 18 75 9 "${SERIALDEVICES[@]}" 2>"$TMP" || bailout 1
195 DEVICE="${DEVICE#\"}"; DEVICE="${DEVICE%\"}"
199 [ -n "$DISPLAY" ] && xterm -e bash -c "scanmodem; read -p 'Enter to quit.'" || { scanmodem; read -p 'Enter to quit.'; }
204 $DIALOG --clear --title "$TITLE_RAWDEVICE" --radiolist "$MESSAGE_RAWDEVICE" 18 75 9 "${USBDEVICES[@]}" 2>"$TMP" || bailout 1
206 DEVICE="${DEVICE#\"}"; DEVICE="${DEVICE%\"}"
210 killall irattach 2>/dev/null
211 modprobe irda 2>/dev/null
212 modprobe ircomm-tty 2>/dev/null
214 $DIALOG --clear --title "$TITLE_RAWDEVICE" --radiolist "$MESSAGE_RAWDEVICE" 18 75 9 "${AUTODEVICE[@]}" "${SERIALDEVICES[@]}" "${USBDEVICES[@]}" 2>"$TMP" || bailout 1
215 read RAWDEVICE <"$TMP"
216 RAWDEVICE="${RAWDEVICE#\"}"; RAWDEVICE="${RAWDEVICE%\"}"
218 $DIALOG --clear --title "$TITLE_DONGLES" --radiolist "$MESSAGE_DONGLES" 18 75 9 "${DONGLES[@]}" 2>"$TMP" || bailout 1
220 DONGLE="${DONGLE#\"}"; DONGLE="${DONGLE%\"}"
222 case "$DONGLE" in auto) DONGLE="" ;; *) DONGLE="-d $DONGLE" ;; esac
223 if [ "$RAWDEVICE" = "auto" ]; then
224 gauge "Device-Scan..." &
225 for i in /dev/ttyUSB* /dev/ttyS*; do
226 RAWDEVICE="${i##/dev/}"
227 irattach "/dev/$RAWDEVICE" $DONGLE -s
232 RAWDEVICE="$(ps auxw | awk '/irattach/{print $12}' | head -1)"
233 RAWDEVICE="${RAWDEVICE##/dev/}"
235 irattach "/dev/$RAWDEVICE" $DONGLE -s
238 if ifconfig irda0 >/dev/null 2>&1; then
241 $DIALOG --clear --title "$TITLE_SRVFAIL" --msgbox "$MESSAGE_SRVFAIL" 18 75
247 echo "#irda.conf Version: 1.0
248 IRDADEV=/dev/$RAWDEVICE" >/etc/irda.conf
249 [ -n "$DONGLE" ] && echo "DONGLE=\"${DONGLE##-d }\"" >>/etc/irda.conf
251 ENABLE=yes" >>/etc/irda.conf
252 [ -x /etc/init.d/irda ] && for i in 2 3 5; do ln -sf /etc/init.d/irda /etc/rc$i.d/S99irda; done
255 killall hcid 2>/dev/null
256 killall rfcomm 2>/dev/null
259 gauge "Device-Scan..." &
260 while read HW NAME; do
262 d1="$(($count * 3 + 1))"
263 d2="$(($count * 3 + 2))"
264 BLUES[$d0]="$HW"; BLUES[$d1]="$NAME"; BLUES[$d2]="off"
265 count=$(($count + 1))
267 $(hcitool scan 2>/dev/null | awk '/[0-9]:[0-9]/{print $0}')
270 if [ -n "${BLUES[0]}" ]; then
271 $DIALOG --clear --title "$TITLE_BLUES" --radiolist "$MESSAGE_BLUES" 18 75 9 "${BLUES[@]}" 2>"$TMP" || bailout 1
273 $DIALOG --title "$TITLE_BTID" --inputbox "$MESSAGE_BTID" 15 60 "00:00:00:00:00:00" 2>"$TMP" || bailout 1
275 read RAWDEVICE <"$TMP"
276 RAWDEVICE="${RAWDEVICE#\"}"; RAWDEVICE="${RAWDEVICE%\"}"
278 read PIN < /etc/bluetooth/pin 2>/dev/null
280 if [ -n "$DISPLAY" ]; then
281 $DIALOG --title "$TITLE_PIN" --inputbox "$MESSAGE_PIN" 8 65 "$PIN" 2>"$TMP" || bailout 1
283 read PIN <"$TMP" 2>/dev/null
285 rm -f /etc/bluetooth/pin
286 echo "$PIN" >/etc/bluetooth/pin
287 rm -f /etc/bluetooth/rfcomm.conf
288 cat >/etc/bluetooth/rfcomm.conf <<EOT
290 # RFCOMM configuration file.
292 # Created by modemlink-grml on $(date)
297 # Bluetooth address of the device
299 # RFCOMM channel for the connection
301 # Description of the connection
302 comment "Selected Bluetooth device";
306 [ -x /etc/init.d/bluez-utils ] && for i in 2 3 5; do ln -sf /etc/init.d/bluez-utils /etc/rc$i.d/S99bluez-utils; done
318 if [ "$?" = "0" -a -n "$DEVICE" ]; then
319 $DIALOG --title "$TITLE_LINK" --yesno "$MESSAGE_LINK $DEVICE ?" 15 65 || bailout 1
321 ln -sf /dev/"$DEVICE" /dev/modem
324 $DIALOG --clear --title "$TITLE_RETRY" --yesno "$MESSAGE_RETRY" 18 75 || bailout 1
330 ## END OF FILE #################################################################