[Galaxy S I9000 Android Development] .:Crack:.:
Hey,

is everybody sure that init.d works on B2??

this:

#!/system/bin/sh

# screenstate_scaling, governor and threshold control
# original by 'FloHimself'(florian.schaefer@gmail.com)
# modifications by 'zacharias.maladroit' and 'well.heeled.man'

# Further modifications by Efpophis (billcrossley@gmail.com)
# soon: an app to control my extra options

# as it turns out, I get better battery life without this running
# at all. Maybe the thing polling constantly is draining
# the battery faster than if it was just left alone...

GLITCH_DIR=/system/etc/glitch-config

# if our config directory is not there, create it and populate it with
# reasonable defaults. Otherwise, we'll pay attn to what the user has there
if [ ! -d $GLITCH_DIR ]
then
# oops! default to off because this means the kernel probably didn't flash right?!?
SCREENSTATE_SCALING_ACTIVE="inactive"
else

# set this to "active" to use this stuff
SCREENSTATE_SCALING_ACTIVE=`cat ${GLITCH_DIR}/screenstate_scaling`
# use the one configured
SLEEP_GOVERNOR=`cat ${GLITCH_DIR}/sleep_governor`
fi

CPUFREQ_PATH=/sys/devices/system/cpu/cpu0/cpufreq
CPUFREQ_PATH1=/sys/devices/system/cpu/cpufreq

(while [ $SCREENSTATE_SCALING_ACTIVE = "active" ]
do

# the "cat" call blocks on these files if the device is not in the state being checked for
# meaning execution will wait here until the phone goes to sleep. Neat.
SLEEPING=`cat /sys/power/wait_for_fb_sleep`

if [ $SLEEPING = "sleeping" ]; then

# save the current awake gov for restoration later - someone may have changed it
# we can do this since coming into this if statement is edge-sensitive, i/e: it
# only happens when the state initially transitions to "sleeping"
AWAKE_GOVERNOR=`cat ${CPUFREQ_PATH}/scaling_governor`

if [ ! $AWAKE_GOVERNOR = $SLEEP_GOVERNOR ]; then

echo $SLEEP_GOVERNOR > ${CPUFREQ_PATH}/scaling_governor

# gives the system time to apply our setting by
# creating subdirectories if needed, etc
sleep 1
fi

case "$SLEEP_GOVERNOR" in

# =========
# Conservative settings [very conservative](conservative SLEEP_GOVERNOR)
# =========
'conservative')
# default = 80
echo "90" > ${CPUFREQ_PATH}/conservative/up_threshold

# default = 20
echo "50" > ${CPUFREQ_PATH}/conservative/down_threshold

# default = 5
echo "10" > ${CPUFREQ_PATH}/conservative/freq_step

# default = 78124
echo "500000" > ${CPUFREQ_PATH}/conservative/sampling_rate
;;

# =========
# Smartass settings (slightly more battery friendly than Glitch Kernel defaults - peformance penalty unclear)
# =========
'smartass')
# default = 70
echo "50" > ${CPUFREQ_PATH}/smartass/max_cpu_load

# default = 35
echo "30" > ${CPUFREQ_PATH}/smartass/min_cpu_load

# these are the defaults
echo "800000" > ${CPUFREQ_PATH}/smartass/up_min_freq
echo "400000" > ${CPUFREQ_PATH}/smartass/sleep_max_freq
;;

# =========
# Ondemand settings [more aggressive power savings vs. standard ondemand]
# also less responsive, but we don't need responsiveness when the screen is
# off.
# =========
'GlitchOndemand')

# default value = 55
echo "95" > ${CPUFREQ_PATH1}/ondemand/up_threshold

# default value = 40000
echo "300000" > ${CPUFREQ_PATH1}/ondemand/sampling_rate

#Get normal ;)
echo "0" > ${CPUFREQ_PATH1}/ondemand/io_is_busy;
#echo "1" > ${CPUFREQ_PATH1}/ondemand/sampling_down_factor;

#VM
echo 6000 > /proc/sys/vm/dirty_expire_centisecs; # 2000 # 700 is long enough [stability testing]
echo 6000 > /proc/sys/vm/dirty_writeback_centisecs; # 1000 # 500 is long enough [stability testing]
echo 75 > /proc/sys/vm/dirty_background_ratio; # 15 # 10 # 50 #10 #55
echo 90 > /proc/sys/vm/dirty_ratio; # 40 # 90
echo 10 > /proc/sys/vm/vfs_cache_pressure; # 100 while screen off # 200 # 50 # 20 [less reclaim]
;;

