From 3c1792235f4d49f5be90d3c36917b2d604c15a0a Mon Sep 17 00:00:00 2001 From: sc-idevops Date: Thu, 23 Feb 2023 04:48:32 -0500 Subject: [PATCH] now takes input if not given --- scripts/swappiness.sh | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/scripts/swappiness.sh b/scripts/swappiness.sh index e53b8b1..efe72dd 100755 --- a/scripts/swappiness.sh +++ b/scripts/swappiness.sh @@ -1,14 +1,10 @@ -#!/bin/sh -if [ $(id -u) -ne 0 ] - then echo "Please run as root" - exit 1 -fi - +#!/bin/bash if [ -z "$1" ] then - echo "Please provide a number to set swappiness value!" && exit 2 + read -p 'swappiness value: ' sw else - sudo echo "vm.swappiness="$1 >> /etc/sysctl.conf - sudo sysctl -p -fi + sw=$1 +fi +echo "vm.swappiness="$sw | sudo tee -a /etc/sysctl.conf +sudo sysctl -p