-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfbs
executable file
·152 lines (123 loc) · 3.14 KB
/
fbs
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/sh
#
# Fbs - Graphical framebuffer boot using Busybox fbsplash applet. No use of SliTaz
# specific code since it may be used by other distros or emb systems.
#
# (C) 2014 Christophe Lincoln - BSD License.
#
sysconf="/etc/fbs.conf"
themes="/usr/share/fbs"
fifo="/fbs.fifo"
[ -f "${sysconf}" ] && . ${sysconf}
[ -f "fbs.conf" ] && . fbs.conf
[ "$2" ] && FBTHEME="$2"
# Functions
boldify() {
echo -e "\033[1m$@\033[0m"
}
usage() {
cat << EOT
Framebuffer Boot Splash utility
$(boldify "Usage:") $(basename $0) [command] [theme]
$(boldify "Commands:")
on Enable graphical boot
off Disable graphical boot
test Test a splash theme
themes List all installed themes
set-theme Change current theme
pack-theme Pack a system theme
add-theme Install a fbs-theme archive
EOT
}
check_root() {
if [ $(id -u) != "0" ]; then
echo "Only root administrator can run fbs $1" && exit 1
fi
}
separator() {
echo "--------------------------------------"
}
set_theme() {
sed -i s'~FBTHEME=.*~FBTHEME=\"$new_theme\"~' /etc/fbs.conf
}
start_fbsplash() {
[ -x "$themes/$FBTHEME/init.sh" ] && \
${themes}/${FBTHEME}/init.sh
mkfifo ${fifo}
fbsplash -c -f ${fifo} \
-s $themes/$FBTHEME/splash.ppm.gz \
-i $themes/$FBTHEME/splash.cfg &
}
# Commands
case "$1" in
on)
# Enable graphical boot
check_root
echo "Enabling SliTaz graphical boot..."
if ! grep -q "rcS > /dev/null 2>/dev/null" /etc/inittab; then
sed -i s'#rcS#rcS >/dev/null 2>/dev/null#' /etc/inittab
fi
sed -i s'/FBSPLASH=.*/FBSPLASH="on"/' /etc/fbs.conf ;;
off)
# Disable graphical boot
check_root
echo "Disabling SliTaz graphical boot..."
sed -i s'#rcS >/dev/null 2>/dev/null#rcS#' /etc/inittab
sed -i s'/FBSPLASH=.*/FBSPLASH="off"/' /etc/fbs.conf ;;
'test')
# Testsuite for fbs
reset && start_fbsplash
for p in 0 10 20 30 40 50 60 70 80 90 100
do
echo "$p" > ${fifo} && sleep 1
done #> /dev/null
echo "exit" > ${fifo}
clear && rm -f ${fifo};;
themes)
# List all themes
echo ""
boldify "Fbs themes list"
separator
cd ${themes}
ls -1 && echo "" ;;
set-theme)
check_root
new_theme="$2"
[ "$new_theme" ] || exit 0
[ -d "$themes/$new_theme" ] || exit 0
echo -n "Enabling fbs theme: $new_theme"
set_theme; status ;;
pack-theme)
# Pack a theme into .tar.gz
theme="$2"
tmp=fbs-theme-$theme
if [ ! -d "$themes/$theme" ]; then
echo "No theme found in: $themes/$theme"; exit 0
fi
echo -n "Creating fbs theme archive: $theme"
mkdir -p $tmp
cp -r $themes/$theme $tmp
cat > $tmp/README << EOT
Fbs theme - Framebuffer Splash boot artwork
$(separator)
This is a Busybox fbsplash theme created by $USER. To use it you can copy
files manually to $themes or use 'fbs add-theme'
$(separator)
EOT
busybox tar czf fbs-theme-$theme.tar.gz $tmp
rm -rf $tmp; status ;;
add-theme)
check_root
file=$2
if [ ! -f "$file" ]; then
echo "Missing theme archive: $file"; exit 0
fi
echo -n "Installing fbs theme: ${file%.tar.gz}"
tar xzf $file -C /tmp
rm /tmp/fbs-theme-*/README
cp -r /tmp/fbs-*/* ${themes}
status ;;
start) start_fbsplash ;;
*) usage ;;
esac
exit 0