[oe-commits] org.oe.dev clamav 0.84: Simplify the init scripts. assume that the volatiles
lenehan commit
openembedded-commits at lists.openembedded.org
Thu Oct 5 08:08:22 UTC 2006
clamav 0.84: Simplify the init scripts. assume that the volatiles
processing takes care of the required directories and permissions in
/var, don't try and create the home directories when adding the clamav user.
Author: lenehan at openembedded.org
Branch: org.openembedded.dev
Revision: f4ab4afc501a0be0908b8d9ea6386912f700a472
ViewMTN: http://monotone.openembedded.org/revision.psp?id=f4ab4afc501a0be0908b8d9ea6386912f700a472
Files:
1
packages/clamav/clamav_0.88.4.bb
packages/clamav/files/clamav-daemon.init
packages/clamav/files/clamav-freshclam.init
Diffs:
#
# mt diff -r9be6b44e77d5700f176e18553c62b41c1f894dc3 -rf4ab4afc501a0be0908b8d9ea6386912f700a472
#
#
#
# patch "packages/clamav/clamav_0.88.4.bb"
# from [293c33440cbc35ab0321eeed632ee7aee546014c]
# to [babeb6cbef4f2add07b1f36379e7643b44293a1d]
#
# patch "packages/clamav/files/clamav-daemon.init"
# from [62f53aca65c208720a815d94759c81281506ebb5]
# to [7d3ea484a1b781569e72e1f8778b1b4b141ae28e]
#
# patch "packages/clamav/files/clamav-freshclam.init"
# from [6367e251c725e4f5fb4d2d48c64fbf621ddf3ffb]
# to [d5a01b7f9ff51cb306cd6cad857d3ac7d7d8f465]
#
============================================================
--- packages/clamav/clamav_0.88.4.bb 293c33440cbc35ab0321eeed632ee7aee546014c
+++ packages/clamav/clamav_0.88.4.bb babeb6cbef4f2add07b1f36379e7643b44293a1d
@@ -16,7 +16,7 @@ RRECOMMENDS_${PN}-daemon = "${PN}-freshc
RDEPENDS_${PN}-daemon = "${PN}-data"
RRECOMMENDS_${PN} = "${PN}-freshclam"
RRECOMMENDS_${PN}-daemon = "${PN}-freshclam"
-PR = "r3"
+PR = "r4"
SRC_URI = "${SOURCEFORGE_MIRROR}/clamav/clamav-${PV}.tar.gz \
file://cross-compile-fix.patch;patch=1 \
@@ -91,20 +91,23 @@ pkg_postinst_${PN}-freshclam () {
# Add clamav's user and groups
pkg_postinst_${PN}-freshclam () {
grep -q clamav: /etc/group || addgroup clamav
- grep -q clamav: /etc/passwd || adduser --disabled-password --home=/var/lib/clamav/ \
- --ingroup clamav -g "ClamAV" clamav
+ grep -q clamav: /etc/passwd || \
+ adduser --disabled-password --home=/var/lib/clamav/ --system \
+ --ingroup clamav --no-create-home -g "ClamAV" clamav
/etc/init.d/populate-volatile.sh
}
pkg_postinst_${PN}-daemon () {
grep -q clamav: /etc/group || addgroup clamav
- grep -q clamav: /etc/passwd || adduser --disabled-password --home=/var/lib/clamav/ \
- --ingroup clamav -g "ClamAV" clamav
+ grep -q clamav: /etc/passwd || \
+ adduser --disabled-password --home=/var/lib/clamav/ --system \
+ --ingroup clamav --no-create-home -g "ClamAV" clamav
/etc/init.d/populate-volatile.sh
}
pkg_postinst_${PN}-data () {
grep -q clamav: /etc/group || addgroup clamav
- grep -q clamav: /etc/passwd || adduser --disabled-password --home=/var/lib/clamav/ \
- --ingroup clamav --no-create-home -g "ClamAV" clamav
+ grep -q clamav: /etc/passwd || \
+ adduser --disabled-password --home=/var/lib/clamav/ --system \
+ --ingroup clamav --no-create-home -g "ClamAV" clamav
/etc/init.d/populate-volatile.sh
}
============================================================
--- packages/clamav/files/clamav-daemon.init 62f53aca65c208720a815d94759c81281506ebb5
+++ packages/clamav/files/clamav-daemon.init 7d3ea484a1b781569e72e1f8778b1b4b141ae28e
@@ -1,64 +1,31 @@
#! /bin/sh
-# This is a modified version of the debian clamav-daemon init script
-set -e
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/clamd
NAME="clamd"
DESC="ClamAV daemon"
CLAMAVCONF=/etc/clamd.conf
-[ -x "$DAEMON" ] || exit 0
-[ -r /etc/default/clamav-daemon ] && . /etc/default/clamav-daemon
+set -e
-if [ ! -f "$CLAMAVCONF" ]; then
- echo "There is no configuration file for $DESC."
- exit 0;
+test -r /etc/default/clamav-daemon && . /etc/default/clamav-daemon
+test -x "$DAEMON" || exit 0
+test ! -r "$CLAMAVCONF" && exit 0
+if [ `grep -q "^Example" $CLAMAVCONF` ]; then
+ echo "$DESC is not configured."
+ exit 0
fi
-if grep -q "^Example" $CLAMAVCONF; then
- echo "$DESC is not configured. Please edit $CLAMAVCONF"
- exit 0
-fi
+pidfile="`grep ^PidFile $CLAMAVCONF | awk '{print $2}'`"
-THEPIDFILE="`grep ^PidFile $CLAMAVCONF | awk '{print $2}'`"
-[ -e "$THEPIDFILE" ] && PID=`cat $THEPIDFILE`
-[ "$PID" = '1' ] && unset PID
-
-# Make sure dirs exist and are correct
-for i in /var/run/clamav /var/log/clamav /var/lib/clamav
-do
- [ ! -d $i ] && mkdir -p $i && chown clamav:clamav $i
-done
-
case "$1" in
start)
echo -n "Starting $DESC: "
start-stop-daemon --oknodo -S -x $DAEMON
- echo "$NAME"
+ echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
- if [ -n "$PID" ]; then
- kill -15 -"$PID"
- sleep 1
- if kill -0 "$PID" 2>/dev/null; then
- echo -n "Waiting . "
- cnt=0
- while kill -0 "$PID" 2>/dev/null; do
- cnt=`expr "$cnt" + 1`
- if [ "$cnt" -gt 60 ]; then
- echo -n " Failed.. "
- kill -9 -"$PID"
- break
- fi
- sleep 2
- echo -n ". "
- done
- fi
- else
- start-stop-daemon -o -K -q -p $THEPIDFILE
- fi
- echo "$NAME"
+ start-stop-daemon -K -p $pidfile
;;
restart|force-reload)
============================================================
--- packages/clamav/files/clamav-freshclam.init 6367e251c725e4f5fb4d2d48c64fbf621ddf3ffb
+++ packages/clamav/files/clamav-freshclam.init d5a01b7f9ff51cb306cd6cad857d3ac7d7d8f465
@@ -1,15 +1,17 @@
#!/bin/sh
-# This is a modified version of the debian clamav-freshclam init script
-set -e
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/freshclam
NAME=freshclam
DESC="ClamAV virus database updater"
+CLAMAV_CONF_FILE=/etc/clamd.conf
+FRESHCLAM_CONF_FILE=/etc/freshclam.conf
+pidfile=/var/run/clamav/freshclam.pid
-[ -x $DAEMON ] || exit 0
+set -e
-CLAMAV_CONF_FILE=/etc/clamd.conf
-FRESHCLAM_CONF_FILE=/etc/freshclam.conf
-PIDFILE=/var/run/clamav/freshclam.pid
+test -r /etc/default/clamav-freshclam && . /etc/default/clamav-freshclam
+test -x "$DAEMON" || exit 0
+test ! -r "$CLAMAV_CONF_FILE" && exit 0
slurp_config()
{
@@ -40,51 +42,8 @@ slurp_config()
fi
}
-
slurp_config "$FRESHCLAM_CONF_FILE"
-for inet in $INTERFACE; do
- if route | grep -q "$inet"; then
- IS_UP=true
- break
- else
- IS_UP=false
- fi
-done
-for inet in $INTERFACE; do
- if [ "$inet" = "$IFACE" ]; then
- match=true
- break
- else
- match=false
- fi
-done
-
-# We don't want to always start/stop if running from if-up/down.d
-if ! [ "$1" = "start" -o "$1" = "stop" ]; then # Exempt restart/reload/etc from checks
- if [ -n "$INTERFACE" ]; then # Want it only run from if-up.d
- if [ -z "$IFACE" ]; then # Is not called by if-up.d
- if [ "$IS_UP" = false ]; then # And route isn't up (e.g., upgrade)
- echo "Interface not up. Exiting."
- exit 0
- fi
- elif [ "$match" != 'true' ]; then # IFACE coming up is not the one selected
- echo "Interface not up. Exiting."
- exit 0
- fi
- fi
-fi
-
-# If user wants it run from cron, we only accept no-daemon and stop
-if [ -f /etc/cron.d/clamav-freshclam ]; then
- if ! [ "$1" = "no-daemon" -o "$1" = "stop" ]; then
- echo "Cron option has been selected for running freshclam"
- echo "Please either run freshclam directly, or run the init"
- echo "script with the 'no-daemon' option"
- exit 0
- fi
-fi
-
[ -z "$UpdateLogFile" ] && UpdateLogFile=/var/log/clamav/freshclam.log
if [ -z "$DatabaseDirectory" ]; then
@@ -92,54 +51,33 @@ fi
[ -z "$DatabaseDirectory" ] && DatabaseDirectory=/var/lib/clamav/
fi
-[ -e "$PIDFILE" ] && PID=`cat $PIDFILE`
-[ "$PID" = '1' ] && unset PID
-# Make sure dirs exist and are correct
-for i in /var/run/clamav /var/log/clamav $DatabaseDirectory
-do
- [ ! -d $i ] && mkdir -p $i && chown clamav:clamav $i
-done
-
case "$1" in
no-daemon)
- echo "It takes freshclam ~3min to timeout and try the next mirror in the list"
- freshclam -l "$UpdateLogFile" --datadir "$DatabaseDirectory"
- ;;
+ echo "It takes freshclam ~3min to timeout and try the next mirror in the list"
+ freshclam -l "$UpdateLogFile" --datadir "$DatabaseDirectory"
+ ;;
+
start)
- echo -n "Starting $DESC: "
- start-stop-daemon -S -x $DAEMON -- -d --quiet -p $PIDFILE
- echo "$NAME"
- ;;
+ echo -n "Starting $DESC: "
+ start-stop-daemon -S -x $DAEMON -- -d --quiet -p $pidfile
+ echo "$NAME."
+ ;;
+
stop)
- echo -n "Stopping $DESC: "
- start-stop-daemon -o -K -q -p $PIDFILE $DAEMON
- if [ -n "$PID" ]; then
- sleep 1
- if kill -0 "$PID" 2>/dev/null; then
- echo -n "Waiting . "
- cnt=0
- while kill -0 "$PID" 2>/dev/null; do
- cnt=`expr "$cnt" + 1`
- if [ "$cnt" -gt 60 ]; then
- echo -n " Failed.. "
- break
- fi
- sleep 2
- echo -n ". "
- done
- fi
- fi
- echo "$NAME"
- ;;
+ echo -n "Stopping $DESC: "
+ start-stop-daemon -K -p $pidfile
+ ;;
+
restart|force-reload)
- $0 stop
- $0 start
- ;;
+ $0 stop
+ $0 start
+ ;;
+
*)
- echo "Usage: $0 {no-daemon|start|stop|restart|force-reload}" >&2
- exit 1
- ;;
+ echo "Usage: $0 {no-daemon|start|stop|restart|force-reload}" >&2
+ exit 1
+ ;;
esac
exit 0
More information about the Openembedded-commits
mailing list