2010-10-23 19:54:08 +02:00
|
|
|
################################################################################
|
2012-05-19 02:28:16 +02:00
|
|
|
# This file is part of OpenELEC - http://www.openelec.tv
|
|
|
|
|
# Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
|
2010-10-23 19:54:08 +02:00
|
|
|
#
|
|
|
|
|
# This Program is free software; you can redistribute it and/or modify
|
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
|
# the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
|
# any later version.
|
|
|
|
|
#
|
|
|
|
|
# This Program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
#
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
|
# along with OpenELEC.tv; see the file COPYING. If not, write to
|
2012-02-29 13:11:22 +01:00
|
|
|
# the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
|
2010-10-23 19:54:08 +02:00
|
|
|
# http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# create and enable swapfile
|
|
|
|
|
#
|
|
|
|
|
# runlevels: openelec, textmode
|
|
|
|
|
|
2012-05-19 02:28:16 +02:00
|
|
|
. /etc/swap.conf
|
|
|
|
|
|
|
|
|
|
if [ -f $HOME/.config/swap.conf ]; then
|
|
|
|
|
. $HOME/.config/swap.conf
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
(
|
|
|
|
|
if [ -e /proc/swaps ]; then
|
|
|
|
|
SWAP=`blkid -t TYPE="swap" -o device`
|
2010-10-23 19:54:08 +02:00
|
|
|
|
2011-09-12 19:26:05 +02:00
|
|
|
if [ -z "$SWAP" -a ! -f "$SWAPFILE" ]; then
|
|
|
|
|
progress "creating swapfile"
|
2013-04-26 00:47:24 +02:00
|
|
|
echo "creating Swapfile ..."
|
2012-05-19 02:28:16 +02:00
|
|
|
mkdir -p `dirname $SWAPFILE`
|
|
|
|
|
dd if=/dev/zero of=$SWAPFILE bs=1024 count=$SWAPFILESIZE 2>&1 > /dev/null
|
2011-09-12 19:26:05 +02:00
|
|
|
mkswap $SWAPFILE 2>&1 > /dev/null
|
|
|
|
|
fi
|
2010-10-23 19:54:08 +02:00
|
|
|
|
2011-09-12 19:26:05 +02:00
|
|
|
progress "enable swap"
|
|
|
|
|
[ -z "$SWAP" -a -f "$SWAPFILE" ] && SWAP=$SWAPFILE
|
|
|
|
|
for i in $SWAP; do
|
|
|
|
|
swapon -p 10000 $SWAP 2>&1 > /dev/null
|
|
|
|
|
done
|
2013-03-06 13:18:17 +01:00
|
|
|
sysctl -w vm.swappiness=10 2>&1 > /dev/null
|
2011-09-12 19:26:05 +02:00
|
|
|
fi
|
2012-04-26 16:17:36 +02:00
|
|
|
)&
|