2013-08-16 15:21:59 +02:00
|
|
|
#!/bin/sh
|
2018-07-16 20:45:36 +02:00
|
|
|
|
|
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
# Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv)
|
2010-10-23 19:54:08 +02:00
|
|
|
|
2012-05-19 02:28:16 +02:00
|
|
|
. /etc/swap.conf
|
2013-10-18 19:43:12 +03:00
|
|
|
. /etc/profile
|
2012-05-19 02:28:16 +02:00
|
|
|
|
2013-08-16 15:21:59 +02:00
|
|
|
if [ -f /storage/.config/swap.conf ]; then
|
|
|
|
|
. /storage/.config/swap.conf
|
2012-05-19 02:28:16 +02:00
|
|
|
fi
|
|
|
|
|
|
2013-10-18 19:43:12 +03:00
|
|
|
if [ -e /dev/.storage_netboot ] ; then
|
|
|
|
|
logger -t Boot "### netbooting... swap disabled ###"
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
2014-01-04 00:08:43 +01:00
|
|
|
if [ ! "$SWAP_ENABLED" = yes ] ; then
|
|
|
|
|
logger -t Boot "### swap disabled via configfile ###"
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
2013-08-16 15:21:59 +02:00
|
|
|
SWAP=`blkid -t TYPE="swap" -o device`
|
2010-10-23 19:54:08 +02:00
|
|
|
|
2013-08-16 15:21:59 +02:00
|
|
|
case $1 in
|
|
|
|
|
create)
|
2011-09-12 19:26:05 +02:00
|
|
|
if [ -z "$SWAP" -a ! -f "$SWAPFILE" ]; then
|
2012-05-19 02:28:16 +02:00
|
|
|
mkdir -p `dirname $SWAPFILE`
|
2013-08-16 15:21:59 +02:00
|
|
|
dd if=/dev/zero of=$SWAPFILE bs=1M count=$SWAPFILESIZE
|
|
|
|
|
chmod 0600 $SWAPFILE
|
|
|
|
|
mkswap $SWAPFILE
|
2011-09-12 19:26:05 +02:00
|
|
|
fi
|
2013-08-16 15:21:59 +02:00
|
|
|
;;
|
|
|
|
|
mount)
|
|
|
|
|
[ -z "$SWAP" -a -f "$SWAPFILE" ] && SWAP=$SWAPFILE
|
|
|
|
|
for i in $SWAP; do
|
2019-08-15 00:10:18 -05:00
|
|
|
swapon -p 10000 $i
|
2013-08-16 15:21:59 +02:00
|
|
|
done
|
|
|
|
|
;;
|
|
|
|
|
unmount)
|
|
|
|
|
swapoff -a
|
|
|
|
|
;;
|
|
|
|
|
esac
|