| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
set -e |
| 4 |
|
| 5 |
# source debconf library. |
| 6 |
. /usr/share/debconf/confmodule |
| 7 |
db_version 2.0 |
| 8 |
db_capb backup |
| 9 |
|
| 10 |
# set title |
| 11 |
db_title "Configuring cvsd" |
| 12 |
|
| 13 |
configfile="/etc/cvsd/cvsd.conf" |
| 14 |
|
| 15 |
# read values from the current configuration file |
| 16 |
if [ -r "$configfile" ] |
| 17 |
then |
| 18 |
|
| 19 |
# Location of Chroot jail |
| 20 |
rootjail=`sed -n 's/^[[:space:]]*RootJail[[:space:]][[:space:]]*\([^[:space:]]*\)[[:space:]]*$/\1/p' < "$configfile"` |
| 21 |
[ "x$rootjail" = "x" ] && rootjail="none" |
| 22 |
db_set cvsd/rootjail "$rootjail" |
| 23 |
|
| 24 |
# Maximum number of connections |
| 25 |
maxconnections=`sed -n 's/^[[:space:]]*MaxConnections[[:space:]][[:space:]]*\([^[:space:]]*\)[[:space:]]*$/\1/p' < "$configfile"` |
| 26 |
[ "x$maxconnections" = "x" ] && maxconnections=0 |
| 27 |
db_set cvsd/maxconnections "$maxconnections" |
| 28 |
|
| 29 |
# Nice value to run at |
| 30 |
nice=`sed -n 's/^[[:space:]]*Nice[[:space:]][[:space:]]*\([^[:space:]]*\)[[:space:]]*$/\1/p' < "$configfile"` |
| 31 |
[ "x$nice" = "x" ] && nice=0 |
| 32 |
db_set cvsd/nice "$nice" |
| 33 |
|
| 34 |
# Umask to use |
| 35 |
umask=`sed -n 's/^[[:space:]]*Umask[[:space:]][[:space:]]*\([^[:space:]]*\)[[:space:]]*$/\1/p' < "$configfile"` |
| 36 |
[ "x$umask" = "x" ] && umask=027 |
| 37 |
db_set cvsd/umask "$umask" |
| 38 |
|
| 39 |
# Address-Port combinations to listen on |
| 40 |
listen=`sed -n 's/^[[:space:]]*Listen[[:space:]][[:space:]]*\([^[:space:]]*\)[[:space:]][[:space:]]*\([^[:space:]]*\)[[:space:]]*$/\1 \2/p' < "$configfile"` |
| 41 |
listen=`echo "$listen" | tr '\n' ' ' | sed 's/ *$//'` |
| 42 |
[ "x$listen" = "x" ] && listen="* 2401" |
| 43 |
db_set cvsd/listen "$listen" |
| 44 |
|
| 45 |
# get current repositories from configfile |
| 46 |
reposs=`sed -n 's/^[[:space:]]*Repos[[:space:]][[:space:]]*\([^[:space:]]*\)[[:space:]]*$/\1/p' < "$configfile"` |
| 47 |
reposs=`echo "$reposs" | tr '\n' ':' | sed 's/:*$//'` |
| 48 |
db_set cvsd/repositories "$reposs" |
| 49 |
|
| 50 |
# read current limits |
| 51 |
limits="" |
| 52 |
for i in `sed -n 's/^[[:space:]]*Limit[[:space:]][[:space:]]*\([^[:space:]]*\)[[:space:]][[:space:]]*[^[:space:]]*[[:space:]]*$/\1/p' < "$configfile"` |
| 53 |
do |
| 54 |
limit=`sed -n 's/^[[:space:]]*Limit[[:space:]][[:space:]]*'"$i"'[[:space:]][[:space:]]*\([^[:space:]]*\)[[:space:]]*$/\1/p' < "$configfile"` |
| 55 |
if db_set "cvsd/limit_$i" "$limit" |
| 56 |
then |
| 57 |
if [ -n "$limits" ] |
| 58 |
then |
| 59 |
limits="$limits, $i" |
| 60 |
else |
| 61 |
limits="$i" |
| 62 |
fi |
| 63 |
fi |
| 64 |
done |
| 65 |
db_set cvsd/limits "$limits" |
| 66 |
|
| 67 |
fi |
| 68 |
|
| 69 |
state="general" |
| 70 |
while [ "$state" != "done" ] |
| 71 |
do |
| 72 |
case "$state" in |
| 73 |
general) |
| 74 |
|
| 75 |
# Location of Chroot jail |
| 76 |
db_input medium cvsd/rootjail || true |
| 77 |
|
| 78 |
# Maximum number of connections |
| 79 |
db_input low cvsd/maxconnections || true |
| 80 |
|
| 81 |
# Nice value to run at |
| 82 |
db_input low cvsd/nice || true |
| 83 |
|
| 84 |
# Umask to use |
| 85 |
db_input low cvsd/umask || true |
| 86 |
|
| 87 |
# Address-Port combinations to listen on |
| 88 |
db_input low cvsd/listen || true |
| 89 |
|
| 90 |
state="repositories" |
| 91 |
db_go || exit 1 |
| 92 |
|
| 93 |
# TODO: add error checking on options (especially listen) |
| 94 |
|
| 95 |
;; |
| 96 |
repositories) |
| 97 |
|
| 98 |
# Repositories to have |
| 99 |
db_get cvsd/rootjail |
| 100 |
[ "$RET" = "/" ] || [ "$RET" = "none" ] && RET="" |
| 101 |
db_subst cvsd/repositories rootjail "$RET" |
| 102 |
db_input high cvsd/repositories || true |
| 103 |
|
| 104 |
state="whichlimits" |
| 105 |
db_go || state="general" |
| 106 |
|
| 107 |
;; |
| 108 |
whichlimits) |
| 109 |
|
| 110 |
# Limits on cvs command |
| 111 |
db_capb multiselect |
| 112 |
db_input low cvsd/limits || true |
| 113 |
|
| 114 |
state="limitlist" |
| 115 |
db_go || state="repositories" |
| 116 |
|
| 117 |
;; |
| 118 |
limitlist) |
| 119 |
|
| 120 |
# ask specific limits questions |
| 121 |
db_get cvsd/limits |
| 122 |
for i in `echo $RET | sed 's/,//g'` |
| 123 |
do |
| 124 |
db_input low "cvsd/limit_$i" || true |
| 125 |
done |
| 126 |
|
| 127 |
state="done" |
| 128 |
db_go || state="whichlimits" |
| 129 |
|
| 130 |
;; |
| 131 |
esac |
| 132 |
done |
| 133 |
|
| 134 |
exit 0 |