source: trunk/package/base-files/files/etc/init.d/fstab @ 12087

Last change on this file since 12087 was 12087, checked in by blogic, 8 years ago

work aroung error message during boot if swapon is nt installed

  • Property svn:executable set to *
File size: 1.5 KB
Line 
1#!/bin/sh /etc/rc.common
2# Copyright (C) 2007 OpenWrt.org
3
4START=20
5
6do_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
22do_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
32do_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       
42do_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
52start() {
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
61stop() {
62        config_load fstab
63        config_foreach do_unmount mount
64        config_foreach do_swapoff swap
65}
66
Note: See TracBrowser for help on using the repository browser.