Created
January 16, 2011 03:41
-
-
Save kig/781535 to your computer and use it in GitHub Desktop.
Filesystem prefetch init.d script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
### BEGIN INIT INFO | |
# Provides: usr-prefetch | |
# Required-Start: $remote_fs | |
# Required-Stop: $remote_fs | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Prefetch system files to page cache. | |
# Description: Prefetches files under /opt, /usr and /etc, and the FS entries for /. | |
### END INIT INFO | |
FULL_PREFETCH_PATHS="/usr /opt /usr/sbin /usr/lib /usr/bin /sbin /lib /bin /etc" | |
ENTRY_PREFETCH_PATHS="/usr /" | |
prefetch_full() { | |
find $1 -type f -mount -print0 -readable 2>/dev/null | xargs -0 -L 200 cat >/dev/null | |
} | |
prefetch_entries() { | |
find $1 -type f -mount -print0 -readable 2>/dev/null >/dev/null | |
} | |
prefetch() { | |
for f in $FULL_PREFETCH_PATHS | |
do | |
prefetch_full $f | |
done | |
for f in $ENTRY_PREFETCH_PATHS | |
do | |
prefetch_entries $f | |
done | |
} | |
case "$1" in | |
start) | |
prefetch & | |
;; | |
stop) | |
;; | |
restart|force-reload) | |
prefetch & | |
;; | |
*) | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment