3 #Copyright (c) 2001 Matthias S. Benkmann
4 #licensed under the GNU General Public License (GPL) Version 2
6 # Modified for Source Mage GNU/Linux by erics/rycee, 2004-06-30.
7 # - removed -u option and checks for root UID as all smgl scripts.
11 echo 1>&2 Usage
: telinit args
12 echo 1>&2 'telinit calls "bootprog telinit args" where bootprog is the program'
13 echo 1>&2 'specified in /etc/inittab' .
14 echo 1>&2 'e.g.: "telinit <number>" might tell bootprog to switch to runlevel <number>'
18 test -p /dev
/initctl
&& touch /dev
/initctl
2>/dev
/null
19 perm
=$?
#0 if writing to /dev/initctl is permitted
24 if [ $UID != 0 ]; then
25 echo "Enter the root password, please."
26 exec su
- -c "DISPLAY=$DISPLAY PATH=$PATH $0 $*"
29 if [ z
"$1" == z
"--" ]; then shift 1; fi
33 # sed -n s/$'^[ \r\t]*'${1}$'[ \r\t]*=*[ \r\t]*''\('$'[^ \r\t]*''\).*$/\1/p' <$INIT_ROOT/etc/inittab
35 #echo before cat to get initial newline because the regex needs it
36 expr "`echo ; cat $INIT_ROOT/etc/inittab`" : $
'.*\n[ \r\t]*'${1}$
'[ \r\t]*=*[ \r\t]*''\('$
'[^ \r\t\n]*''\).*'
40 export INIT_D
=$INIT_ROOT`get_inittab_entry fileprefix`
41 bootprog
=`get_inittab_entry bootprog`
42 export PATH
=$PRE_PATH`get_inittab_entry PATH`
43 export INIT_PATH
=`get_inittab_entry INIT_PATH`
46 $INIT_D$bootprog telinit
"$@"