Shell script to print Sysctl.conf


Script ini baiknya digunakan untuk membackup configurasi default sebelum melakukan perubahan  beberapa parameter di /etc/sysctrl.conf. Sehingga apabila terjadi hal yang tidak sesuai dengan yang di harapkan dapat di restore ke default value.

#!/bin/bash

#create moses@intelix.co.id
echo “Default value /etc/sysctrl.conf”
echo “====================================================”
#grep -v “^#” /etc/sysctrl.conf | sed -e ‘/^$/d’
cat /etc/sysctl.conf | sed ‘/ *#/d; /^ *$/d’
echo “”
i=0
DIR_TCP_KERNEL=”/proc/sys/net/ipv4/ /proc/sys/kernel/ /proc/sys/net/core/ /proc/sys/fs/ /proc/sys/vm/”
for kernel in $DIR_TCP_KERNEL;
do
i=`expr $i + 1`
echo “”
echo “Directory  = “$kernel
echo “====================================================”
for tcp in `ls -l $kernel | awk ‘{print $9}’`;
do
if [ -f $kernel$tcp ]; then
case $i in
1)
path_file=”net.ipv4.$tcp = ”
;;
2)
path_file=”kernel.$tcp = ”
;;
3)
path_file=”net.core.$tcp = ”
;;
4)
path_file=”fs.$tcp = ”
;;
5)
path_file=”vm.$tcp = ”
;;
esac
file_value=`cat $kernel$tcp`
printf ‘%s %s\n’ “$path_file” “$file_value”
fi
done
done

Cara menjalankannnya:

sh /dir/filename.sh > kernel.txt
Thx

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

shisdew

Listens until think alike

moses.spaceku@yahoo.com / voip ipbx

Hosted PBX, IP-PBX SOHO/ CALL CENTER, VOICE GATEWAY, VOICE CARD, COST EFECTIVE SOLUTIONS (LCR), GSM/CDMA GATEWAY

%d bloggers like this: