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
|
#!/bin/sh
set -e
# Some ideas stolen from the cvs package
# Config script for seyon using debconf
. /usr/share/debconf/confmodule
db_version 2.0 || [ $? -lt 30 ]
db_title "Seyon communication software"
# Defaults
MODEMDEFAULTS=/etc/X11/seyon/Seyon-modem
DEFAULTPORT=/dev/modem
PORT=$DEFAULTPORT
read_rcfile() {
# Default values
if [ -f $MODEMDEFAULTS ]; then
PORT=`cat $MODEMDEFAULTS | grep -m1 "^seyon\*modems:" | cut -f2 -d: 2>/dev/null`
fi
if [ -z $PORT ] ; then
PORT=$DEFAULTPORT
fi
}
write_rcfile() {
TEMPFILE=`tempfile`
if [ -f $MODEMDEFAULTS ]; then
ESCAPEDPORT=`echo $PORT | sed 's/\//\\\\\//g'`
sed "s/^seyon\*modems:.*$/seyon\*modems: ${ESCAPEDPORT}/" $MODEMDEFAULTS > $TEMPFILE
chmod --reference=$MODEMDEFAULTS $TEMPFILE
chown --reference=$MODEMDEFAULTS $TEMPFILE
else
echo "seyon*modems: $PORT" > $TEMPFILE
chmod 640 $TEMPFILE
chown root:dialout $TEMPFILE
fi
if [ ! -d /etc/X11/seyon ] ; then
mkdir -p /etc/X11/seyon
fi
mv $TEMPFILE $MODEMDEFAULTS
}
set_debconf() {
if [ "$PORT" ]; then
db_set seyon/device "$PORT" || true
fi
}
get_debconf() {
db_get seyon/device
PORT=$RET
# If not present, use default
if [ "$PORT" = "" ]
then
PORT=$DEFAULTPORT
fi
}
input_settings() {
db_input low seyon/device || true
db_go
db_get seyon/device
PORT=$RET
# If not present, use default
if [ "$PORT" = "" ]
then
PORT=$DEFAULTPORT
fi
}
## Main program
# We first read the settings file
# in order to get admin-modified settings
read_rcfile
# Debconf-stored values are updated accordingly
set_debconf
# They are re-read from Debconf
get_debconf
# In case the package has never been configured, the settings
# are asked through debconf
input_settings
# They are re-re-read from debconf
# for updating variables
get_debconf
# The settings file is written
write_rcfile
# Then we do some other stuff, which could sometimes lead to
# debconf showing screens
# This is why they are here and not in the postinst script
|