From 5db227b05ba316713d6793e728b21366e8337721 Mon Sep 17 00:00:00 2001 From: "Alex Xu (Hello71)" Date: Sat, 4 Apr 2020 20:23:21 -0400 Subject: Initial commit --- nureadahead-init | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 nureadahead-init (limited to 'nureadahead-init') 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" "$@" -- cgit v1.2.3-70-g09d2