55# License: This file is licensed under the GPL v2.
66# ###############################################################################
77
8- # {{{ set default PATH
9- setpath (){
10- export PATH=${PATH:- ' /bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin' }
11- }
12- # }}}
13-
148# {{{ check for root-permissions
159check4root (){
1610 if [ " $( id -u 2> /dev/null) " != 0 ] ; then
@@ -19,34 +13,6 @@ check4root(){
1913}
2014# }}}
2115
22- # {{{ check for user permissions
23- check4user (){
24- if [ " $( id -u 2> /dev/null) " = 0 ] ; then
25- echo 1>&2 " Error: please do not run this script with uid 0 (root)." ; return 1
26- fi
27- }
28- # }}}
29-
30- # {{{ check for running zsh
31- iszsh (){
32- if ! [ -z " $ZSH_VERSION " ] ; then
33- return 0
34- else
35- return 1
36- fi
37- }
38- # }}}
39-
40- # {{{ check for (X)dialog
41- setdialog (){
42- if [ -n " $DISPLAY " ] ; then
43- [ -x /usr/bin/Xdialog ] && DIALOG=" Xdialog" && export XDIALOG_HIGH_DIALOG_COMPAT=1
44- else
45- [ -x /usr/bin/dialog ] && DIALOG=' dialog' || ( echo 1>&2 " dialog not available" ; return 1 )
46- fi
47- }
48- # }}}
49-
5016# {{{ check for availability of program(s)
5117# usage example:
5218# check4progs [-s,-q,--quiet,--silent] arg [arg .... argn]
@@ -137,96 +103,15 @@ checkbootparam(){
137103}
138104# }}}
139105
140- # {{{ check whether $1 is yes
141- checkvalue (){
142- if [ " $1 " = " yes" -o " $1 " = " YES" ] ; then
143- return 0
144- else
145- return 1
146- fi
147- }
148- # }}}
149-
150106# {{{ grml specific checks
151107isgrml (){
152108 [ -f /etc/grml_version ] && return 0 || return 1
153109}
154110
155- grmlversion (){
156- cat /etc/grml_version
157- }
158-
159111isgrmlcd (){
160112 [ -f /etc/grml_cd ] && return 0 || return 1
161113}
162-
163- isgrmlhd (){
164- [ -f /etc/grml_cd ] && return 1 || return 0
165- }
166-
167- checkgrmlsmall (){
168- grep -q small /etc/grml_version 2> /dev/null && return 0 || return 1
169- }
170114# }}}
171115
172- # {{{ filesystems (proc, pts, sys)
173- mount_proc (){
174- check4root || return 1
175- [ -f /proc/version ] || mount -t proc /proc /proc 2> /dev/null
176- }
177-
178- mount_pts (){
179- check4root || return 1
180- stringinfile " /dev/pts" /proc/mounts || mount -t devpts /dev/pts /dev/pts 2> /dev/null
181- }
182-
183- mount_sys (){
184- check4root || return 1
185- [ -d /sys/devices ] || mount -t sysfs /sys /sys 2> /dev/null
186- }
187- # }}}
188-
189- # char *reverse_list(list) {{{
190- #
191- # Returns the reversed order of list
192- #
193- reverse_list () {
194- local ret
195- ret=' '
196- while [ " $# " -gt 0 ] ; do
197- if [ -z " ${ret} " ] ; then
198- ret=" $1 "
199- else
200- ret=" $1 ${ret} "
201- fi
202- shift
203- done
204- printf ' %s' " ${ret} "
205- }
206- # }}}
207-
208- # bool is_older_than(reference, files/dirs to check) {{{
209- #
210- # return 0 if any of the files/dirs are newer than
211- # the reference file
212- #
213- # EXAMPLE: if is_older_than a.out *.o ; then ...
214- is_older_than () {
215- local x
216- local ref=" $1 "
217- shift
218-
219- for x in " $@ " ; do
220- [ " ${x} " -nt " ${ref} " ] && return 0
221-
222- if [ -d " ${x} " ] ; then
223- is_older_than " ${ref} " " ${x} " /* && return 0
224- fi
225- done
226-
227- return 1
228- }
229- # }}}
230-
231116# # END OF FILE #################################################################
232117# vim:foldmethod=marker tw=80 ai expandtab shiftwidth=2 tabstop=8 ft=sh
0 commit comments