fstab.init 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2007 OpenWrt.org
  3. # Copyright (C) 2010 Vertical Communications
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. START=20
  8. . /lib/functions/mount.sh
  9. do_mount() {
  10. local cfg="$1"
  11. config_mount_by_section "$cfg"
  12. }
  13. do_swapon() {
  14. local cfg="$1"
  15. config_swapon_by_section "$cfg"
  16. }
  17. do_unmount() {
  18. local cfg="$1"
  19. config_get target "$cfg" target
  20. config_get_bool enabled "$cfg" "enabled" '1'
  21. [ -n "$target" -a "$enabled" -gt 0 ] || return 0
  22. umount $target
  23. }
  24. do_swapoff() {
  25. local cfg="$1"
  26. config_get device "$cfg" device
  27. config_get_bool enabled "$cfg" "enabled" '1'
  28. [ -n "$device" -a "$enabled" -gt 0 ] && type swapoff >/dev/null || return 0
  29. swapoff $device
  30. }
  31. start() {
  32. config_load fstab
  33. mkdir -p /var/lock
  34. lock /var/lock/fstab.lck
  35. echo '# WARNING: this is an auto generated file, please use uci to set defined filesystems' > /etc/fstab
  36. lock -u /var/lock/fstab.lck
  37. config_foreach do_swapon swap
  38. config_foreach do_mount mount
  39. }
  40. stop() {
  41. config_load fstab
  42. config_foreach do_unmount mount
  43. config_foreach do_swapoff swap
  44. swapoff -a
  45. }