sunetdrive/templates/scriptreceiver/makeswap.erb.sh

13 lines
296 B
Bash
Raw Normal View History

2023-02-14 11:07:43 +00:00
#!/bin/bash
if ! [[ -f /swapfile ]]; then
gb=$(free --gibi| grep Mem: | awk '{print $2}')
fallocate -l "${gb}G" /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
if ! grep -E '^(#)?/swapfile' /etc/fstab; then
echo '/swapfile none swap sw 0 0' >> /etc/fstab
fi
fi