-
Notifications
You must be signed in to change notification settings - Fork 8
/
sleep.sh
82 lines (67 loc) · 1.24 KB
/
sleep.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/sh
#
# initramfs hook for blocking boot procedure for a specific time
# by simon <simon.codingmonkey@googlemail.com>
#
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
error_exit()
{
echo "[ERROR] $1"
exit 1
}
case $1 in
prereqs)
prereqs
exit 0
;;
esac
. /usr/share/initramfs-tools/hook-functions
echo "> Including sleep.sh into initramfs"
cat >${DESTDIR}/scripts/local-top/sleep << 'EOF'
#!/bin/sh
TIMER=300
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
prereqs)
prereqs
exit 0
;;
esac
for cmd in $( cat /proc/cmdline )
do
if ( echo "$cmd" | grep -q "initramfs-sleep=" )
then
sleeptime=$( echo "$cmd" | cut -f'2' -d'=' | sed 's|[^0-9]||g' )
if [ -n "$sleeptime" ]
then
TIMER=$sleeptime
fi
fi
done
i=0
j=0
echo "Starting initramfs sleep for $TIMER seconds..."
while [ $i -lt $TIMER ]
do
i=$(( $i + 1 ))
j=$(( $j + 1 ))
sleep 1
if [ $j -eq 10 ]
then
j=0
echo "Sleept $i seconds. Continue Booting in $(( $TIMER - $i )) seconds."
fi
done
echo "Continue Booting after initramfs sleep."
EOF
chmod 700 ${DESTDIR}/scripts/local-top/sleep
echo "> Including sleep.sh into initramfs - SUCCESSFUL"
exit 0