# since lazy is on-demand-ish, lets see if the same sleepy settings will save
# us some battery while sleeping.
'lazy')
echo "98" > ${CPUFREQ_PATH}/lazy/up_threshold
echo "300000" > ${CPUFREQ_PATH}/lazy/sampling_rate
;;

#==========
# Powersave settings - nothing here is relevant since powersave sticks to
# the lowest allowable freq. Note that this gov will
# probably be WORSE on power than conservative.
#==========
'powersave')
# nothing to do here
;;

esac

# Finishing.

SLEEPING=
fi

# the "cat" call blocks on these files if the device is not in the state being checked for
# meaning execution will wait here until the phone wakes up. Neat.
AWAKE=`cat /sys/power/wait_for_fb_wake`

if [ $AWAKE = "awake" ]; then
CURRENT_GOV=`cat ${CPUFREQ_PATH}/scaling_governor`

if [ ! $CURRENT_GOV = $AWAKE_GOVERNOR ]; then
echo $AWAKE_GOVERNOR > ${CPUFREQ_PATH}/scaling_governor
sleep 1
fi

# adjust some stuff based on what gov we're using
case "$AWAKE_GOVERNOR" in

# =========
# Smartass settings (restore defaults while awake)
# =========
'smartass')
# default = 70
echo "70" > ${CPUFREQ_PATH}/smartass/max_cpu_load

# default = 35
echo "35" > ${CPUFREQ_PATH}/smartass/min_cpu_load

# these are the defaults
echo "800000" > ${CPUFREQ_PATH}/smartass/up_min_freq
echo "400000" > ${CPUFREQ_PATH}/smartass/sleep_max_freq
;;

# =========
# Ondemand settings [restore defaults while awake]
# =========
'GlitchOndemand')
# default value = 55
echo "65" > ${CPUFREQ_PATH1}/ondemand/up_threshold

# default value = 40000
echo "20000" > ${CPUFREQ_PATH1}/ondemand/sampling_rate

#boost
echo "1" > ${CPUFREQ_PATH1}/ondemand/io_is_busy;

#VM
echo 3000 > /proc/sys/vm/dirty_expire_centisecs;
echo 500 > /proc/sys/vm/dirty_writeback_centisecs;
echo 65 > /proc/sys/vm/dirty_background_ratio;
echo 80 > /proc/sys/vm/dirty_ratio;
echo 1 > /proc/sys/vm/vfs_cache_pressure;
;;

'lazy')
# default value is 90
echo "90" > ${CPUFREQ_PATH}/lazy/up_threshold
# default value 10000
echo "10000" > ${CPUFREQ_PATH}/lazy/sampling_rate
;;

# =========
# Conservative settings [SavagedZen (which is smartass-like) governor-like] (conservative AWAKE_GOVERNOR)
# =========
'conservative')
# default = 80
echo "75" > ${CPUFREQ_PATH}/conservative/up_threshold

# default = 20
echo "30" > ${CPUFREQ_PATH}/conservative/down_threshold

# default = 5
echo "50" > ${CPUFREQ_PATH}/conservative/freq_step

# default = 78124
echo "80000" > ${CPUFREQ_PATH}/conservative/sampling_rate
;;
esac

AWAKE=
fi

SCREENSTATE_SCALING_ACTIVE=`cat ${GLITCH_DIR}/screenstate_scaling`

done &)

and this

#!/system/bin/sh
#
# 89system_tweak V66
# by zacharias.maladroit
# modifications and ideas taken from: ckMod SSSwitch by voku1987 and "battery tweak" (collin_ph@xda)
# OOM/LMK settings by Juwe11
# network security settings inspired by various security, server guides on the web

# ==============================================================
# ==============================================================
# ==============================================================
# One-time tweaks to apply on every boot
# ==============================================================
# ==============================================================
# ==============================================================

STL=`ls -d /sys/block/stl*`;
BML=`ls -d /sys/block/bml*`;
MMC=`ls -d /sys/block/mmc*`;
ZRM=`ls -d /sys/block/zram*`;
MTD=`ls -d /sys/block/mtd*`;

