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

Archive Download this file



interactive