checks for root, appends to end of file

This commit is contained in:
Stefen Auris 2018-01-05 17:46:35 -05:00
parent f29cf06931
commit 692a4ae608
2 changed files with 11 additions and 5 deletions

View file

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