mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
3.6 KiB

  1. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  2. #
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. # Please add additional copyright information _after_ the line containing
  5. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  6. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  7. #
  8. # ROCK Linux: rock-src/package/base/sysfiles/stone_mod_runlevel.sh
  9. # ROCK Linux is Copyright (C) 1998 - 2005 Clifford Wolf
  10. #
  11. # This program is free software; you can redistribute it and/or modify
  12. # it under the terms of the GNU General Public License as published by
  13. # the Free Software Foundation; either version 2 of the License, or
  14. # (at your option) any later version. A copy of the GNU General Public
  15. # License can be found at Documentation/COPYING.
  16. #
  17. # Many people helped and are helping developing ROCK Linux. Please
  18. # have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  19. # file for details.
  20. #
  21. # --- ROCK-COPYRIGHT-NOTE-END ---
  22. #
  23. # [MAIN] 80 runlevel Runlevel Configuration (Services)
  24. # Remove dead symlinks
  25. for x in /etc/rc.d/rc[0-6].d/* ; do
  26. [ -L "$x" -a ! -e "$x" ] && rm -f "$x"
  27. done
  28. chrlv() {
  29. local srv=$1 rl=$2 pri=$3
  30. if [ ! -e /etc/rc.d/rc$rl.d/S??$srv ]
  31. then
  32. ln -sf ../init.d/$srv /etc/rc.d/rc$rl.d/S$pri$srv
  33. kpr=`printf "%02d" $(( 100 - $pri ))`
  34. ln -sf ../init.d/$srv /etc/rc.d/rc$rl.d/K$kpr$srv
  35. else
  36. rm -f /etc/rc.d/rc$rl.d/[SK]??$srv
  37. fi
  38. }
  39. chpri() {
  40. local srv=$1 pri=$2
  41. gui_input "Changing priority for service $1" "$pri" pri
  42. if [ ! -z "${pri#[0-9][0-9]}" ]
  43. then
  44. gui_message "The value you entered is not valid."
  45. return
  46. fi
  47. rm -f /etc/rc.d/rcX.d/X??$srv
  48. echo "The script '$srv' has the priority $pri." \
  49. > /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
  56. fi
  57. done
  58. }
  59. edit_srv() {
  60. local srv=$1 id="runlevel_$RANDOM" cmd=""
  61. while
  62. cmd="gui_menu $id 'Runlevel Editor - $srv'"
  63. pri=`ls /etc/rc.d/rc?.d/[SX]??$srv 2> /dev/null | \
  64. cut -c18-19 | head -n 1`
  65. [ -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
  72. cmd="$cmd '$pri This scripts priority (01-99)'"
  73. cmd="$cmd 'chpri $srv $pri' '' ''"
  74. cmd="$cmd 'Edit /etc/rc.d/init.d/$srv script'"
  75. cmd="$cmd \"gui_edit 'SysV Init Script $srv'"
  76. cmd="$cmd /etc/rc.d/init.d/$srv\""
  77. cmd="$cmd \"(Re-)Start the '$srv' system service\""
  78. cmd="$cmd '$STONE runlevel restart $srv'"
  79. eval "$cmd"
  80. do : ; done
  81. }
  82. restart() {
  83. gui_cmd "(Re-)Starting System Service '$1'" \
  84. "/sbin/rc $1 stop ; /sbin/rc $1 start"
  85. }
  86. main() {
  87. while
  88. cmd="gui_menu runlevel 'Runlevel Editor - Select an"
  89. cmd="$cmd item to change the priority or runlevels'"
  90. x=`mktemp`
  91. for srv in $( ls /etc/rc.d/init.d/ )
  92. do
  93. [ -f /etc/rc.d/init.d/$srv ] || continue
  94. pri=`ls /etc/rc.d/rc?.d/[SX]??$srv \
  95. 2> /dev/null | cut -c18-19 | head -n 1`
  96. [ -z "$pri" ] && pri=99
  97. rlv=''
  98. for x in 1 2 3 4 5 ; do
  99. if [ -e /etc/rc.d/rc$x.d/S??$srv ]
  100. then rlv="${rlv}$x" ; else rlv="${rlv}-" ; fi
  101. done
  102. desc=`grep '# *Desc:' /etc/rc.d/init.d/$srv | \
  103. cut -f2- -d: | tr -d "'" | cut -c1-45`
  104. desc="$( printf "%-10s %s" "$srv" "$desc" )"
  105. echo "$pri$srv '$pri $rlv $desc' 'edit_srv $srv'"
  106. done | sort > $x
  107. cmd="$cmd $(cut -f2- -d' ' < $x | tr '\n' ' ')"
  108. rm -f $x ; eval "$cmd"
  109. do : ; done
  110. }