slackbuilds_ponce/system/preload/rc.preload
2010-05-11 20:02:06 +02:00

62 lines
1 KiB
Bash

#!/bin/sh
# /etc/rc.d/rc.preload
# See preload(8) for options
PRELOAD_OPTS="-c /etc/preload.conf -s /var/lib/preload/preload.state -l /var/log/preload.log"
# You need at least 256 MB of memory for this to be useful
free -m | awk '/Mem:/ {exit ($2 >= ('256'))?0:1}' || exit 1
start() {
if [ -x /usr/sbin/preload ]; then
if [ ! -f /var/lock/subsys/preload ]; then
echo "Starting preload daemon: /usr/sbin/preload "
/usr/sbin/preload $PRELOAD_OPTS && \
touch /var/lock/subsys/preload
else
echo "/usr/sbin/preload is already running. Exiting."
exit 1
fi
else
echo "/usr/sbin/preload is either not present or not executable."
echo "Exiting."
exit 1
fi
}
stop() {
echo "Stopping preload daemon... "
killall -9 preload
rm -f /var/lock/subsys/preload
}
restart() {
stop
sleep 1
start
}
reload() {
trap "" SIGHUP
killall -HUP preload
}
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart|reload}"
exit 1
esac