slackbuilds_ponce/system/preload/rc.preload
Robby Workman 2aaa31261b system/preload: Miscellaneous cleanups and fixes
Signed-off-by: Robby Workman <rworkman@slackbuilds.org>
2012-09-07 15:32:57 -05: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/run/preload.lock ]; then
echo "Starting preload daemon: /usr/sbin/preload "
/usr/sbin/preload $PRELOAD_OPTS && \
touch /var/run/preload.lock
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/run/preload.lock
}
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