d755eccf08a4305cfa8240b4d1136a82db6872f8
[openwrt/staging/yousong.git] / package / block-mount / files / fstab.init
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
8
9 START=20
10
11 . /lib/functions/mount.sh
12
13 do_mount() {
14 local cfg="$1"
15 config_mount_by_section "$cfg"
16 }
17
18 do_swapon() {
19 local cfg="$1"
20 config_swapon_by_section "$cfg"
21 }
22
23 do_unmount() {
24 local cfg="$1"
25
26 config_get target "$cfg" target
27 config_get_bool enabled "$cfg" "enabled" '1'
28 [ -n "$target" -a "$enabled" -gt 0 ] || return 0
29 umount $target
30 }
31
32 do_swapoff() {
33 local cfg="$1"
34
35 config_get device "$cfg" device
36 config_get_bool enabled "$cfg" "enabled" '1'
37 [ -n "$device" -a "$enabled" -gt 0 ] && type swapoff >/dev/null || return 0
38 swapoff $device
39 }
40
41 start() {
42 config_load fstab
43 mkdir -p /var/lock
44 lock /var/lock/fstab.lck
45 echo '# WARNING: this is an auto generated file, please use uci to set defined filesystems' > /etc/fstab
46 lock -u /var/lock/fstab.lck
47 config_foreach do_swapon swap
48 config_foreach do_mount mount
49 }
50
51 stop() {
52 config_load fstab
53 config_foreach do_unmount mount
54 config_foreach do_swapoff swap
55 swapoff -a
56 }
57