# Optimize non-rotating storage;
for i in $STL $BML $MMC $ZRM $MTD;
do
#IMPORTANT!
if [ -e $i/queue/rotational ];
then
echo 0 > $i/queue/rotational;
fi;
if [ -e $i/queue/nr_requests ];
then
echo 8192 > $i/queue/nr_requests; # for starters: keep it sane
fi;
#CFQ specific
if [ -e $i/queue/iosched/back_seek_penalty ];
then
echo 1 > $i/queue/iosched/back_seek_penalty;
fi;
#CFQ specific
if [ -e $i/queue/iosched/low_latency ];
then
echo 1 > $i/queue/iosched/low_latency;
fi;
#CFQ Specific
if [ -e $i/queue/iosched/slice_idle ];
then
echo 0 > $i/queue/iosched/slice_idle; # previous: 1
fi;
# deadline/VR/SIO scheduler specific
if [ -e $i/queue/iosched/fifo_batch ];
then
echo 1 > $i/queue/iosched/fifo_batch;
fi;
if [ -e $i/queue/iosched/writes_starved ];
then
echo 1 > $i/queue/iosched/writes_starved;
fi;
#CFQ specific
if [ -e $i/queue/iosched/quantum ];
then
echo 8 > $i/queue/iosched/quantum;
fi;
#VR Specific
if [ -e $i/queue/iosched/rev_penalty ];
then
echo 1 > $i/queue/iosched/rev_penalty;
fi;
if [ -e $i/queue/rq_affinity ];
then
echo "1" > $i/queue/rq_affinity;
fi;
done;

#disable iostats to reduce overhead # idea by kodos96 - thanks !
for k in $STL $BML $MMC $ZRM $MTD;
do
if [ -e $k/queue/iostats ];
then
echo "0" > $k/queue/iostats;
fi;
done;

# Remount all partitions with noatime
for k in $(busybox mount | grep relatime | cut -d " " -f3);

do
sync;
busybox mount -o remount,noatime $k;
done;

# =========
# TWEAKS: raising read_ahead_kb cache-value for sd card to 2048 [not needed with above tweak but just in case it doesn't get applied]
# =========
# improved approach of the readahead-tweak:

if [ -e /sys/devices/virtual/bdi/179:0/read_ahead_kb ];
then
/system/xbin/echo "1024" > /sys/devices/virtual/bdi/179:0/read_ahead_kb;
fi;

if [ -e /sys/devices/virtual/bdi/179:8/read_ahead_kb ];
then
/system/xbin/echo "1024" > /sys/devices/virtual/bdi/179:8/read_ahead_kb;
fi;

if [ -e /sys/devices/virtual/bdi/179:28/read_ahead_kb ];
then
/system/xbin/echo "1024" > /sys/devices/virtual/bdi/179:28/read_ahead_kb;
fi;

if [ -e /sys/devices/virtual/bdi/179:33/read_ahead_kb ];
then
/system/xbin/echo "1024" > /sys/devices/virtual/bdi/179:33/read_ahead_kb;
fi;

if [ -e /sys/devices/virtual/bdi/default/read_ahead_kb ];
then
/system/xbin/echo "256" > /sys/devices/virtual/bdi/default/read_ahead_kb;
fi;

# Optimize for read- & write-throughput;
# Optimize for readahead;

for i in $STL $BML $MMC $ZRM $MTD;
do
if [ -e $i/queue/read_ahead_kb ];
then
echo "256" > $i/queue/read_ahead_kb; # yes - I know - this is evil ^^, might help with battery runtime still (in certain workloads)
fi;

done;

# ==============================================================
# ==============================================================
# ==============================================================
# VFS, VM settings
# ==============================================================
# ==============================================================
# ==============================================================

# =========
# TWEAKS: MEMORY SETTINGS for general operation + zcache/zram usage
# =========

# optimizing the system for zcache & zram usage & general VM (compatible with all ROMs)
sysctl -w vm.page-cluster=3;
sysctl -w vm.laptop_mode=0;
sysctl -w vm.dirty_expire_centisecs=3000;
sysctl -w vm.dirty_writeback_centisecs=500;
sysctl -w vm.dirty_background_ratio=65;
sysctl -w vm.dirty_ratio=80;
sysctl -w vm.vfs_cache_pressure=1;
sysctl -w vm.overcommit_memory=1;
sysctl -w vm.oom_kill_allocating_task=0;
sysctl -w vm.panic_on_oom=0;
sysctl -w kernel.panic_on_oops=1;
sysctl -w kernel.panic=0;
sysctl -w vm.swappiness=0;

#echo 3 > /proc/sys/vm/page-cluster; # 12
#echo 0 > /proc/sys/vm/laptop_mode; # do not omit syncing
#echo 3000 > /proc/sys/vm/dirty_expire_centisecs; # 2000 # 700 is long enough [stability testing]
#echo 500 > /proc/sys/vm/dirty_writeback_centisecs; # 1000 # 500 is long enough [stability testing]
#echo 65 > /proc/sys/vm/dirty_background_ratio; # 15 # 10 # 50 #10 #55
#echo 80 > /proc/sys/vm/dirty_ratio; # 40 # 90
#echo 1 > /proc/sys/vm/vfs_cache_pressure; # 100 while screen off # 200 # 50 # 20 [less reclaim] #
#echo 1 > /proc/sys/vm/overcommit_memory;
#echo 0 > /proc/sys/vm/oom_kill_allocating_task;
#echo 0 > /proc/sys/vm/panic_on_oom;
#echo 1 > /proc/sys/kernel/panic_on_oops;
#echo 0 > /proc/sys/kernel/panic;
#echo 0 > /proc/sys/vm/swappiness;

