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.

67 lines
1.4 KiB

  1. #!/bin/sh
  2. #
  3. # ROCK Linux: /etc/rc.d/rc
  4. #
  5. # This script does the switching between runlevels.
  6. #
  7. {
  8. export PATH=/bin:/sbin:/usr/bin:/usr/sbin
  9. echo "** running rc script **"
  10. echo "RC: Previous runlevel: $PREVLEVEL, new runlevel: $RUNLEVEL."
  11. curdir=/etc/rc.d/rc$RUNLEVEL.d
  12. prevdir=/etc/rc.d/rc$PREVLEVEL.d
  13. #
  14. # run the KILL scripts of the previous runlevel (if needed)
  15. #
  16. if ! [ $PREVLEVEL = S -o $PREVLEVEL = N ]
  17. then
  18. echo "RC: Leave runlevel $PREVLEVEL ..."
  19. for i in $prevdir/K*; do
  20. test -x "$i" || continue
  21. x="`echo "$i" | sed "s,$prevdir/K..,$curdir/S??,"`"
  22. [ "`echo $x`" = "$x" ] || continue
  23. /sbin/rc --nobtee $i stop
  24. done
  25. fi
  26. echo "RC: Enter runlevel $RUNLEVEL ..."
  27. if [ $RUNLEVEL = S ]
  28. then
  29. #
  30. # Kill all processes
  31. #
  32. echo "Sending all processes a SIGTERM (15) ..."
  33. killall5 -15
  34. sleep 5
  35. echo "Sending all processes a 2nd SIGTERM (15) ..."
  36. killall5 -15
  37. sleep 3
  38. echo "Sending all processes a SIGKILL (9) ..."
  39. killall5 -9
  40. sleep 3
  41. elif [ $RUNLEVEL != 0 -a $RUNLEVEL != 6 ]
  42. then
  43. #
  44. # run the START scripts of the current (new) runlevel
  45. #
  46. for i in $curdir/S*; do
  47. test -x "$i" || continue
  48. x="`echo "$i" | sed "s,$curdir/S..,$prevdir/K??,"`"
  49. [ "`echo $x`" = "$x" ] || continue
  50. /sbin/rc --nobtee $i start
  51. done
  52. fi
  53. echo "RC: The system is now in runlevel $RUNLEVEL."
  54. # write EOT mark for btee
  55. echo -ne '\004'
  56. } 2>&1 | /sbin/btee a /var/log/init.msg
  57. exit 0