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
|
#
# /etc/rc.serial
# Initializes the serial ports on your system
#
# chkconfig: 2345 50 75
# description: This initializes the settings of the serial port
#
# FILE_VERSION: 19981128
#
# Distributed with setserial and the serial driver. We need to use the
# FILE_VERSION field to assure that we don't overwrite a newer rc.serial
# file with a newer one.
#
# XXXX For now, the autosave feature doesn't work if you are
# using the multiport feature; it doesn't save the multiport configuration
# (for now). Autosave also doesn't work for the hayes devices.
# Will fix later...
#
#
RCLOCKFILE=/var/lock/subsys/serial
DIRS="/lib/modules/`uname -r`/misc /lib/modules /usr/lib/modules ."
PATH=/bin:/sbin:/usr/bin
DRIVER=serial
DRIVER_NAME=serial
MODULE_REGEXP="serial\b"
ALLDEVS="/dev/ttyS?"
if /bin/ls /dev/ttyS?? >& /dev/null ; then
ALLDEVS="$ALLDEVS /dev/ttyS??"
fi
SETSERIAL=""
if test -x /bin/setserial ; then
SETSERIAL=/bin/setserial
elif test -x /sbin/setserial ; then
SETSERIAL=/sbin/setserial
fi
#
# See if the serial driver is loaded
#
LOADED=""
if test -f /proc/devices; then
if grep -q " ttyS$" /proc/devices ; then
LOADED="yes"
else
LOADED="no"
fi
fi
#
# Find the serial driver
#
for i in $DIRS
do
if test -z "$MODULE" -a -f $i/$DRIVER.o ; then
MODULE=$i/$DRIVER.o
fi
done
if ! test -f /proc/modules ; then
MODULE=""
fi
#
# Handle System V init conventions...
#
case $1 in
start)
action="start";
;;
stop)
action="stop";
;;
*)
action="start";
esac
if test $action = stop ; then
if test -n ${SETSERIAL} -a "$LOADED" != "no" -a \
`head -1 /etc/serial.conf`X = "###AUTOSAVE###X" ; then
echo -n "Saving state of serial devices... "
grep "^#" /etc/serial.conf > /etc/.serial.conf.new
${SETSERIAL} -G -g ${ALLDEVS} >> /etc/.serial.conf.new
mv /etc/serial.conf /etc/.serial.conf.old
mv /etc/.serial.conf.new /etc/serial.conf
echo "done."
fi
if test -n $MODULE ; then
module=`grep $MODULE_REGEXP /proc/modules | awk '{print $1}'`
if test -z "$module" ; then
echo "The $DRIVER_NAME driver is not loaded."
rm -f ${RCLOCKFILE}
exit 0
fi
if rmmod $module ; then :; else
echo "The $DRIVER_NAME driver could NOT be unloaded."
exit 1;
fi
echo "The $DRIVER_NAME driver has been unloaded."
fi
rm -f ${RCLOCKFILE}
exit 0
fi
#
# If not stop, it must be a start....
#
if test -n $MODULE -a "$LOADED" != "yes" ; then
if insmod -fm $MODULE $DRIVER_ARG \
> /tmp/$DRIVER.map 2> /tmp/$DRIVER.$$; then :;
else
echo "Couldn't load $DRIVER_NAME driver."
echo "See error logs in /tmp/$DRIVER.$$"
exit 1
fi
/bin/rm -f /tmp/$DRIVER.$$
fi
if test -f /etc/serial.conf ; then
if test -n ${SETSERIAL} ; then
grep -v ^# < /etc/serial.conf | while read device args
do
${SETSERIAL} -z $device $args
done
fi
else
echo "###AUTOSAVE###" > /etc/serial.conf
fi
touch ${RCLOCKFILE}
${SETSERIAL} -bg ${ALLDEVS}
|