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
|
#!/bin/sh -e
# $Id: config,v 1.17 2002/04/11 00:22:02 vanbaal Exp $
# see debconf_specification.txt.gz , policy.text.gz ,
# /usr/share/doc/debconf-doc/
# http://kitenet.net/doc/debconf-doc/
# /var/lib/dpkg/info/cvs.* , /var/lib/dpkg/info/*.config
# just run this as # ./config when debugging, after exporting
# DEBCONF_DEBUG='.*' and, possibly, DEBIAN_FRONTEND=text, and maybe even
# having ran # dpkg-reconfigure debconf
# make sure your /var/cache/debconf/ is sane.
# Source debconf library.
. /usr/share/debconf/confmodule
ok=
while test -z "$ok"
do
db_input medium lire/user || true
db_go
db_get lire/user
user=${RET:-lire}
if id $user >/dev/null 2>&1
then
# specified account already lives on the system
db_subst lire/useexistinguser user "$user"
db_input high lire/useexistinguser || true
db_go
db_get lire/useexistinguser
if test x"$RET" = x"true"
then
ok=1
db_subst lire/usingexistinguser user "$user"
db_input high lire/usingexistinguser || true
db_go
else
db_fset lire/user seen false
db_fset lire/useexistinguser seen false
fi
elif echo "$user" | grep -q '^[a-z][a-z0-9]*$'
then
ok=1
else
db_subst lire/wronguser user "$user"
db_input high lire/wronguser || true
db_go
db_fset lire/user seen false
fi
done
db_subst lire/config user "$user"
# go deal with lire user's group
ok=
while test -z "$ok"
do
# ask for preferred group
db_input medium lire/group || true
db_go
db_get lire/group
group=${RET:-lire}
# it's a shame there's no standard commandline tool to test for the
# existence of a given group. perl to the rescue!
# (just doing
# if grep -q "^lire:" /etc/group
# is not what we want: it gives incorrect results on systems not
# using the /etc/group file for group management, but e.g. nis.
# (see also debian bug #94936)
# check if preferred group already on the system
OK=`perl -e 'defined getgrnam("'$group'") && print "OK\n"'`
if test OK = "$OK"
then
# it's on the system, ask if that's ok
db_subst lire/useexistinggroup group "$group"
db_input high lire/useexistinggroup || true
db_go
db_get lire/useexistinggroup
if test x"$RET" = x"true"
then
ok=1
db_subst lire/usingexistinggroup group "$group"
db_input high lire/usingexistinggroup || true
db_go
else
db_fset lire/group seen false
db_fset lire/useexistinggroup seen false
fi
# group is not on the system, check if given name looks ok
elif echo "$group" | grep -q '^[a-z][a-z0-9]*$'
then
ok=1
else
db_subst lire/wronggroup group "$group"
db_input high lire/wronggroup || true
db_go
db_fset lire/group seen false
fi
done
# we have a sane $group and usingexistinggroup recorded now
# check if current Lire user looks like created by buggy package
# (no, it's no use inspecting the usingexistinguser flag here: Lire
# might have been purged and reinstalled, which kept the account
# created during first installation, but now marked as usingexistinguser.)
if id $user >/dev/null 2>&1
then
uid="`id -u $user`"
if test \( $uid -ge 1000 \) -a \( $uid -le 29999 \)
then
# ... if so, inform user
db_subst lire/foundlocaluser user "$user"
db_input medium lire/foundlocaluser || true
fi
fi
# tell the user to do manual configuration
db_input high lire/config || true
db_go
exit 0
|