mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-08-05 00:47:50 +00:00
util-linux: port swapfile init scripts to systemd
Signed-off-by: Stephan Raue <stephan@openelec.tv>
This commit is contained in:
parent
97cc8cbd7b
commit
4fd5d8afc5
@ -113,10 +113,16 @@ post_makeinstall_target() {
|
||||
cp .libs/swapon $INSTALL/usr/sbin
|
||||
cp .libs/swapoff $INSTALL/usr/sbin
|
||||
|
||||
mkdir -p $INSTALL/etc/init.d
|
||||
cp $PKG_DIR/scripts/32_swapfile $INSTALL/etc/init.d
|
||||
mkdir -p $INSTALL/usr/lib/openelec
|
||||
cp -PR $PKG_DIR/scripts/mount-swap $INSTALL/usr/lib/openelec
|
||||
|
||||
mkdir -p $INSTALL/etc
|
||||
cat $PKG_DIR/config/swap.conf | sed -e "s,@SWAPFILESIZE@,$SWAPFILESIZE,g" > $INSTALL/etc/swap.conf
|
||||
fi
|
||||
}
|
||||
|
||||
post_install () {
|
||||
if [ "$SWAP_SUPPORT" = "yes" ]; then
|
||||
enable_service swap.service
|
||||
fi
|
||||
}
|
||||
|
38
packages/sysutils/util-linux/scripts/32_swapfile → packages/sysutils/util-linux/scripts/mount-swap
Normal file → Executable file
38
packages/sysutils/util-linux/scripts/32_swapfile → packages/sysutils/util-linux/scripts/mount-swap
Normal file → Executable file
@ -1,3 +1,4 @@
|
||||
#!/bin/sh
|
||||
################################################################################
|
||||
# This file is part of OpenELEC - http://www.openelec.tv
|
||||
# Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
|
||||
@ -18,35 +19,30 @@
|
||||
# http://www.gnu.org/copyleft/gpl.html
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# create and enable swapfile
|
||||
#
|
||||
# runlevels: openelec, textmode
|
||||
|
||||
. /etc/swap.conf
|
||||
|
||||
if [ -f $HOME/.config/swap.conf ]; then
|
||||
. $HOME/.config/swap.conf
|
||||
if [ -f /storage/.config/swap.conf ]; then
|
||||
. /storage/.config/swap.conf
|
||||
fi
|
||||
|
||||
(
|
||||
if [ -e /proc/swaps ]; then
|
||||
SWAP=`blkid -t TYPE="swap" -o device`
|
||||
SWAP=`blkid -t TYPE="swap" -o device`
|
||||
|
||||
case $1 in
|
||||
create)
|
||||
if [ -z "$SWAP" -a ! -f "$SWAPFILE" ]; then
|
||||
progress "creating swapfile"
|
||||
echo "creating Swapfile ..."
|
||||
mkdir -p `dirname $SWAPFILE`
|
||||
dd if=/dev/zero of=$SWAPFILE bs=1M count=$SWAPFILESIZE 2>&1 > /dev/null
|
||||
chmod 0600 $SWAPFILE 2>&1 > /dev/null
|
||||
mkswap $SWAPFILE 2>&1 > /dev/null
|
||||
dd if=/dev/zero of=$SWAPFILE bs=1M count=$SWAPFILESIZE
|
||||
chmod 0600 $SWAPFILE
|
||||
mkswap $SWAPFILE
|
||||
fi
|
||||
|
||||
progress "enable swap"
|
||||
;;
|
||||
mount)
|
||||
[ -z "$SWAP" -a -f "$SWAPFILE" ] && SWAP=$SWAPFILE
|
||||
for i in $SWAP; do
|
||||
swapon -p 10000 $SWAP 2>&1 > /dev/null
|
||||
swapon -p 10000 $SWAP
|
||||
done
|
||||
sysctl -w vm.swappiness=10 2>&1 > /dev/null
|
||||
fi
|
||||
)&
|
||||
;;
|
||||
unmount)
|
||||
swapoff -a
|
||||
;;
|
||||
esac
|
1
packages/sysutils/util-linux/sysctl.d/swappiness.conf
Normal file
1
packages/sysutils/util-linux/sysctl.d/swappiness.conf
Normal file
@ -0,0 +1 @@
|
||||
vm.swappiness=10
|
22
packages/sysutils/util-linux/system.d/swap.service
Normal file
22
packages/sysutils/util-linux/system.d/swap.service
Normal file
@ -0,0 +1,22 @@
|
||||
[Unit]
|
||||
Description=Mounting swapfile
|
||||
DefaultDependencies=false
|
||||
|
||||
Before=swap.target shutdown.target
|
||||
Conflicts=shutdown.target
|
||||
Wants=swap.target
|
||||
|
||||
ConditionPathExists=/proc/swaps
|
||||
ConditionKernelCommandLine=!noswap
|
||||
ConditionKernelCommandLine=!installer
|
||||
|
||||
[Service]
|
||||
Environment=HOME=/storage
|
||||
Type=oneshot
|
||||
ExecStartPre=/usr/lib/openelec/mount-swap create
|
||||
ExecStart=/usr/lib/openelec/mount-swap mount
|
||||
ExecStop=/usr/lib/openelec/mount-swap unmount
|
||||
RemainAfterExit=yes
|
||||
|
||||
[Install]
|
||||
WantedBy=basic.target
|
Loading…
x
Reference in New Issue
Block a user