# =========
# TWEAKS: for TCP read/write
# =========

sysctl -w net.ipv4.tcp_timestamps=0;
sysctl -w net.ipv4.tcp_tw_reuse=1;
sysctl -w net.ipv4.tcp_sack=1;
sysctl -w net.ipv4.tcp_dsack=1;
sysctl -w net.ipv4.tcp_tw_recycle=1;
sysctl -w net.ipv4.tcp_window_scaling=1;
sysctl -w net.ipv4.tcp_keepalive_probes=5;
sysctl -w net.ipv4.tcp_keepalive_intvl=30;
sysctl -w net.ipv4.tcp_fin_timeout=30;
#echo 0 > /proc/sys/net/ipv4/tcp_timestamps;
#echo 1 > /proc/sys/net/ipv4/tcp_tw_reuse;
#echo 1 > /proc/sys/net/ipv4/tcp_sack;
#echo 1 > /proc/sys/net/ipv4/tcp_dsack;
#echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle;
#echo 1 > /proc/sys/net/ipv4/tcp_window_scaling;
#echo 5 > /proc/sys/net/ipv4/tcp_keepalive_probes;
#echo 30 > /proc/sys/net/ipv4/tcp_keepalive_intvl;
#echo 30 > /proc/sys/net/ipv4/tcp_fin_timeout;
#echo 524288 > /proc/sys/net/core/wmem_max;
#echo 524288 > /proc/sys/net/core/rmem_max;

sysctl -w net.ipv4.tcp_moderate_rcvbuf=1;
#echo 1 > /proc/sys/net/ipv4/tcp_moderate_rcvbuf # enabled by default
# removes an odd behavior in the 2.6 kernels, whereby the kernel stores the slow start threshold for a client between TCP sessions. This can cause undesired results, as a single period of congestion can affect many subsequent connections.

# ==============================================================
# ==============================================================
# ==============================================================
# network security related settings
# ==============================================================
# ==============================================================
# ==============================================================

# Configure the server to ignore broadcast pings and smurf attacks:
# (smurf-attacks)
sysctl -w net.ipv4.icmp_echo_ignore_broadcasts=1;

#echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts; # default
if [ -e /proc/sys/net/ipv6/icmp_echo_ignore_broadcasts ]
then
echo "1" > /proc/sys/net/ipv6/icmp_echo_ignore_broadcasts; # default
fi;

# Ignore all kinds of icmp packets or pings:
sysctl -w net.ipv4.icmp_echo_ignore_all=1;
#echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_all; # default: 0

if [ -e /proc/sys/net/ipv6/icmp_echo_ignore_all ]
then
echo "1" > /proc/sys/net/ipv6/icmp_echo_ignore_all; # default: 0
fi;
# Some routers send invalid responses to broadcast frames, and each one generates a
# warning that is logged by the kernel. These responses can be ignored:
sysctl -w net.ipv4.icmp_ignore_bogus_error_responses=1;
#echo "1" > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses;

if [ -e /proc/sys/net/ipv6/icmp_ignore_bogus_error_responses ]
then
echo "1" > /proc/sys/net/ipv6/icmp_ignore_bogus_error_responses;
fi;

# Increase the number of outstanding syn requests allowed.
# Note: some people (including myself) have used tcp_syncookies to handle the problem of too many legitimate outstanding SYNs.
sysctl -w net.core.netdev_max_backlog=2500;

# enabling syncookies
sysctl -w net.ipv4.tcp_syncookies=1;

# =========
# TWEAKS: overall
# =========
sysctl -w kernel.sem="500 512000 100 2048";
sysctl -w kernel.shmmax=268435456;
sysctl -w kernel.msgmni=1024;
sysctl -w kernel.hung_task_timeout_secs=30;

# =========
# TWEAKS: new scheduler performance settings (test)
# =========

echo "NO_GENTLE_FAIR_SLEEPERS" > /sys/kernel/debug/sched_features;
echo "NO_NEW_FAIR_SLEEPERS" > /sys/kernel/debug/sched_features;
echo "NO_NORMALIZED_SLEEPER" > /sys/kernel/debug/sched_features;

won't apply.