diff options
| author | Daniel Baumann <mail@daniel-baumann.ch> | 2013-06-24 21:29:10 +0200 |
|---|---|---|
| committer | Daniel Baumann <mail@daniel-baumann.ch> | 2013-06-24 21:33:51 +0200 |
| commit | 0aa07bd386f516176364e710e8b9132036c72986 (patch) | |
| tree | 27e39d4b1a7deedad4adb8b6e62cc01e44c58bc5 /bin | |
| parent | 9bb62c8a50e9e92b0e0d637c624d364be6a911ca (diff) | |
| download | live-boot-0aa07bd386f516176364e710e8b9132036c72986.tar.gz live-boot-0aa07bd386f516176364e710e8b9132036c72986.zip | |
Reorganizing frontend in source tree.
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/live-swapfile | 100 |
1 files changed, 0 insertions, 100 deletions
diff --git a/bin/live-swapfile b/bin/live-swapfile deleted file mode 100755 index 745fa87..0000000 --- a/bin/live-swapfile +++ /dev/null @@ -1,100 +0,0 @@ -#!/bin/sh - -# File: live-swapfile - create and use a swap file -# Copyright: (C) 2009 Daniel Baumann <mail@daniel-baumann.ch> -# License: GPL-3+ - -set -e - -# Options -_SWAP_DIRECTORY="${_SWAP_DIRECTORY:-/live/swap}" -_SWAP_FILE="${_SWAP_FILE:-swapfile.img}" - -_SWAP_SIZE="${_SWAP_SIZE:-auto}" -_SWAP_FACTOR="${_SWAP_FACTOR:-2}" - -_SWAP_PURGE="${_SWAP_PURGE:-true}" -_FORCE="${_FORCE:-true}" - -case "${1}" in - add) - # Reading size of physical memory - _MEM_TOTAL_KB="$(awk '/^MemTotal: / { print $2 }' /proc/meminfo)" - _MEM_TOTAL_MB="$(expr ${_MEM_TOTAL_KB} / 1024)" - - echo "Found ${_MEM_TOTAL_MB} MB physical memory." - - # Setting size of new swapfile - if [ -z "${_SWAP_SIZE}" ] || [ "${_SWAP_SIZE}" = "auto" ] - then - _SWAP_SIZE_KB="$(expr ${_MEM_TOTAL_KB} '*' ${_SWAP_FACTOR})" - _SWAP_SIZE_MB="$(expr ${_SWAP_SIZE_KB} / 1024)" - else - _SWAP_SIZE_MB="${_SWAP_SIZE}" - fi - - echo "Requesting ${_SWAP_SIZE_MB} MB swapfile." - - # Reading size of old swapfile - if [ -e "${_SWAP_DIRECTORY}/${_SWAP_FILE}" ] - then - _SWAP_FILESIZE="$(ls -hl ${_SWAP_DIRECTORY}/${_SWAP_FILE} | awk '{ print $5 }')" - - echo "Found ${_SWAP_FILESIZE} MB swapfile." - fi - - # Creating new swap file - if [ "${_SWAP_FILESIZE}" != "${_SWAP_SIZE_MB}M" ] - then - if [ "${_FORCE}" = "true" ] - then - # Removing old swapfile - rm -f "${_SWAP_DIRECTORY}/${_SWAP_FILE}" - - echo "Creating ${_SWAP_SIZE_MB} MB swapfile." - - mkdir -p "${_SWAP_DIRECTORY}" - - # Unfortunately, swapon does not support files - # with holes, therefore we cannot preallocate. - dd if=/dev/zero of="${_SWAP_DIRECTORY}/${_SWAP_FILE}" bs=1024k count="${_SWAP_SIZE_MB}" - else - echo "Exit." - return 1 - fi - fi - - echo "Enabling ${_SWAP_DIRECTORY}/${_SWAP_FILE}." - - mkswap "${_SWAP_DIRECTORY}/${_SWAP_FILE}" - swapon "${_SWAP_DIRECTORY}/${_SWAP_FILE}" - ;; - - rm|remove) - if grep -qs "${_SWAP_DIRECTORY}/${_SWAP_FILE}" /proc/swaps - then - echo "Disabling ${_SWAP_DIRECTORY}/${_SWAP_FILE}." - - swapoff "${_SWAP_DIRECTORY}/${_SWAP_FILE}" - fi - - if [ "${_SWAP_PURGE}" = "true" ] - then - echo "Removing ${_SWAP_DIRECTORY}/${_SWAP_FILE}." - - rm -f "${_SWAP_DIRECTORY}/${_SWAP_FILE}" - - __DIRECTORY="${_SWAP_DIRECTORY}" - while [ "${__DIRECTORY}" != "/" ] - do - rmdir --ignore-fail-on-non-empty "${__DIRECTORY}" - __DIRECTORY="$(dirname ${__DIRECTORY})" - done - fi - ;; - - *) - echo "Usage: ${0} {add|remove}" - exit 1 - ;; -esac |
