#!/bin/sh
[ "$(whoami)" != 'root' ] && ( echo you are using a non-privileged account; exit 1 )

#push options directly
if  [ "$1" == 'KillAllocatingTask' ]; then echo "$2" > /proc/sys/vm/oom_kill_allocating_task; fi 
if  [ "$1" == 'PageCluster' ]; then echo "$2" > /proc/sys/vm/page-cluster; fi  
if  [ "$1" == 'LaptopMode' ]; then echo "$2" > /proc/sys/vm/laptop_mode; fi  
if  [ "$1" == 'DirtyExpireCentisecs' ]; then echo "$2" > /proc/sys/vm/dirty_expire_centisecs; fi  
if  [ "$1" == 'TCPTimestamps' ]; then echo "$2" > /proc/sys/net/ipv4/tcp_timestamps; fi  
if  [ "$1" == 'DirtyWritebackCentisecs' ]; then echo "$2" > /proc/sys/vm/dirty_writeback_centisecs; fi  
if  [ "$1" == 'TCPNoMetricsSave' ]; then echo "$2" > /proc/sys/net/ipv4/tcp_no_metrics_save; fi  
if  [ "$1" == 'DirtyRatio' ]; then echo "$2" > /proc/sys/vm/dirty_ratio; fi  
if  [ "$1" == 'Swappiness' ]; then echo "$2" > /proc/sys/vm/swappiness; fi  
if  [ "$1" == 'DirtyBGDRatio' ]; then echo "$2" > /proc/sys/vm/dirty_background_ratio; fi  
if  [ "$1" == 'VFSCachePressure' ]; then echo "$2" > /proc/sys/vm/vfs_cache_pressure; fi  

#new options for possible interactivity improvement under high I/O load 
if  [ "$1" == 'mmc0requests' ]; then echo "$2" > /sys/block/mmcblk0/queue/nr_requests; fi  
if  [ "$1" == 'mmc1requests' ]; then echo "$2" > /sys/block/mmcblk1/queue/nr_requests; fi  
if  [ "$1" == 'minFreekbytes' ]; then echo "$2" > /proc/sys/vm/min_free_kbytes; fi  

#copy/remove tuning file
if  [ "$1" == 'copyTuning_temp' ]; then cp /home/user/.swappolube/swappolube_config_temp /etc/event.d/tuning; fi  
if  [ "$1" == 'deleteTuning' ]; then rm /etc/event.d/tuning; fi  
