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
|
|
|
|
|
2011-03-27 08:39:53 +03:00
|
|
|
EXTRA_COMMANDS="overlay_enable whole_root_enable"
|
|
|
|
EXTRA_HELP=" overlay_enable Reenable overlay rootfs. (After you fix it).
|
|
|
|
whole_root_enable Reenable whole-disk rootfs. (After you fix it)."
|
|
|
|
|
|
|
|
rootfs_enable() {
|
|
|
|
local extroot_type="$1"
|
|
|
|
|
|
|
|
if [ ! -d /tmp/${extroot_type}-disabled ]; then
|
|
|
|
echo "No disabled ${extroot_type} present (/tmp/${extroot_type}-disabled). Can't renable."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm -f /tmp/${extroot_type}-disabled/.extroot.md5sum
|
|
|
|
rm -f /tmp/${extroot_type}-disabled/etc/extroot.md5sum
|
|
|
|
echo "Please reboot router to complete re-enabling external rootfs."
|
|
|
|
}
|
|
|
|
|
|
|
|
overlay_enable() {
|
|
|
|
rootfs_enable overlay
|
|
|
|
}
|
|
|
|
|
|
|
|
whole_root_enable() {
|
|
|
|
rootfs_enable whole_root
|
|
|
|
}
|
|
|
|
|
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() {
|
2010-10-07 18:15:54 +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
|
2011-06-19 21:15:14 +03:00
|
|
|
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
|
2010-07-12 19:35:39 +03:00
|
|
|
}
|
2011-06-19 21:15:14 +03:00
|
|
|
lock -u /var/lock/fstab.lck
|
2007-09-22 16:47:20 +03:00
|
|
|
config_foreach do_swapon swap
|
2010-07-12 19:25:09 +03:00
|
|
|
config_foreach do_mount mount
|
2010-07-12 20:28:50 +03:00
|
|
|
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:15:54 +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
|
|
|
}
|
|
|
|
|
2012-12-19 11:41:28 +02:00
|
|
|
restart() {
|
|
|
|
stop
|
|
|
|
sleep 1
|
|
|
|
start
|
|
|
|
}
|