OpenSDE Packages Database (without history before r20070)
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.

123 lines
3.2 KiB

  1. # --- T2-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # T2 SDE: package/.../stone/stone_mod_runlevel.sh
  5. # Copyright (C) 2004 - 2006 The T2 SDE Project
  6. # Copyright (C) 1998 - 2003 Clifford Wolf
  7. #
  8. # More information can be found in the files COPYING and README.
  9. #
  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 ---
  15. #
  16. # [MAIN] 80 runlevel Runlevel Configuration (Services)
  17. # Remove dead symlinks
  18. for x in /etc/rc.d/rc[0-6].d/* ; do
  19. [ -L "$x" -a ! -e "$x" ] && rm -f "$x"
  20. done
  21. chrlv() {
  22. local srv=$1 rl=$2 pri=$3
  23. if [ ! -e /etc/rc.d/rc$rl.d/S??$srv ]
  24. then
  25. ln -sf ../init.d/$srv /etc/rc.d/rc$rl.d/S$pri$srv
  26. kpr=`printf "%02d" $(( 100 - $pri ))`
  27. ln -sf ../init.d/$srv /etc/rc.d/rc$rl.d/K$kpr$srv
  28. else
  29. rm -f /etc/rc.d/rc$rl.d/[SK]??$srv
  30. fi
  31. }
  32. chpri() {
  33. local srv=$1 pri=$2
  34. gui_input "Changing priority for service $1" "$pri" pri
  35. if [ ! -z "${pri#[0-9][0-9]}" ]
  36. then
  37. gui_message "The value you entered is not valid."
  38. return
  39. fi
  40. rm -f /etc/rc.d/rcX.d/X??$srv
  41. echo "The script '$srv' has the priority $pri." \
  42. > /etc/rc.d/rcX.d/X$pri$srv
  43. for x in 0 1 2 3 4 5 6 ; do
  44. if [ -e /etc/rc.d/rc$x.d/S??$srv ] ; then
  45. rm -f /etc/rc.d/rc$x.d/[SK]??$srv
  46. ln -sf ../init.d/$srv /etc/rc.d/rc$x.d/S$pri$srv
  47. kpr=`printf "%02d" $(( 100 - $pri ))`
  48. ln -sf ../init.d/$srv /etc/rc.d/rc$x.d/K$kpr$srv
  49. fi
  50. done
  51. }
  52. edit_srv() {
  53. local srv=$1 id="runlevel_$RANDOM" cmd=""
  54. while
  55. cmd="gui_menu $id 'Runlevel Editor - $srv'"
  56. pri=`ls /etc/rc.d/rc?.d/[SX]??$srv 2> /dev/null | \
  57. cut -c18-19 | head -n 1`
  58. [ -z "$pri" ] && pri=99
  59. for rl in 1 2 3 4 5 ; do
  60. if [ -e /etc/rc.d/rc$rl.d/S??$srv ]
  61. then cmd="$cmd '[*] " ; else cmd="$cmd '[ ] " ; fi
  62. cmd="$cmd Run this script in runlevel $rl'"
  63. cmd="$cmd 'chrlv $srv $rl $pri'"
  64. done
  65. cmd="$cmd '$pri This scripts priority (01-99)'"
  66. cmd="$cmd 'chpri $srv $pri' '' ''"
  67. cmd="$cmd 'Edit /etc/rc.d/init.d/$srv script'"
  68. cmd="$cmd \"gui_edit 'SysV Init Script $srv'"
  69. cmd="$cmd /etc/rc.d/init.d/$srv\""
  70. cmd="$cmd \"(Re-)Start the '$srv' system service\""
  71. cmd="$cmd '$STONE runlevel restart $srv'"
  72. eval "$cmd"
  73. do : ; done
  74. }
  75. restart() {
  76. gui_cmd "(Re-)Starting System Service '$1'" \
  77. "/sbin/rc $1 stop ; /sbin/rc $1 start"
  78. }
  79. main() {
  80. while
  81. cmd="gui_menu runlevel 'Runlevel Editor - Select an"
  82. cmd="$cmd item to change the priority or runlevels'"
  83. x=`mktemp`
  84. for srv in $( ls /etc/rc.d/init.d/ )
  85. do
  86. [ -f /etc/rc.d/init.d/$srv ] || continue
  87. pri=`ls /etc/rc.d/rc?.d/[SX]??$srv \
  88. 2> /dev/null | cut -c18-19 | head -n 1`
  89. [ -z "$pri" ] && pri=99
  90. rlv=''
  91. for x in 1 2 3 4 5 ; do
  92. if [ -e /etc/rc.d/rc$x.d/S??$srv ]
  93. then rlv="${rlv}$x" ; else rlv="${rlv}-" ; fi
  94. done
  95. desc=`grep '# *Desc:' /etc/rc.d/init.d/$srv | \
  96. cut -f2- -d: | tr -d "'" | cut -c1-45`
  97. desc="$( printf "%-10s %s" "$srv" "$desc" )"
  98. echo "$pri$srv '$pri $rlv $desc' 'edit_srv $srv'"
  99. done | sort > $x
  100. cmd="$cmd $(cut -f2- -d' ' < $x | tr '\n' ' ')"
  101. rm -f $x ; eval "$cmd"
  102. do : ; done
  103. }