From 144d9ee559356b42e1777e4299737b1e5c00d676 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 8 Feb 2014 17:31:18 +0100 Subject: Adjusting internal file of the swap component to match its own boot parameter. --- components/3020-swap | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++ components/3020-swapon | 62 -------------------------------------------------- 2 files changed, 62 insertions(+), 62 deletions(-) create mode 100755 components/3020-swap delete mode 100755 components/3020-swapon (limited to 'components') diff --git a/components/3020-swap b/components/3020-swap new file mode 100755 index 0000000..a1bcdbe --- /dev/null +++ b/components/3020-swap @@ -0,0 +1,62 @@ +#!/bin/sh + +#set -e + +Swap () +{ + for _PARAMETER in ${LIVE_BOOT_CMDLINE} + do + case "${_PARAMETER}" in + live-boot.swap=*|swap=*) + LIVE_SWAP="true" + LIVE_SWAP_DEVICES="${_PARAMETER#*swap=}" + ;; + + live-boot.swap|swap) + LIVE_SWAP="true" + ;; + esac + done + + case "${LIVE_SWAP}" in + true) + ;; + + *) + return 0 + ;; + esac + + LIVE_SWAP_DEVICES="${LIVE_SWAP_DEVICES:-/dev/sd* /dev/vd*}" + + for _DEVICE in $(echo ${LIVE_SWAP_DEVICES} | sed -e 's|,| |g') + do + if [ ! -b "${_DEVICE}" ] + then + continue + fi + + blkid -o udev -p ${_DEVICE%%[0-9]*} | grep -q "^ID_FS_USAGE=raid" && continue + + _MAGIC="$(/bin/dd if=${_DEVICE} bs=4086 skip=1 count=1 2>/dev/null | /bin/dd bs=10 count=1 2>/dev/null)" || continue + + case "${_MAGIC}" in + SWAPSPACE2|SWAP-SPACE) + _SWAP_DEVICES="${_SWAP_DEVICES} ${_DEVICE}" + ;; + esac + done + + # Remove all auto swap entries + if grep -qs "swap swap" /root/etc/fstab.d/swap + then + grep -v "swap swap" /root/etc/fstab.d/swap > /root/etc/fstab.d/swap.tmp + mv /root/etc/fstab.d/swap.tmp /root/etc/fstab.d/swap + fi + + # Add new swap entries + for _DEVICE in ${_SWAP_DEVICES} + do + echo "${_DEVICE} swap swap defaults 0 0" >> /root/etc/fstab.d/swap + done +} diff --git a/components/3020-swapon b/components/3020-swapon deleted file mode 100755 index a1bcdbe..0000000 --- a/components/3020-swapon +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/sh - -#set -e - -Swap () -{ - for _PARAMETER in ${LIVE_BOOT_CMDLINE} - do - case "${_PARAMETER}" in - live-boot.swap=*|swap=*) - LIVE_SWAP="true" - LIVE_SWAP_DEVICES="${_PARAMETER#*swap=}" - ;; - - live-boot.swap|swap) - LIVE_SWAP="true" - ;; - esac - done - - case "${LIVE_SWAP}" in - true) - ;; - - *) - return 0 - ;; - esac - - LIVE_SWAP_DEVICES="${LIVE_SWAP_DEVICES:-/dev/sd* /dev/vd*}" - - for _DEVICE in $(echo ${LIVE_SWAP_DEVICES} | sed -e 's|,| |g') - do - if [ ! -b "${_DEVICE}" ] - then - continue - fi - - blkid -o udev -p ${_DEVICE%%[0-9]*} | grep -q "^ID_FS_USAGE=raid" && continue - - _MAGIC="$(/bin/dd if=${_DEVICE} bs=4086 skip=1 count=1 2>/dev/null | /bin/dd bs=10 count=1 2>/dev/null)" || continue - - case "${_MAGIC}" in - SWAPSPACE2|SWAP-SPACE) - _SWAP_DEVICES="${_SWAP_DEVICES} ${_DEVICE}" - ;; - esac - done - - # Remove all auto swap entries - if grep -qs "swap swap" /root/etc/fstab.d/swap - then - grep -v "swap swap" /root/etc/fstab.d/swap > /root/etc/fstab.d/swap.tmp - mv /root/etc/fstab.d/swap.tmp /root/etc/fstab.d/swap - fi - - # Add new swap entries - for _DEVICE in ${_SWAP_DEVICES} - do - echo "${_DEVICE} swap swap defaults 0 0" >> /root/etc/fstab.d/swap - done -} -- cgit v1.2.3