From 9ead7e36440c7b5f95f49da8f86a4c18903c09d3 Mon Sep 17 00:00:00 2001 From: Andrew Schleifer Date: Thu, 29 Feb 2024 13:46:23 +0000 Subject: [PATCH] remove swapfile script The instructions have, for quite some time now, pointed users at the `discourse-setup` script. That will prompt the user to create a swapfile if necessary and configure relevant sysctls. --- scripts/mk_swapfile | 51 --------------------------------------------- 1 file changed, 51 deletions(-) delete mode 100755 scripts/mk_swapfile diff --git a/scripts/mk_swapfile b/scripts/mk_swapfile deleted file mode 100755 index 3240b4476..000000000 --- a/scripts/mk_swapfile +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash -e -# This script adds a 1GB swapfile to the system - -function do_err() { - code=$? - echo "Command failed with code $code: $BASH_COMMAND" - exit $code - -} -trap do_err ERR - - -function set_swappiness() { - if ! grep -q '^vm.swappiness' /etc/sysctl.conf; then - echo -n 'Setting ' - sysctl -w vm.swappiness=10 - echo vm.swappiness = 10 >> /etc/sysctl.conf - fi -} - -function get_new_swapfile() { - for i in `seq 0 99`; do - if [ ! -e /swapfile.$i ]; then - echo /swapfile.$i - return - fi - done - # Seriously? 100 swapfiles already exist? - echo "too many swapfiles" - exit 1 -} - -[ `id -u` -eq 0 ] || { echo "You must be root to run this script"; exit 1; } - -# how big? default 1GB -declare -i num_gb -num_gb="${1-1}" -[ $num_gb -lt 1 ] && { echo "Please specify an integer >= 1"; exit 1; } -echo "Creating a ${num_gb}GB swapfile..." - -set_swappiness - -SWAPFILE=$(get_new_swapfile) - -umask 077 -dd if=/dev/zero of=$SWAPFILE bs=1k count=$(($num_gb * 1024 * 1024)) conv=excl -mkswap $SWAPFILE -swapon $SWAPFILE -echo "$SWAPFILE swap swap auto 0 0" >> /etc/fstab - -echo 1GiB swapfile successfully added