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
|
check_ucf()
{
if ucf -h 2>&1 | grep -q debconf-ok; then
echo ok
else
echo notok
fi
}
ucf_cleanup()
{
# This only does something if I've fucked up before
# Not entirely impossible :(
configfile=$1
if [ `grep "$configfile" /var/lib/ucf/hashfile | wc -l` -gt 1 ]; then
grep -v "$configfile" /var/lib/ucf/hashfile > /var/lib/ucf/hashfile.tmp
grep "$configfile" /var/lib/ucf/hashfile | tail -n 1 >> /var/lib/ucf/hashfile.tmp
mv /var/lib/ucf/hashfile.tmp /var/lib/ucf/hashfile
fi
}
add_to_ucf()
{
configfile=$1
ucffile=$2
if ! grep -q "$configfile" /var/lib/ucf/hashfile; then
md5sum $configfile >> /var/lib/ucf/hashfile
cp $configfile $ucffile
fi
}
ucf_upgrade_check()
{
configfile=$1
sourcefile=$2
ucffile=$3
if [ -f "$configfile" ]; then
add_to_ucf $configfile $ucffile
if [ "$UCFVER" = 'ok' ]; then
ucf --three-way --debconf-ok "$sourcefile" "$configfile"
else
ucf --three-way "$sourcefile" "$configfile" < /dev/tty
fi
else
[ -d /var/lib/ucf/cache ] || mkdir -p /var/lib/ucf/cache
cp $sourcefile $configfile
add_to_ucf $configfile $ucffile
fi
}
slurp_config()
{
CLAMAVCONF="$1"
if [ -e "$CLAMAVCONF" ]; then
for variable in `egrep -v '^[[:space:]]*(#|$)' "$CLAMAVCONF" | awk '{print $1}'`; do
if [ "$variable" = 'DatabaseMirror' ]; then
if [ -z "$DatabaseMirror" ]; then
for i in `grep ^$variable $CLAMAVCONF | awk '{print $2}'`; do
value="$i $value"
done
else
continue
fi
elif [ "$variable" = 'VirusEvent' ] || [ "$variable" = 'OnUpdateExecute' ] || [ "$variable" = 'OnErrorExecute' ]; then
value=`grep ^$variable $CLAMAVCONF | head -n1 | sed -e s/$variable\ //`
else
value=`grep ^$variable $CLAMAVCONF | head -n1 | awk '{print $2}'`
fi
if [ -z "$value" ]; then
export "$variable"="true"
elif [ "$value" != "$variable" ]; then
export "$variable"="$value"
else
export "$variable"="true"
fi
unset value
done
fi
}
|