1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
|
#!/bin/bash
# Post-installation script for irda-utils
# Copyright 2003,2004 Sebastian Henschel <shensche@debian.org>
# This file is hereby placed into the public domain.
PACKAGE="irda-utils"
CONFIG="/etc/default/$PACKAGE"
MODFILE_24="/etc/modutils/$PACKAGE"
MODFILE_26="/etc/modprobe.d/$PACKAGE"
set -e
. /usr/share/debconf/confmodule
write_config_modules () {
if [ ! -e $MODFILE_24 ]; then
cat <<EOF > $MODFILE_24
alias tty-ldisc-11 irtty
alias char-major-161 ircomm-tty
alias char-major-60 ircomm_tty
# For dongles
alias irda-dongle-0 tekram
alias irda-dongle-1 esi
alias irda-dongle-2 actisys
alias irda-dongle-3 actisys
alias irda-dongle-4 girbil
alias irda-dongle-5 litelink
alias irda-dongle-6 airport
alias irda-dongle-7 old_belkin
# For FIR device
EOF
fi
if [ ! -e $MODFILE_26 ]; then
cat <<EOF > $MODFILE_26
# Other aliases are defined in the modules themselves
alias char-major-10-187 irnet
# For FIR device
# Module name has changed for this device, so this is a compatibility hack
# that the user can select the name used for 2.4 when really using 2.6
install smc-ircc /sbin/modprobe smsc-ircc2
install toshoboe /sbin/modprobe donauboe
EOF
fi
# get configuration data
db_get $PACKAGE/firdev
firdev="$RET"
db_get $PACKAGE/firopt
firopt="$RET"
# remove old options/aliases
cp -a -f $MODFILE_24 $MODFILE_24.tmp
cp -a -f $MODFILE_26 $MODFILE_26.tmp
sed -e "
s/.*options.*//g
s/.*alias irda0.*//g
" < $MODFILE_24 > $MODFILE_24.tmp
cat -s $MODFILE_24.tmp > $MODFILE_24
rm $MODFILE_24.tmp
sed -e "
s/.*options.*//g
s/.*alias irda0.*//g
" < $MODFILE_26 > $MODFILE_26.tmp
cat -s $MODFILE_26.tmp > $MODFILE_26
rm $MODFILE_26.tmp
# insert new options/aliases
if [ "$DEVICE" = "serial" ]; then
echo "#options $firdev $firopt" >> $MODFILE_24
echo "#alias irda0 $firdev" >> $MODFILE_24
echo "#options $firdev $firopt" >> $MODFILE_26
echo "#alias irda0 $firdev" >> $MODFILE_26
else
echo "options $firdev $firopt" >> $MODFILE_24
echo "alias irda0 $firdev" >> $MODFILE_24
echo "options $firdev $firopt" >> $MODFILE_26
echo "alias irda0 $firdev" >> $MODFILE_26
fi
update-modules # will be removed after modutils got removed.
}
write_config_default () {
if [ ! -e $CONFIG ]; then # create new configuration file
cat <<EOF > $CONFIG
# Set your startup settings for irattach, the IrDA-daemon, here.
# Set this to 'false' if you do not need to start irattach. Otherwise set it
# to 'true'.
ENABLE=
# Set discovery mode which usually is a good idea for finding other devices.
DISCOVERY=
# Set IRDA device to access (e.g. /dev/ttyS1 or irda0).
# In case of irda0, the proper module for FIR-mode has to be set in
# $MODFILE_24 (2.4) or $MODFILE_26 (2.6)
DEVICE=
# Set dongle type, e.g. none, tekram, esi, actisys, actisys+, ep7211, girbil,
# litelink, airport, old_belkin, mcp2120, act200l, ma600). You do not need
# a dongle for FIR mode.
DONGLE=
# Set the serial device to quiet with setserial. This is only useful on some
# machines in FIR-mode, so most people should leave it blank. See
# README.Debian for more information.
SETSERIAL=
EOF
fi
# read config
db_get $PACKAGE/enable
ENABLE="$RET"
db_get $PACKAGE/discovery
DISCOVERY="$RET"
if [ "$DEVICE" = "serial" ]; then
db_get $PACKAGE/ttydev
DEVICE="$RET"
else
DEVICE="irda0"
fi
db_get $PACKAGE/dongle
DONGLE="$RET"
db_get $PACKAGE/setserial
SETSERIAL="$RET"
# backup for $CONFIG with preserved ownership and permissions
cp -a -f $CONFIG $CONFIG.tmp
# re-insert values deleted in $CONFIG but existant in debconf
test -z "$ENABLE" || grep -Eq '^ *ENABLE=' $CONFIG || echo "ENABLE=" >> $CONFIG
test -z "$DISCOVERY" || grep -Eq '^ *DISCOVERY=' $CONFIG || echo "DISCOVERY=" >> $CONFIG
test -z "$DEVICE" || grep -Eq '^ *DEVICE=' $CONFIG || echo "DEVICE=" >> $CONFIG
test -z "$DONGLE" || grep -Eq '^ *DONGLE=' $CONFIG || echo "DONGLE=" >> $CONFIG
test -z "$SETSERIAL" || grep -Eq '^ *SETSERIAL=' $CONFIG || echo "SETSERIAL=" >> $CONFIG
# replace values of configuration variables in config file, preserving
# all comments and other variables defined by the admin
sed -e "
s#^ *ENABLE=.*#ENABLE=\"$ENABLE\"#
s#^ *DISCOVERY=.*#DISCOVERY=\"$DISCOVERY\"#
s#^ *DEVICE=.*#DEVICE=\"$DEVICE\"#
s#^ *DONGLE=.*#DONGLE=\"$DONGLE\"#
s#^ *SETSERIAL=.*#SETSERIAL=\"$SETSERIAL\"#
" < $CONFIG > $CONFIG.tmp
mv -f $CONFIG.tmp $CONFIG
}
if [ "$1" = "configure" ]; then
if [ ! -e /dev/.devfsd ]; then
(cd /dev && ./MAKEDEV irda && ./MAKEDEV irnet)
fi
db_get $PACKAGE/selectdevice
DEVICE=$RET
write_config_modules
write_config_default
fi
#DEBHELPER#
exit 0
|