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
|
#!/bin/sh
set -e
. /usr/share/debconf/confmodule
CONFFILE=/etc/default/oftpd
LOGFILE=/var/log/oftpd.log
TMPFILE=$(tempfile)
#DEBHELPER#
update_value() {
if [ -e "$CONFFILE" ]; then
if [ $(grep -c "$1" "$CONFFILE") = "0" ]; then
echo "$1=\"$2\"" >> $CONFFILE
else
TMPVAL=$(echo $2 | sed -e "s/\\//\\\\\\//g")
sed -e "s/$1=.*/$1=\"$TMPVAL\"/" < $CONFFILE > $TMPFILE
mv -f $TMPFILE $CONFFILE
fi
else
echo "$1=\"$2\"" >> $TMPFILE
fi
}
if [ "$1" = "configure" ]; then
update-inetd --disable ftp || true
update-rc.d oftpd defaults > /dev/null 2>/dev/null
/etc/init.d/oftpd stop
# . $CONFFILE
db_get oftpd/enable_oftpd
if [ "$RET" = "true" ]; then
update_value "ENABLE" "yes"
db_get oftpd/which_user
if [ -z "$RET" -o "$RET" = "oftpd" ]; then
USER_TEST=$(cut -d ':' -f 1 < /etc/passwd | grep -w oftpd) || true
if [ -z "$USER_TEST" ]; then
adduser --system oftpd
fi
update_value "USER" "oftpd"
else
update_value "USER" "$RET"
fi
db_get oftpd/which_dir
if [ -z "$RET" ]; then
update_value "DIR" "/home/oftpd"
else
update_value "DIR" "$RET"
fi
db_get oftpd/which_port
if [ -n "$RET" ]; then
update_value "PORT" "$RET"
else
update_value "PORT" "21"
fi
db_get oftpd/which_iface
if [ -n "$RET" ]; then
update_value "IFACE" "$RET"
else
update_value "IFACE" "0.0.0.0"
fi
db_get oftpd/max_conn
if [ -n "$RET" ]; then
update_value "MAXCON" "$RET"
else
update_value "MAXCON" "250"
fi
else
update_value "ENABLE" "no"
db_get oftpd/which_user
update_value "USER" "$RET"
db_get oftpd/which_dir
update_value "DIR" "$RET"
fi
if [ ! -e "$CONFFILE" ]; then
mv -f $TMPFILE $CONFFILE
fi
/etc/init.d/oftpd start
fi
exit 0;
|