2a63a5b1bf43b0e540a640d2ef6eabeca21065fd
[openwrt/svn-archive/archive.git] / package / base-files / files / etc / init.d / fstab
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2007 OpenWrt.org
3
4 START=20
5
6 do_mount() {
7 local cfg="$1"
8 config_get fstype "$cfg" fstype
9 fstype="${fstype:-auto}"
10 config_get options "$cfg" options
11 options="${options:-rw}"
12 config_get device "$cfg" device
13 [ -n "device" ] || return 0
14 config_get target "$cfg" target
15 [ -n "target" ] || return 0
16 mkdir -p $target
17 config_get_bool enabled "$cfg" "enabled" '1'
18 [ "$enabled" -gt 0 ] && {
19 /bin/mount -t $fstype -o $options $device $target
20 }
21 }
22
23 do_unmount() {
24 local cfg="$1"
25 config_get target "$cfg" target
26 [ -n "target" ] || return 0
27 config_get_bool enabled "$cfg" "enabled" '1'
28 [ "$enabled" -gt 0 ] && {
29 /bin/umount $target
30 }
31 }
32
33 start() {
34 config_load fstab
35 config_foreach do_mount mount
36 }
37
38 stop() {
39 config_load fstab
40 config_foreach do_unmount mount
41 }
42