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
|
|
|
|
|
|
|
|
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() {
|
2010-10-07 18:26:15 +03:00
|
|
|
. /lib/functions/mount.sh
|
|
|
|
|
2007-09-21 16:20:50 +03:00
|
|
|
config_load fstab
|
2010-02-27 00:45:39 +02:00
|
|
|
mkdir -p /var/lock
|
2010-10-13 22:21:41 +03:00
|
|
|
lock -w /var/lock/fstab.lck && {
|
|
|
|
lock /var/lock/fstab.lck
|
|
|
|
[ -e /tmp/fstab ] || {
|
|
|
|
echo '# WARNING: this is an auto generated file, please use uci to set defined filesystems' > /tmp/fstab
|
|
|
|
}
|
|
|
|
lock -u /var/lock/fstab.lck
|
|
|
|
}
|
2007-09-22 16:47:20 +03:00
|
|
|
config_foreach do_swapon swap
|
2010-10-13 22:21:41 +03:00
|
|
|
config_foreach do_mount mount
|
|
|
|
config_foreach do_swapon swap # do swap a second time so that swap on filesystems is enabled
|
2007-09-21 16:20:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
2010-10-07 18:26:15 +03:00
|
|
|
. /lib/functions/mount.sh
|
|
|
|
|
2007-09-21 16:20:50 +03:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2010-10-07 18:26:15 +03:00
|
|
|
|