swap 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/bin/sh
  2. ########################################################################
  3. # Begin swap
  4. #
  5. # Description : Swap Control Script
  6. #
  7. # Authors : Gerard Beekmans - gerard@linuxfromscratch.org
  8. # Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
  9. #
  10. # Version : LFS 7.0
  11. #
  12. ########################################################################
  13. ### BEGIN INIT INFO
  14. # Provides: swap
  15. # Required-Start: udev
  16. # Should-Start: modules
  17. # Required-Stop: localnet
  18. # Should-Stop:
  19. # Default-Start: S
  20. # Default-Stop: 0 6
  21. # Short-Description: Mounts and unmounts swap partitions.
  22. # Description: Mounts and unmounts swap partitions defined in
  23. # /etc/fstab.
  24. # X-LFS-Provided-By: LFS
  25. ### END INIT INFO
  26. . /lib/boot/functions
  27. case "${1}" in
  28. start)
  29. boot_mesg "Activating all swap files/partitions..."
  30. swapon -a
  31. evaluate_retval
  32. ;;
  33. stop)
  34. boot_mesg "Deactivating all swap files/partitions..."
  35. swapoff -a
  36. evaluate_retval
  37. ;;
  38. restart)
  39. ${0} stop
  40. sleep 1
  41. ${0} start
  42. ;;
  43. status)
  44. boot_mesg "Retrieving swap status." ${INFO}
  45. echo_ok
  46. echo
  47. swapon -s
  48. ;;
  49. *)
  50. echo "Usage: ${0} {start|stop|restart|status}"
  51. exit 1
  52. ;;
  53. esac
  54. # End swap