summaryrefslogtreecommitdiff
path: root/system/preload/rc.preload
diff options
context:
space:
mode:
authorRobby Workman <rw@rlworkman.net>2010-05-11 20:02:06 +0200
committerDavid Somero <xgizzmo@slackbuilds.org>2010-05-11 20:02:06 +0200
commit90500bd86f52dcc9d4bbe26e150d647175675f81 (patch)
tree9fd3b325533b90aaaeb1c874fc72eab95297b077 /system/preload/rc.preload
parent96025eb035a7f510c30a01b923d644ae56479bc7 (diff)
downloadslackbuilds-90500bd86f52dcc9d4bbe26e150d647175675f81.tar.gz
system/preload: Added to 12.0 repository
Diffstat (limited to 'system/preload/rc.preload')
-rw-r--r--system/preload/rc.preload62
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
+