swap 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/sh
  2. # Begin /etc/init.d/swap
  3. ### BEGIN INIT INFO
  4. # Provides: swap
  5. # Required-Start:
  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-Default-Start: S20
  15. # X-LFS-Default-Stop: S80
  16. # X-LFS-Provided-By: LFS
  17. ### END INIT INFO
  18. . /lib/lsb/init-functions
  19. case "${1}" in
  20. start)
  21. message="Activating all swap files/partitions..."
  22. swapon -a
  23. evaluate_retval standard
  24. ;;
  25. stop)
  26. message="Deactivating all swap files/partitions..."
  27. swapoff -a
  28. evaluate_retval standard
  29. ;;
  30. restart)
  31. swapoff -a
  32. error_level="${?}"
  33. sleep 1
  34. swapon -a
  35. error_level="$(( ${error_level} + ${?} ))"
  36. (exit "${error_level}")
  37. evaluate_retval restart
  38. ;;
  39. status)
  40. log_success_msg "Retrieving swap status..."
  41. echo
  42. swapon -s
  43. ;;
  44. *)
  45. echo "Usage: ${0} {start|stop|restart|status}"
  46. exit 1
  47. ;;
  48. esac
  49. # End /etc/init.d/swap