mirror of
https://github.com/Ponce/slackbuilds
synced 2024-11-29 13:00:32 +01:00
62 lines
1 KiB
Bash
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/preload.lock ]; then
|
|
echo "Starting preload daemon: /usr/sbin/preload "
|
|
/usr/sbin/preload $PRELOAD_OPTS && \
|
|
touch /var/run/preload/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/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
|
|
|