fstab.init 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. EXTRA_COMMANDS="overlay_enable whole_root_enable"
  9. EXTRA_HELP=" overlay_enable Reenable overlay rootfs. (After you fix it).
  10. whole_root_enable Reenable whole-disk rootfs. (After you fix it)."
  11. rootfs_enable() {
  12. local extroot_type="$1"
  13. if [ ! -d /tmp/${extroot_type}-disabled ]; then
  14. echo "No disabled ${extroot_type} present (/tmp/${extroot_type}-disabled). Can't renable."
  15. exit 1
  16. fi
  17. rm -f /tmp/${extroot_type}-disabled/.extroot.md5sum
  18. rm -f /tmp/${extroot_type}-disabled/etc/extroot.md5sum
  19. echo "Please reboot router to complete re-enabling external rootfs."
  20. }
  21. overlay_enable() {
  22. rootfs_enable overlay
  23. }
  24. whole_root_enable() {
  25. rootfs_enable whole_root
  26. }
  27. do_mount() {
  28. local cfg="$1"
  29. config_mount_by_section "$cfg"
  30. }
  31. do_swapon() {
  32. local cfg="$1"
  33. config_swapon_by_section "$cfg"
  34. }
  35. do_unmount() {
  36. local cfg="$1"
  37. config_get target "$cfg" target
  38. config_get_bool enabled "$cfg" "enabled" '1'
  39. [ -n "$target" -a "$enabled" -gt 0 ] || return 0
  40. umount $target
  41. }
  42. do_swapoff() {
  43. local cfg="$1"
  44. config_get device "$cfg" device
  45. config_get_bool enabled "$cfg" "enabled" '1'
  46. [ -n "$device" -a "$enabled" -gt 0 ] && type swapoff >/dev/null || return 0
  47. swapoff $device
  48. }
  49. start() {
  50. . /lib/functions/mount.sh
  51. config_load fstab
  52. mkdir -p /var/lock
  53. lock /var/lock/fstab.lck
  54. [ -e /tmp/fstab ] || {
  55. echo '# WARNING: this is an auto generated file, please use uci to set defined filesystems' > /tmp/fstab
  56. }
  57. lock -u /var/lock/fstab.lck
  58. config_foreach do_swapon swap
  59. config_foreach do_mount mount
  60. config_foreach do_swapon swap # do swap a second time so that swap on filesystems is enabled
  61. }
  62. stop() {
  63. . /lib/functions/mount.sh
  64. config_load fstab
  65. config_foreach do_unmount mount
  66. config_foreach do_swapoff swap
  67. swapoff -a
  68. }