swap 1.3 KB

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