now takes input if not given

This commit is contained in:
Stefen Auris 2023-02-23 04:48:32 -05:00
parent 0eb174c22f
commit 3c1792235f

View file

@ -1,14 +1,10 @@
#!/bin/sh #!/bin/bash
if [ $(id -u) -ne 0 ]
then echo "Please run as root"
exit 1
fi
if [ -z "$1" ] if [ -z "$1" ]
then then
echo "Please provide a number to set swappiness value!" && exit 2 read -p 'swappiness value: ' sw
else else
sudo echo "vm.swappiness="$1 >> /etc/sysctl.conf sw=$1
sudo sysctl -p fi
fi echo "vm.swappiness="$sw | sudo tee -a /etc/sysctl.conf
sudo sysctl -p