mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-29 05:36:47 +00:00
Merge pull request #7039 from antonlacon/swap-cleanup
util-linux: cleanup mount-swap, add comments to swap.conf
This commit is contained in:
commit
292f469eee
@ -1,6 +1,12 @@
|
|||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
# Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv)
|
# Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv)
|
||||||
|
# Copyright (C) 2022-present Team LibreELEC (https://libreelec.tv)
|
||||||
|
|
||||||
SWAPFILE="$HOME/.cache/swapfile"
|
# location with write access and no spaces
|
||||||
|
SWAPFILE="${HOME}/.cache/swapfile"
|
||||||
|
|
||||||
|
# in MiB
|
||||||
SWAPFILESIZE="@SWAPFILESIZE@"
|
SWAPFILESIZE="@SWAPFILESIZE@"
|
||||||
|
|
||||||
|
# set to "yes" to enable
|
||||||
SWAP_ENABLED="@SWAP_ENABLED_DEFAULT@"
|
SWAP_ENABLED="@SWAP_ENABLED_DEFAULT@"
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
# Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv)
|
# Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv)
|
||||||
|
# Copyright (C) 2022-present Team LibreELEC (https://libreelec.tv)
|
||||||
|
|
||||||
. /etc/swap.conf
|
. /etc/swap.conf
|
||||||
. /etc/profile
|
. /etc/profile
|
||||||
@ -15,26 +16,26 @@ if [ -e /dev/.storage_netboot ] ; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! "$SWAP_ENABLED" = yes ] ; then
|
if [ ! "${SWAP_ENABLED}" = "yes" ] ; then
|
||||||
logger -t Boot "### swap disabled via configfile ###"
|
logger -t Boot "### swap disabled via configfile ###"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SWAP=`blkid -t TYPE="swap" -o device`
|
SWAP=$(blkid -t TYPE="swap" -o device)
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
create)
|
create)
|
||||||
if [ -z "$SWAP" -a ! -f "$SWAPFILE" ]; then
|
if [ -z "${SWAP}" ] && [ ! -f "${SWAPFILE}" ]; then
|
||||||
mkdir -p `dirname $SWAPFILE`
|
mkdir -p "$(dirname ${SWAPFILE})"
|
||||||
dd if=/dev/zero of=$SWAPFILE bs=1M count=$SWAPFILESIZE
|
dd if=/dev/zero of="${SWAPFILE}" bs=1M count="${SWAPFILESIZE}"
|
||||||
chmod 0600 $SWAPFILE
|
chmod 0600 "${SWAPFILE}"
|
||||||
mkswap $SWAPFILE
|
mkswap "${SWAPFILE}"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
mount)
|
mount)
|
||||||
[ -z "$SWAP" -a -f "$SWAPFILE" ] && SWAP=$SWAPFILE
|
{ [ -z "${SWAP}" ] && [ -f "${SWAPFILE}" ]; } && SWAP="${SWAPFILE}"
|
||||||
for i in $SWAP; do
|
for i in ${SWAP}; do
|
||||||
swapon -p 10000 $i
|
swapon -p 10000 "${i}"
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
unmount)
|
unmount)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user