blob: b29fafa0eb66ef9c22b3f080b1c6a3cd5e875f0c (
plain)
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
|
#!/bin/sh
#
# /usr/local/etc/rc.d/change_splash.sh * mato [11-feb-2006]
#
# PROVIDE: change_splash
# REQUIRE: mountcritremote
#
# Boot Splash Image Changer * martinko [09-feb-2006]
#
# Add the following to /etc/rc.conf[.local] to enable this service:
#
# splash_changer_enable="YES"
# splash_changer_dir (string): Defaults to "%%DATADIR%%".
# Splash image file is randomly picked up from this directory.
# splash_changer_file (string): Defaults to "/boot/splash".
# This is where the image file is copied to.
#
. %%RC_SUBR%%
name=change_splash
rcvar=`set_rcvar splash_changer`
start_cmd=${name}_start
: ${splash_changer_enable="NO"}
: ${splash_changer_file="/boot/splash"}
: ${splash_changer_dir="%%DATADIR%%"}
change_splash_start()
{
echo "Changing splash image."
local splash_file splash_dir
local fcount random choice select filename
splash_file="${splash_changer_file-"/boot/splash"}"
splash_dir="${splash_changer_dir-"%%DATADIR%%"}"
[ -f "$splash_file" -o ! -e "$splash_file" ] || err 1 "$splash_file is not a file"
[ -d "$splash_dir" ] || err 2 "$splash_dir is not a directory"
if [ "$splash_dir" = "${splash_file%/*}" ]
then
fcount="`ls -1 "$splash_dir" | grep -v "^${splash_file##*/}$" | wc -l`"
else
fcount="`ls -1 "$splash_dir" | wc -l`"
fi
random="`od -A n -D -N 1 < /dev/random`"
choice="`expr $random % $fcount`"
select=0
[ -z "$choice" ] && err 3 "choice failed"
for filename in "$splash_dir"/*
do
if [ $select -eq $choice ]
then
cp -f "$filename" "$splash_file"
break
fi
select="`expr $select + 1`"
done
debug "Boot splash image changed to $filename"
}
load_rc_config $name
run_rc_command "$1"
# done
|