diff options
Diffstat (limited to 'system/preload/rc.preload')
-rw-r--r-- | system/preload/rc.preload | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/system/preload/rc.preload b/system/preload/rc.preload new file mode 100644 index 0000000000..73f6e0e838 --- /dev/null +++ b/system/preload/rc.preload @@ -0,0 +1,62 @@ +#!/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 + |