Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.41 KB | None | 0 0
  1. # rc-sysinit - System V initialisation compatibility
  2. #
  3. # This task runs the old System V-style system initialisation scripts,
  4. # and enters the default runlevel when finished.
  5. description "System V initialisation compatibility"
  6. author      "Scott James Remnant <scott@netsplit.com>"
  7.  
  8. start on (filesystem and static-network-up) or failsafe-boot
  9. stop on runlevel
  10.  
  11. # Default runlevel, this may be overriden on the kernel command-line
  12. # or by faking an old /etc/inittab entry
  13. env DEFAULT_RUNLEVEL=2
  14.  
  15. emits runlevel
  16. # There can be no previous runlevel here, but there might be old
  17. # information in /var/run/utmp that we pick up, and we don't want
  18. # that.
  19. #
  20. # These override that
  21. env RUNLEVEL=
  22. env PREVLEVEL=
  23.  
  24. console output
  25. env INIT_VERBOSE
  26.  
  27. task
  28.  
  29. script
  30.     # Check for default runlevel in /etc/inittab
  31.     if [ -r /etc/inittab ]; then
  32.        eval "$(sed -nre 's/^[^#][^:]*:([0-6sS]):initdefault:.*/DEFAULT_RUNLEVEL="\1";/p' /etc/inittab || true)"
  33.     fi
  34.  
  35.     # Check kernel command-line for typical arguments
  36.     for ARG in $(cat /proc/cmdline); do
  37.        case "${ARG}" in
  38.          rootboot=*)
  39.                         # autologin root - set custom kernel param rootboot=1
  40.                         # exec /bin/bash --login < /dev/console > /dev/console 2>&1
  41.                         # ...no echo
  42.                         # exec /bin/login -f root < /dev/tty0 > /dev/tty0 2>&1
  43.                         # This works
  44.                         # exec /sbin/rungetty -u root tty0 /root/bin/my_autologin
  45.                         #exec /sbin/rungetty -u root tty0 /root/bin/my_autologin
  46.                         # this works, but no console echo either
  47.                         # exec /bin/bash --login < /dev/console>/dev/console 2>&1
  48.                         exec /sbin/rungetty --autologin root tty0
  49.          ;;
  50.  
  51.           -b|emergency)
  52.                          # Emergency shell
  53.                          [ -n "${FROM_SINGLE_USER_MODE}" ] || sulogin
  54.           ;;
  55.  
  56.           [0123456sS])
  57.                          # Override runlevel
  58.                          DEFAULT_RUNLEVEL="${ARG}"
  59.           ;;
  60.  
  61.           -s|single)
  62.                         # Single user mode
  63.                          [ -n "${FROM_SINGLE_USER_MODE}" ] || DEFAULT_RUNLEVEL=S
  64.           ;;
  65.        esac
  66.     done
  67.  
  68.     # Run the system initialisation scripts
  69.     [ -n "${FROM_SINGLE_USER_MODE}" ] || /etc/init.d/rcS
  70.  
  71.     # Switch into the default runlevel
  72.     telinit "${DEFAULT_RUNLEVEL}"
  73. end script
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement