You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
128 lines
2.8 KiB
128 lines
2.8 KiB
#!/bin/sh |
|
|
|
set -e |
|
# Some ideas stolen from the cvs package |
|
|
|
# Config script for geneweb using debconf |
|
. /usr/share/debconf/confmodule |
|
db_version 2.0 || [ $? -lt 30 ] |
|
|
|
db_title "Geneweb genealogy software" |
|
|
|
# Needs Depends: iso-codes, isoquery |
|
ISOQUERY=/usr/bin/isoquery |
|
|
|
# These will be used here and there below |
|
SERVICES=/etc/services |
|
INITFILE=/etc/init.d/geneweb |
|
OLDRCFILE=/etc/geneweb/genewebrc |
|
NEWRCFILE=/etc/default/geneweb |
|
OLD_GENEWEBDB=/var/geneweb |
|
GENEWEBDB=/var/lib/geneweb |
|
DEFAULTLNG="en" |
|
DEFAULTFULLLNG="English" |
|
DEFAULTPORT=2317 |
|
DEFAULTRUNMODE="Always on" |
|
DEFAULTREMOVE=false |
|
DEFAULTOPTIONS="" |
|
|
|
read_rcfile() { |
|
# Default values |
|
if [ -f $NEWRCFILE ]; then |
|
LNG=$DEFAULTLNG |
|
PORT=$DEFAULTPORT |
|
RUN_MODE="$DEFAULTRUNMODE" |
|
REMOVE=$DEFAULTREMOVE |
|
OPTIONS=$DEFAULTOPTIONS |
|
. $NEWRCFILE || true |
|
# Handle the transition between LANG and LNG, in case |
|
# the $NEWRCFILE still had LANG |
|
if grep -q -E "^LANG=" $NEWRCFILE ; then |
|
LNG=$LANG |
|
fi |
|
fi |
|
} |
|
|
|
translate_LNG() { |
|
# Get the full language name from the two letter code |
|
if [ -n "$LNG" ] ; then |
|
FULLLNG=`$ISOQUERY --iso=639-2 "$LNG" | cut -f4` |
|
fi |
|
} |
|
|
|
set_debconf() { |
|
# Still have to find a way to store the language setting |
|
# (kept as "en" in rcfile and "English" in debconf |
|
if [ "$RUN_MODE" ]; then |
|
db_set geneweb/run_mode "$RUN_MODE" || true |
|
fi |
|
if [ "$FULLLNG" ]; then |
|
db_set geneweb/lang "$FULLLNG" || true |
|
fi |
|
if [ "$PORT" ]; then |
|
db_set geneweb/port "$PORT" || true |
|
fi |
|
if [ "$REMOVE" ]; then |
|
db_set geneweb/remove_databases "$REMOVE" || true |
|
fi |
|
} |
|
|
|
get_debconf() { |
|
db_get geneweb/port |
|
PORT=$RET |
|
|
|
db_get geneweb/lang |
|
FULLLNG=$RET |
|
|
|
# Find the two letter code for language |
|
LNG=`$ISOQUERY --iso=639-2 | grep "${FULLLNG}\$" | cut -f3` |
|
|
|
|
|
db_get geneweb/run_mode |
|
RUN_MODE="$RET" |
|
} |
|
|
|
|
|
input_settings() { |
|
db_input low geneweb/run_mode || true |
|
db_go |
|
db_get geneweb/run_mode |
|
RUN_MODE=$RET |
|
# If not present, use default |
|
if [ -z "$RUN_MODE" ] |
|
then |
|
RUN_MODE="$DEFAULTRUNMODE" |
|
fi |
|
if [ "$RUN_MODE" = "Always on" ] |
|
then |
|
# These question will be asked only when running in daemon mode |
|
db_input medium geneweb/lang || true |
|
db_go |
|
|
|
db_input low geneweb/port || true |
|
db_go |
|
|
|
db_input medium geneweb/remove_databases || true |
|
db_go |
|
fi |
|
} |
|
|
|
|
|
## Main program |
|
# We first read the settings file |
|
# in order to get admin-modified settings |
|
read_rcfile |
|
# We get FULLLNG ("Name (code)" style) from LNG) |
|
translate_LNG |
|
# Debconf-stored values are updated accordingly |
|
set_debconf |
|
# They are re-read from Debconf |
|
# mostly for having the correct value for LNG |
|
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 (LNG again) |
|
get_debconf |
|
|
|
|