#!/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" "$@"