2007-09-21 16:20:50 +03:00
|
|
|
#!/bin/sh /etc/rc.common
|
|
|
|
# Copyright (C) 2007 OpenWrt.org
|
2010-02-27 00:45:39 +02:00
|
|
|
# Copyright (C) 2010 Vertical Communications
|
|
|
|
# This is free software, licensed under the GNU General Public License v2.
|
|
|
|
# See /LICENSE for more information.
|
|
|
|
#
|
|
|
|
|
2007-09-21 16:20:50 +03:00
|
|
|
|
|
|
|
START=20
|
|
|
|
|
2010-02-27 00:45:39 +02:00
|
|
|
. /lib/functions/mount.sh
|
|
|
|
|
2007-09-21 16:20:50 +03:00
|
|
|
do_mount() {
|
|
|
|
local cfg="$1"
|
2010-02-27 00:45:39 +02:00
|
|
|
config_mount_by_section "$cfg"
|
2007-09-21 16:20:50 +03:00
|
|
|
}
|
|
|
|
|
2007-09-22 16:47:20 +03:00
|
|
|
do_swapon() {
|
|
|
|
local cfg="$1"
|
2010-02-27 00:45:39 +02:00
|
|
|
config_swapon_by_section "$cfg"
|
2007-09-22 16:47:20 +03:00
|
|
|
}
|
|
|
|
|
2007-09-21 16:20:50 +03:00
|
|
|
do_unmount() {
|
|
|
|
local cfg="$1"
|
2009-08-07 03:08:01 +03:00
|
|
|
|
2007-09-21 16:20:50 +03:00
|
|
|
config_get target "$cfg" target
|
|
|
|
config_get_bool enabled "$cfg" "enabled" '1'
|
2009-08-07 03:08:01 +03:00
|
|
|
[ -n "$target" -a "$enabled" -gt 0 ] || return 0
|
|
|
|
umount $target
|
2007-09-21 16:20:50 +03:00
|
|
|
}
|
|
|
|
|
2007-09-22 16:47:20 +03:00
|
|
|
do_swapoff() {
|
|
|
|
local cfg="$1"
|
2009-08-07 03:08:01 +03:00
|
|
|
|
2007-09-22 16:47:20 +03:00
|
|
|
config_get device "$cfg" device
|
|
|
|
config_get_bool enabled "$cfg" "enabled" '1'
|
2009-08-07 03:08:01 +03:00
|
|
|
[ -n "$device" -a "$enabled" -gt 0 ] && type swapoff >/dev/null || return 0
|
|
|
|
swapoff $device
|
2007-09-22 16:47:20 +03:00
|
|
|
}
|
|
|
|
|
2007-09-21 16:20:50 +03:00
|
|
|
start() {
|
|
|
|
config_load fstab
|
2010-02-27 00:45:39 +02:00
|
|
|
mkdir -p /var/lock
|
|
|
|
lock /var/lock/fstab.lck
|
|
|
|
echo '# WARNING: this is an auto generated file, please use uci to set defined filesystems' > /etc/fstab
|
|
|
|
lock -u /var/lock/fstab.lck
|
2007-09-21 16:20:50 +03:00
|
|
|
config_foreach do_mount mount
|
2007-09-22 16:47:20 +03:00
|
|
|
config_foreach do_swapon swap
|
2007-09-21 16:20:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
|
|
|
config_load fstab
|
|
|
|
config_foreach do_unmount mount
|
2007-09-22 16:47:20 +03:00
|
|
|
config_foreach do_swapoff swap
|
2010-02-27 00:45:39 +02:00
|
|
|
swapoff -a
|
2007-09-21 16:20:50 +03:00
|
|
|
}
|
|
|
|
|