swap 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/sh
  2. # Begin $RC_BASE/init.d/swap
  3. ### BEGIN INIT INFO
  4. # Provides: swap
  5. # Required-Start: udev
  6. # Should-Start: modules
  7. # Required-Stop: localnet
  8. # Should-Stop:
  9. # Default-Start: S
  10. # Default-Stop: 0 6
  11. # Short-Description: Mounts and unmounts swap partitions.
  12. # Description: Mounts and unmounts swap partitions defined in
  13. # /etc/fstab.
  14. # X-LFS-Provided-By: LFS
  15. ### END INIT INFO
  16. . /lib/lsb/init-functions
  17. case "${1}" in
  18. start)
  19. message="Activating all swap files/partitions..."
  20. swapon -a
  21. evaluate_retval standard
  22. ;;
  23. stop)
  24. message="Deactivating all swap files/partitions..."
  25. swapoff -a
  26. evaluate_retval standard
  27. ;;
  28. restart)
  29. swapoff -a
  30. error_level="${?}"
  31. sleep 1
  32. swapon -a
  33. error_level="$(( ${error_level} + ${?} ))"
  34. (exit "${error_level}")
  35. evaluate_retval restart
  36. ;;
  37. status)
  38. log_success_msg "Retrieving swap status..."
  39. echo
  40. swapon -s
  41. ;;
  42. *)
  43. echo "Usage: ${0} {start|stop|restart|status}"
  44. exit 1
  45. ;;
  46. esac
  47. # End $RC_BASE/init.d/swap