1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # T2 SDE: package/*/stone/stone_mod_runlevel.sh
3 # Copyright (C) 2004 - 2022 The T2 SDE Project
4 # Copyright (C) 1998 - 2003 ROCK Linux Project
6 # This Copyright note is generated by scripts/Create-CopyPatch,
7 # more information can be found in the files COPYING and README.
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License version 2.
11 # --- T2-COPYRIGHT-NOTE-END ---
13 # [MAIN] 80 runlevel Runlevel Configuration (Services)
15 # Remove dead symlinks
16 for x
in /etc
/rc.d
/rc
[0-6].d
/* ; do
17 [ -L "$x" -a ! -e "$x" ] && rm -f "$x"
21 local srv
=$1 rl
=$2 pri
=$3
22 if [ ! -e /etc
/rc.d
/rc
$rl.d
/S??
$srv ]
24 ln -sf ..
/init.d
/$srv /etc
/rc.d
/rc
$rl.d
/S
$pri$srv
25 kpr
=`printf "%02d" $(( 100 - $pri ))`
26 ln -sf ..
/init.d
/$srv /etc
/rc.d
/rc
$rl.d
/K
$kpr$srv
28 rm -f /etc
/rc.d
/rc
$rl.d
/[SK
]??
$srv
35 gui_input
"Changing priority for service $1" "$pri" pri
37 if [ ! -z "${pri#[0-9][0-9]}" ]
39 gui_message
"The value you entered is not valid."
43 rm -f /etc
/rc.d
/rcX.d
/X??
$srv
44 echo "The script '$srv' has the priority $pri." \
45 > /etc
/rc.d
/rcX.d
/X
$pri$srv
47 for x
in 0 1 2 3 4 5 6 ; do
48 if [ -e /etc
/rc.d
/rc
$x.d
/S??
$srv ]; then
49 rm -f /etc
/rc.d
/rc
$x.d
/[SK
]??
$srv
50 ln -sf ..
/init.d
/$srv /etc
/rc.d
/rc
$x.d
/S
$pri$srv
51 kpr
=`printf "%02d" $(( 100 - $pri ))`
52 ln -sf ..
/init.d
/$srv /etc
/rc.d
/rc
$x.d
/K
$kpr$srv
58 local srv
=$1 id
="runlevel_$RANDOM" cmd
=""
61 cmd
="gui_menu $id 'Runlevel Editor - $srv'"
62 pri
=`ls /etc/rc.d/rc?.d/[SX]??$srv 2> /dev/null | \
63 cut -c18-19 | head -n 1`
64 [ -z "$pri" ] && pri
=99
66 for rl
in 1 2 3 4 5 ; do
67 if [ -e /etc
/rc.d
/rc
$rl.d
/S??
$srv ]
68 then cmd
="$cmd '[*] "; else cmd
="$cmd '[ ] "; fi
69 cmd
="$cmd Run this script in runlevel $rl'"
70 cmd
="$cmd 'chrlv $srv $rl $pri'"
73 cmd
="$cmd '$pri This scripts priority (01-99)'"
74 cmd
="$cmd 'chpri $srv $pri' '' ''"
76 cmd
="$cmd 'Edit /etc/rc.d/init.d/$srv script'"
77 cmd
="$cmd \"gui_edit 'SysV Init Script $srv'"
78 cmd
="$cmd /etc/rc.d/init.d/$srv\""
79 cmd
="$cmd \"(Re-)Start the '$srv' system service\""
80 cmd
="$cmd '$STONE runlevel restart $srv'"
86 gui_cmd
"(Re-)Starting System Service '$1'" \
87 "/sbin/rc $1 stop ; /sbin/rc $1 start"
92 cmd
="gui_menu runlevel 'Runlevel Editor - Select an"
93 cmd
="$cmd item to change the priority or runlevels'"
96 for srv
in $
( ls /etc
/rc.d
/init.d
/ )
98 [ -f /etc
/rc.d
/init.d
/$srv ] ||
continue
100 pri
=`ls /etc/rc.d/rc?.d/[SX]??$srv \
101 2> /dev/null | cut -c18-19 | head -n 1`
102 [ -z "$pri" ] && pri
=99
105 for x
in 1 2 3 4 5 ; do
106 if [ -e /etc
/rc.d
/rc
$x.d
/S??
$srv ]
107 then rlv
="${rlv}$x"; else rlv
="${rlv}-"; fi
110 desc
=`grep '# *Desc:' /etc/rc.d/init.d/$srv | \
111 cut -f2- -d: | tr -d "'" | cut -c1-45`
112 desc
="$( printf "%-10s %s
" "$srv" "$desc" )"
114 echo "$pri$srv '$pri $rlv $desc' 'edit_srv $srv'"
116 cmd
="$cmd $(cut -f2- -d' ' < $x | tr '\n' ' ')"
117 rm -f $x ; eval "$cmd"