* updated tzdata (2024a -> 2024b)
[t2sde.git] / package / base / stone / stone_mod_runlevel.sh
blob86a23463ce008865378b7b81ef571ca82ece2280
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
5 #
6 # This Copyright note is generated by scripts/Create-CopyPatch,
7 # more information can be found in the files COPYING and README.
8 #
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"
18 done
20 chrlv() {
21 local srv=$1 rl=$2 pri=$3
22 if [ ! -e /etc/rc.d/rc$rl.d/S??$srv ]
23 then
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
27 else
28 rm -f /etc/rc.d/rc$rl.d/[SK]??$srv
32 chpri() {
33 local srv=$1 pri=$2
35 gui_input "Changing priority for service $1" "$pri" pri
37 if [ ! -z "${pri#[0-9][0-9]}" ]
38 then
39 gui_message "The value you entered is not valid."
40 return
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
54 done
57 edit_srv() {
58 local srv=$1 id="runlevel_$RANDOM" cmd=""
60 while
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'"
71 done
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'"
81 eval "$cmd"
82 do : ; done
85 restart() {
86 gui_cmd "(Re-)Starting System Service '$1'" \
87 "/sbin/rc $1 stop ; /sbin/rc $1 start"
90 main() {
91 while
92 cmd="gui_menu runlevel 'Runlevel Editor - Select an"
93 cmd="$cmd item to change the priority or runlevels'"
95 x=`mktemp`
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
104 rlv=''
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
108 done
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'"
115 done | sort > $x
116 cmd="$cmd $(cut -f2- -d' ' < $x | tr '\n' ' ')"
117 rm -f $x ; eval "$cmd"
118 do : ; done