HEX
Server: Apache/2.4.41
System: Linux mainweb 5.4.0-182-generic #202-Ubuntu SMP Fri Apr 26 12:29:36 UTC 2024 x86_64
User: nationalmedicaregrp (1119)
PHP: 8.3.7
Disabled: exec,passthru,shell_exec,system,popen,proc_open,pcntl_exec
Upload Files
File: /home/leads/public_html/tools/swap.sh
#!/bin/bash

echo "Let's setup a SWAP partition!"
free -m
read -p "Does SWAP have all zeros? (y/n) " hasswap

if [ "$hasswap" == "y" -o "$hasswap" == "yes" -o "$hasswap" == "Y" ]; then
	echo "No SWAP is already setup. Setting up a 2 GB swap space..."
else
	echo "SWAP is already setup."
    exit 0
fi 

dd if=/dev/zero of=/swapfile count=2048 bs=1M
checkswap=$(ls / | grep swapfile)

if [ "$checkswap" == "swapfile" ]; then
	echo "SWAP location confirmed. Continuing setup..."
else
	echo "Error, the swapfile is not located at the root."
    exit 1
fi 

chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo -e "\n/swapfile   none    swap    sw    0   0" >> /etc/fstab

echo "Complete. SWAP should show non-zero numbers below."
free -m