1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
4 # T2 SDE: package/.../stone/stone_mod_runlevel.sh
5 # Copyright (C) 2004 - 2005 The T2 SDE Project
6 # Copyright (C) 1998 - 2003 ROCK Linux Project
8 # More information can be found in the files COPYING and README.
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; version 2 of the License. A copy of the
13 # GNU General Public License can be found in the file COPYING.
14 # --- T2-COPYRIGHT-NOTE-END ---
16 # [MAIN] 80 runlevel Runlevel Configuration (Services)
18 # Remove dead symlinks
19 for x
in /etc
/rc.d
/rc
[0-6].d
/* ; do
20 [ -L "$x" -a ! -e "$x" ] && rm -f "$x"
24 local srv
=$1 rl
=$2 pri
=$3
25 if [ ! -e /etc
/rc.d
/rc
$rl.d
/S??
$srv ]
27 ln -sf ..
/init.d
/$srv /etc
/rc.d
/rc
$rl.d
/S
$pri$srv
28 kpr
=`printf "%02d" $(( 100 - $pri ))`
29 ln -sf ..
/init.d
/$srv /etc
/rc.d
/rc
$rl.d
/K
$kpr$srv
31 rm -f /etc
/rc.d
/rc
$rl.d
/[SK
]??
$srv
38 gui_input
"Changing priority for service $1" "$pri" pri
40 if [ ! -z "${pri#[0-9][0-9]}" ]
42 gui_message
"The value you entered is not valid."
46 rm -f /etc
/rc.d
/rcX.d
/X??
$srv
47 echo "The script '$srv' has the priority $pri." \
48 > /etc
/rc.d
/rcX.d
/X
$pri$srv
50 for x
in 0 1 2 3 4 5 6 ; do
51 if [ -e /etc
/rc.d
/rc
$x.d
/S??
$srv ] ; then
52 rm -f /etc
/rc.d
/rc
$x.d
/[SK
]??
$srv
53 ln -sf ..
/init.d
/$srv /etc
/rc.d
/rc
$x.d
/S
$pri$srv
54 kpr
=`printf "%02d" $(( 100 - $pri ))`
55 ln -sf ..
/init.d
/$srv /etc
/rc.d
/rc
$x.d
/K
$kpr$srv
61 local srv
=$1 id
="runlevel_$RANDOM" cmd
=""
64 cmd
="gui_menu $id 'Runlevel Editor - $srv'"
65 pri
=`ls /etc/rc.d/rc?.d/[SX]??$srv 2> /dev/null | \
66 cut -c18-19 | head -n 1`
67 [ -z "$pri" ] && pri
=99
69 for rl
in 1 2 3 4 5 ; do
70 if [ -e /etc
/rc.d
/rc
$rl.d
/S??
$srv ]
71 then cmd
="$cmd '[*] " ; else cmd
="$cmd '[ ] " ; fi
72 cmd
="$cmd Run this script in runlevel $rl'"
73 cmd
="$cmd 'chrlv $srv $rl $pri'"
76 cmd
="$cmd '$pri This scripts priority (01-99)'"
77 cmd
="$cmd 'chpri $srv $pri' '' ''"
79 cmd
="$cmd 'Edit /etc/rc.d/init.d/$srv script'"
80 cmd
="$cmd \"gui_edit 'SysV Init Script $srv'"
81 cmd
="$cmd /etc/rc.d/init.d/$srv\""
82 cmd
="$cmd \"(Re-)Start the '$srv' system service\""
83 cmd
="$cmd '$STONE runlevel restart $srv'"
89 gui_cmd
"(Re-)Starting System Service '$1'" \
90 "/sbin/rc $1 stop ; /sbin/rc $1 start"
95 cmd
="gui_menu runlevel 'Runlevel Editor - Select an"
96 cmd
="$cmd item to change the priority or runlevels'"
99 for srv
in $
( ls /etc
/rc.d
/init.d
/ )
101 [ -f /etc
/rc.d
/init.d
/$srv ] ||
continue
103 pri
=`ls /etc/rc.d/rc?.d/[SX]??$srv \
104 2> /dev/null | cut -c18-19 | head -n 1`
105 [ -z "$pri" ] && pri
=99
108 for x
in 1 2 3 4 5 ; do
109 if [ -e /etc
/rc.d
/rc
$x.d
/S??
$srv ]
110 then rlv
="${rlv}$x" ; else rlv
="${rlv}-" ; fi
113 desc
=`grep '# *Desc:' /etc/rc.d/init.d/$srv | \
114 cut -f2- -d: | tr -d "'" | cut -c1-45`
115 desc
="$( printf "%-10s %s
" "$srv" "$desc" )"
117 echo "$pri$srv '$pri $rlv $desc' 'edit_srv $srv'"
119 cmd
="$cmd $(cut -f2- -d' ' < $x | tr '\n' ' ')"
120 rm -f $x ; eval "$cmd"