work aroung error message during boot if swapon is nt installed
[openwrt.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" -eq 0 ] && options="noauto,$options"
19 echo "$device $target $fstype $options 0 0" >> /tmp/fstab
20 }
21
22 do_swapon() {
23 local cfg="$1"
24 config_get device "$cfg" device
25 [ -n "$device" ] || return 0
26 config_get_bool enabled "$cfg" "enabled" '1'
27 [ "$enabled" -gt 0 ] && {
28 echo "$device none swap ${noauto}sw 0 0" >> /tmp/fstab
29 }
30 }
31
32 do_unmount() {
33 local cfg="$1"
34 config_get target "$cfg" target
35 [ -n "$target" ] || return 0
36 config_get_bool enabled "$cfg" "enabled" '1'
37 [ "$enabled" -gt 0 ] && {
38 umount $target
39 }
40 }
41
42 do_swapoff() {
43 local cfg="$1"
44 config_get device "$cfg" device
45 [ -n "$device" ] || return 0
46 config_get_bool enabled "$cfg" "enabled" '1'
47 [ "$enabled" -gt 0 ] && type swapoff >/dev/null && {
48 swapoff $device
49 }
50 }
51
52 start() {
53 config_load fstab
54 echo '# WARNING: this is an auto generated file, please use uci to set static filesystems' > /tmp/fstab
55 config_foreach do_mount mount
56 config_foreach do_swapon swap
57 mount -a
58 [ -x /sbin/swapon ] && swapon -a
59 }
60
61 stop() {
62 config_load fstab
63 config_foreach do_unmount mount
64 config_foreach do_swapoff swap
65 }
66
This page took 0.043886 seconds and 5 git commands to generate.