diff options
author | Alex Xu (Hello71) <alex_y_xu@yahoo.ca> | 2020-04-04 20:23:21 -0400 |
---|---|---|
committer | Alex Xu (Hello71) <alex_y_xu@yahoo.ca> | 2020-04-04 20:23:21 -0400 |
commit | 5db227b05ba316713d6793e728b21366e8337721 (patch) | |
tree | 8001f1fba5ec3c1fa37ad1aa6c55fe748880823a /nureadahead-init | |
download | nureadahead-5db227b05ba316713d6793e728b21366e8337721.tar.xz nureadahead-5db227b05ba316713d6793e728b21366e8337721.zip |
Diffstat (limited to 'nureadahead-init')
-rwxr-xr-x | nureadahead-init | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/nureadahead-init b/nureadahead-init new file mode 100755 index 0000000..f8b315b --- /dev/null +++ b/nureadahead-init @@ -0,0 +1,30 @@ +#!/bin/sh + +usage() { + echo "usage: nureadahead-init [FILE [TIMEOUT [INIT [ARGS...]]]]" >&2 +} + +case "$1" in + -*) usage; exit 1 +esac + +case "$#" in + 0) file=/.nureadahead timeout=120 init=init;; + 1) file=$1 timeout=120 init=init; shift 1;; + 2) file=$1 timeout=$2 init=init; shift 2;; + *) file=$1 timeout=$2 init=$3; shift 3;; +esac + +export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" +device=$(awk '$2 == "/" { d=$1 } END { print d }' < /proc/self/mounts) +if [ -n "$device" ]; then + if [ -e "$file" ]; then + nureadahead-preload "$device" < "$file" & + else + echo "nureadahead-init: no file, skipping preload" >&2 + fi + nureadahead-collect "$device" "$timeout" > "$file" & +else + echo "nureadahead-init: cannot find root device, skipping preload + collect" >&2 +fi +exec "$init" "$@" |