Magellan Linux

Contents of /mcore-src/trunk/mcore-tools/daemon/client/include/boot.client.class

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2078 - (show annotations) (download)
Fri May 10 11:02:36 2013 UTC (10 years, 11 months ago) by niro
File size: 4624 byte(s)
-improved MROOT support
1 # $Id$
2
3 provide basic-boot
4
5 helper_boot_rebuild_bootconfig()
6 {
7 local grubconf="/boot/grub/grub.cfg"
8
9 mount /boot &> /dev/null
10 grub-mkconfig -o ${grubconf}
11 umount /boot &> /dev/null
12 }
13
14 help_boot_splash()
15 {
16 mecho "get boot.splash"
17 mecho " Shows the state of bootsplash"
18 mecho
19 mecho "set boot.splash [action]"
20 mecho " Enables or disables a fancy splashscreen at boot time."
21 mecho " Available actions:"
22 mecho " enable - enables bootsplash"
23 mecho " disable - disables bootsplash"
24 }
25
26 helper_get_boot_splash_plymouth()
27 {
28 if grep "^export GRUB_CMDLINE_BOOTSPLASH=.*splash" ${MROOT}/etc/conf.d/grub
29 then
30 mecho "bootsplash currently enabled"
31 rvecho "1"
32 else
33 mecho "bootsplash currently disabled"
34 rvecho "0"
35 fi
36 }
37
38 helper_get_boot_splash_fbsplash()
39 {
40 local var
41 var=$(grep "^export GRUB_CMDLINE_BOOTSPLASH=" ${MROOT}/etc/conf.d/grub | sed "s:.*splash=\(.*\),.*:\1:")
42
43 case "${var}" in
44 silent|"") mecho "bootsplash currently enabled"; rvecho "1" ;;
45 verbose) mecho "bootsplash currently disabled"; rvecho "0" ;;
46 *) eecho "unkown state" ;;
47 esac
48 }
49
50 get_boot_splash()
51 {
52 if [ -x $(type -P plymouth-set-default-theme) ]
53 then
54 helper_get_boot_splash_plymouth $*
55 else
56 helper_get_boot_splash_fbsplash $*
57 fi
58 }
59
60 helper_set_boot_splash_plymouth()
61 {
62 local action="$1"
63 [[ -z ${action} ]] && help_boot_splash && return 1
64
65 case "${action}" in
66 enable)
67 sed -i "s:^\(export GRUB_CMDLINE_BOOTSPLASH=\).*:\1\"splash\":" ${MROOT}/etc/conf.d/grub
68 helper_boot_rebuild_bootconfig
69 mecho "bootsplash enabled"
70 ;;
71 disable)
72 sed -i "s:^\(export GRUB_CMDLINE_BOOTSPLASH=\).*:\1\"rd.plymouth=0\":" ${MROOT}/etc/conf.d/grub
73 helper_boot_rebuild_bootconfig
74 mecho "bootsplash disabled"
75 ;;
76 *) help_system_autologon && return 1 ;;
77 esac
78 }
79
80 helper_set_boot_splash_fbsplash()
81 {
82 local action="$1"
83 [[ -z ${action} ]] && help_boot_splash && return 1
84
85 case "${action}" in
86 enable)
87 sed -i "s:^\(export GRUB_CMDLINE_BOOTSPLASH=\).*:\1\"splash=silent,theme=default\":" ${MROOT}/etc/conf.d/grub
88 helper_boot_rebuild_bootconfig
89 mecho "bootsplash enabled"
90 ;;
91 disable)
92 sed -i "s:^\(export GRUB_CMDLINE_BOOTSPLASH=\).*:\1\"splash=verbose,theme=default\":" ${MROOT}/etc/conf.d/grub
93 helper_boot_rebuild_bootconfig
94 mecho "bootsplash disabled"
95 ;;
96 *) help_system_autologon && return 1 ;;
97 esac
98 }
99
100 set_boot_splash()
101 {
102 if [ -x $(type -P plymouthd) ]
103 then
104 helper_set_boot_splash_plymouth $*
105 else
106 helper_set_boot_splash_fbsplash $*
107 fi
108 }
109
110 help_boot_theme()
111 {
112 mecho "get boot.theme [action]"
113 mecho " Shows current selected or system-wide available bootsplash themes."
114 mecho " Available actions:"
115 mecho " system - shows available themes on the system"
116 mecho " current - shows the currently used theme of bootsplash"
117 mecho
118 mecho "set boot.theme [theme]"
119 mecho " Selects the theme which will be used on system startup by bootsplash."
120 }
121
122 helper_get_boot_theme_plymouth()
123 {
124 local action="$1"
125 local i
126
127 case "${action}" in
128 current) rvecho "$(plymouth-set-default-theme)" ;;
129 system)
130 for i in $(plymouth-set-default-theme --list)
131 do
132 rvecho "${i}"
133 done
134 ;;
135 *)
136 help_boot_theme
137 return 1
138 ;;
139 esac
140 }
141
142 helper_get_boot_theme_fbsplash()
143 {
144 local action="$1"
145 local themedir="${MROOT}/etc/splash/themes"
146 local theme
147 local i
148
149 case "${action}" in
150 current)
151 if [[ -L ${themedir}/default ]]
152 then
153 theme=$(readlink ${themedir}/default)
154 rvecho "${theme}"
155 else
156 rvecho "none"
157 fi
158 ;;
159 system)
160 list_files_in_directory -type d -mindepth 1 -maxdepth 1 ${themedir}
161 ;;
162 *)
163 help_boot_theme
164 return 1
165 ;;
166 esac
167 }
168
169 get_boot_theme()
170 {
171 if [ -x $(type -P plymouth-set-default-theme) ]
172 then
173 helper_get_boot_theme_plymouth $*
174 else
175 helper_get_boot_theme_fbsplash $*
176 fi
177 }
178
179 helper_set_boot_theme_plymouth()
180 {
181 local theme="$1"
182 local themedir="${MROOT}/usr/share/plymouth/themes"
183 [[ -z ${theme} ]] && help_boot_theme && return 1
184
185 if [[ -d ${themedir}/${theme} ]]
186 then
187 plymouth-set-default-theme ${theme}
188 mecho "Selected theme '${theme}'."
189 else
190 eecho "Theme '${theme}' not available on this system. Aborted!"
191 fi
192 }
193
194 helper_set_boot_theme_fbsplash()
195 {
196 local theme="$1"
197 local themedir="${MROOT}/etc/splash/themes"
198 [[ -z ${theme} ]] && help_boot_theme && return 1
199
200 if [[ -d ${themedir}/${theme} ]]
201 then
202 ln -snf ${theme} ${themedir}/default
203 mecho "Selected theme '${theme}'."
204 else
205 eecho "Theme '${theme}' not available on this system. Aborted!"
206 fi
207 }
208
209 set_boot_theme()
210 {
211 if [ -x $(plymouth-set-default-theme) ]
212 then
213 helper_set_boot_theme_plymouth $*
214 else
215 helper_set_boot_theme_fbsplash $*
216 fi
217 }