Commit 0fa5f49c authored by Romain Reuillon's avatar Romain Reuillon
Browse files

file variable

parent 33906e5c
#!/bin/sh
SWAPFILE=/data/swapfile
if [ "$#" -ne 1 ]; then
echo "Illegal number of parameters"
fi
......@@ -8,16 +10,16 @@ fi
swapsize=$1
# does the swap file already exist?
grep -q "swapfile" /etc/fstab && ls /swapfile
grep -q $SWAPFILE /etc/fstab && ls $SWAPFILE
# if not then create it
if [ $? -ne 0 ]; then
echo 'swapfile not found. Adding swapfile.'
fallocate -l ${swapsize}M /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo '/swapfile none swap defaults 0 0' >> /etc/fstab
fallocate -l ${swapsize}M $SWAPFILE
chmod 600 $SWAPFILE
mkswap $SWAPFILE
swapon $SWAPFILE
echo "$SWAPFILE none swap defaults 0 0" >> /etc/fstab
else
echo 'swapfile found. No changes made.'
fi
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment