Rename /usr/share/amnesia to /usr/share/tails.
[tails.git] / config / chroot_local-includes / lib / live / config / 0000-readahead
blob536c34a89a022ad3db8a3aaaed5ca987f2e2b1f3
1 #!/bin/sh
3 READAHEAD_LIST="/usr/share/tails/readahead-list"
4 BACKGROUND_AT="^usr/bin/Xorg$"
6 Readahead ()
9 # Do not readahead when "profile" appears on kernel command line
10 if grep -qw "profile" /proc/cmdline
11 then
12 return 0
15 if ! test -e "$READAHEAD_LIST"
16 then
17 echo "the readahead list (${READAHEAD}) does not exist."
18 return
21 echo " readahead"
22 Start_readahead
25 Start_readahead ()
27 FG_FILES="sed -n -e \\:$BACKGROUND_AT:q;p $READAHEAD_LIST"
28 BG_FILES="sed -n -e \\:$BACKGROUND_AT:,\$p $READAHEAD_LIST"
29 FG_SIZE=$(
30 cd /
31 $FG_FILES |
32 xargs du -bc 2>/dev/null |
33 awk '$2 ~ /^total$/ { t = t + $1 } END { print t }')
34 (cd /
35 $BG_FILES |
36 xargs stat >/dev/null 2>/dev/null || :)
37 (cd /
38 $FG_FILES |
39 xargs cat 2>/dev/null |
40 pv -f -s ${FG_SIZE} >/dev/null || :)
41 (cd /
42 start-stop-daemon \
43 --start --background --make-pidfile --startas /bin/sh \
44 --pidfile /run/background-readahead.pid -- \
45 -c "$BG_FILES | xargs cat >/dev/null 2>&1")
47 # Creating state file
48 touch /var/lib/live/config/readahead
51 Readahead