#!/system/bin/sh
# Copyright (C) 2016 rjramirez2000
# Big thanks for our legend zeppelinrox
# Thanks to Google, xda and to all users who contribute
#
# LS by rjramirez2000/Riki Naoe (THANKS TO PAGET AND XDADEVELOPERS)
#
ver="1.0"
#
# 5-JAN-2016
#
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

if [ ! -d "/data/local/busybox*/xbin" ]; then export "PATH"=$PATH:/system/xbin:/sbin:/vendor/bin:/system/sbin:/system/bin
else export "PATH"=$PATH:/system/xbin:/sbin:/vendor/bin:/system/sbin:/system/bin:$(busybox ls -d /data/local/busybox*/xbin 2>/dev/null)
fi 2>/dev/null
divider="==============================================="
timeblast="0.1"
timeshorter="0.5"
timeshort="1"
timelong="2"
timelonger="5"
init="/system/etc/init.d" 2>/dev/null
core="/system/L_SPEED" 2>/dev/null
backup="/sdcard/LS_backup" 2>/dev/null
bb1="/system/bin/busybox" 2>/dev/null
bb2="/system/xbin/busybox" 2>/dev/null
bb_down="https://play.google.com/store/apps/details?id=stericson.busybox" 2>/dev/null
thread="http://forum.xda-developers.com/android/software-hacking/tweak-l-speed-v1-0-02-02-2015-t3020138" 2>/dev/null
donation="http://forum.xda-developers.com/donatetome.php?u=5514152" 2>/dev/null
bbver=$(busybox | busybox head -n 1 | busybox awk '{print $1,$2}') 2>/dev/null
sestat=$(getenforce) 2>/dev/null
id="$(id)"; id="${id#*=}"; id="${id%%\(*}"; id="${id%% *}"
if [ "$id" != "0" ] && [ "$id" != "root" ]; then
busybox sleep $timeshort
busybox echo ""
busybox echo ""
busybox echo "    Di ka naka root..."
busybox echo "    Pls type mo muna su (terminal emulator)"
busybox echo "    Enable mo root kung rooted ka. (script manager)"
busybox echo ""
busybox sleep $timeshort
exit
fi
busybox clear
busybox echo ""
busybox echo ""
busybox echo ""
busybox echo " Welcome PHC!"
busybox sleep $timeshort
busybox echo "      to Android Optimizer"
busybox sleep $timeshorter
busybox echo "              1.0"
busybox sleep $timeshorter
busybox echo "                    by Riki Naoe/rjramirez2000 (Originally made by Paget and XDADEVELOPERS)"
busybox echo ""
busybox echo ""
busybox echo ""
busybox sleep $timeshorter
busybox echo ""
busybox sleep $timeshorter
busybox echo ""
busybox echo "                    Yun lang! XD"
busybox echo "Joke hehe"
busybox sleep $timelong
busybox clear
busybox echo ""
busybox echo ""
mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null
if [ ! -d "/sqlite_stmt_journals" ]; then 
  busybox mkdir -p /sqlite_stmt_journals; 
fi
if [ ! -d /system/su.d ]; then
busybox mkdir -p /system/su.d/
busybox chmod 755 /system/su.d/
fi
busybox echo "Checking busybox"
    busybox sleep $timeshort
        busybox echo ""
        busybox echo ""
if [ -e $bb1 ]; then
	busybox echo "Nice, meron kang $bbver"
	busybox echo ""
  elif [ -e $bb2 ]; then
	busybox echo "Nice, meron kang $bbver"
	busybox echo ""
		else
	busybox echo "Aw, wala kang busybox!!!"
	busybox sleep $timeshorter
	busybox echo "Gusto mo bang i-download?"
  busybox sleep $timeshorter
	busybox echo "[ 1 = I-download | 2 = Mamaya na...]:"
	read -r option
		if [ "$option" -eq 1 ]; then
			su -c "LD_LIBRARY_PATH=/vendor/lib:/system/lib am start $bb_down"
     busybox clear
     exit
				else
			busybox echo "     Pag-nadownload mo na yung Busybox.."
			busybox sleep $timeshort
			busybox echo "          Balik ka dito!!! =)"
			busybox sleep $timeshort
			busybox echo "                Good luck!!!"
			busybox sleep $timelong
     busybox clear
     exit
		fi
fi
busybox echo ""
busybox sleep $timelong
busybox echo "Checking init.d support"
busybox echo ""
busybox sleep $timeshort
        if [ -e $init ]; then
busybox echo "Yun, sinusuportahan ng device mo ang init.d!!"
busybox sleep $timelong
    else
busybox echo "Aw, di naka enable init.d. Enable mo!"
busybox sleep $timeshort
busybox echo " Installer will now create"
busybox sleep $timeshort
busybox echo "only init.d folder"
busybox sleep $timeshort
busybox echo "You need to enable init.d support later"
busybox echo "From PHC Android Optimizer"
busybox sleep $timelong
busybox mkdir -p $init/
busybox chmod 755 $init/
busybox chown 0:0 $init/
  fi
if [ ! -d $core ]; then
busybox mkdir -p $core
busybox chmod 755 $core
busybox mkdir -p $core/LOGS
busybox chmod 755 $core/LOGS
touch $core/LOGS/dummy_file
fi
  for file in $core/LS00*
do
  busybox rm -rf $file 2>/dev/null
done
#
#
#   Init.d enabler
#
#
#
busybox cat >> $core/LS00Init_d.sh <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#  GNU General Public License for more details.
#  You should have received a copy of the GNU General Public License along with this program.  If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

/system/xbin/sysinit

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
	busybox chmod 755 $core/LS00Init_d.sh
	busybox chown 0:0 $core/LS00Init_d.sh
if [ -f /system/su.d/LS00init_d.sh ]; then
  busybox rm -rf /system/su.d/LS00init_d.sh
  busybox cp -f $core/LS00Init_d.sh /system/su.d/LS00init_d.sh
	busybox chmod 755 /system/su.d/LS00init_d.sh
	busybox chown 0:2000 /system/su.d/LS00init_d.sh
elif [ -f /system/etc/install-recovery-2.sh ]; then
  busybox rm -rf /system/etc/install-recovery-2.sh
  busybox cp -f $core/LS00Init_d.sh /system/etc/install-recovery-2.sh
  	busybox chmod 755 /system/etc/install-recovery-2.sh
	busybox chown 0:2000 /system/etc/install-recovery-2.sh
fi
#
#
#   Sysinit file (init.d trigger)
#
#
#
busybox cat >> $core/LS00Sysinit <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#  GNU General Public License for more details.
#  You should have received a copy of the GNU General Public License along with this program.  If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

busybox sleep 60

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

export PATH=/sbin:/system/sbin:/system/bin:/system/xbin
busybox run-parts /system/etc/init.d/

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Sysinit
busybox chown 0:0 $core/LS00Sysinit
if [ -f /system/xbin/sysinit ]; then
  busybox rm -rf /system/xbin/sysinit
  busybox cp -f $core/LS00Sysinit /system/xbin/sysinit
  busybox chmod 755 /system/xbin/sysinit
  busybox chown 0:0 /system/xbin/sysinit
fi
#
#
#   LSPEED Status
#
#
#
busybox cat >> $core/LS00LSPEED <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

busybox mkdir -p /tmp
busybox chmod 755 /tmp

LS=/tmp/LSPEED.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox touch \$LS

busybox echo "L SPEED dummy file" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00LSPEED
busybox chown 0:0 $core/LS00LSPEED
#
#
#   MCPS
#
#
#
busybox cat >> $core/LS00MCPS <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00MCPS.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "CPU multicore power save is running..." | busybox tee -a \$LS

# MCPS
if [ -f "/sys/devices/system/cpu/sched_mc_power_savings" ]; then
busybox echo "2" > /sys/devices/system/cpu/sched_mc_power_savings;
fi;

if busybox grep 2 /sys/devices/system/cpu/sched_mc_power_savings; then
busybox echo "Feature enabled" | busybox tee -a \$LS; else
busybox echo "This feature is not avaible for you, because your device is not multi core or your CPU doesn't support it" | busybox tee -a \$LS

fi

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00MCPS
busybox chown 0:0 $core/LS00MCPS
#
#
#   CPU Optimizer
#
#
#
busybox cat >> $core/LS00CPU_Optimizer <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00CPU_Optimizer.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Optimizing CPU.." | busybox tee -a \$LS

# CPU_Optimizer
# Source - google code
# Thanks to @fivefour
pid=\$(busybox pgrep surfaceflinger 2>/dev/null);
busybox echo "\$pid" >> /dev/cpuctl/cgroup.procs 2>/dev/null;
for i in /proc/\$pid/task; do
  busybox echo "\$i" >> /dev/cpuctl/tasks 2>/dev/null;
done;
pid=\$(busybox pgrep binder 2>/dev/null);
busybox echo "\$pid" >> /dev/cpuctl/cgroup.procs 2>/dev/null;
for i in /proc/\$pid/task; do
  busybox echo "\$i" >> /dev/cpuctl/tasks 2>/dev/null;
done;

busybox echo "96" > /dev/cpuctl/bg_non_interactive/cpu.shares 2>/dev/null;

busybox echo "" | busybox tee -a \$LS
busybox echo "CPU is optimized" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00CPU_Optimizer
busybox chown 0:0 $core/LS00CPU_Optimizer
#
#
#   Selinux enforce
#
#
#
busybox cat >> $core/LS00Selinux_Enforce <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

busybox chmod 666 /sys/fs/selinux/enforce
setenforce 1
busybox echo "1" > /sys/fs/selinux/enforce
busybox chmod 444 /sys/fs/selinux/enforce

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Selinux_Enforce
busybox chown 0:0 $core/LS00Selinux_Enforce
#
#
#   Selinux permissive
#
#
#
busybox cat >> $core/LS00Selinux_Permissive <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

busybox chmod 666 /sys/fs/selinux/enforce
setenforce 0
busybox echo "0" > /sys/fs/selinux/enforce
busybox chmod 444 /sys/fs/selinux/enforce

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Selinux_Permissive
busybox chown 0:0 $core/LS00Selinux_Permissive
#
#
#   Cleaner
#
#
#
busybox cat >> $core/LS00Cleaner <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
mount -o remount,rw /data 2>/dev/null
mount -o remount,rw /cache 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw /data 2>/dev/null
busybox mount -o remount,rw /cache 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00Cleaner.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Cleaner script is running..." | busybox tee -a \$LS

busybox rm -f /cache/*.apk 2>/dev/null
busybox rm -f /cache/*.tmp 2>/dev/null
busybox rm -f /cache/*.log 2>/dev/null
busybox rm -f /cache/*.txt 2>/dev/null
busybox rm -f /cache/recovery/* 2>/dev/null
busybox rm -f /data/*.log 2>/dev/null
busybox rm -f /data/*.txt 2>/dev/null
busybox rm -f /data/anr/*.log 2>/dev/null
busybox rm -f /data/anr/*.txt 2>/dev/null
busybox rm -f /data/backup/pending/*.tmp 2>/dev/null
busybox rm -f /data/cache/*.* 2>/dev/null
busybox rm -f /data/dalvik-cache/*.apk 2>/dev/null
busybox rm -f /data/dalvik-cache/*.tmp 2>/dev/null
busybox rm -f /data/dalvik-cache/*.log 2>/dev/null
busybox rm -f /data/dalvik-cache/*.txt 2>/dev/null
busybox rm -f /data/data/*.log 2>/dev/null
busybox rm -f /data/data/*.txt 2>/dev/null
busybox rm -f /data/log/*.log 2>/dev/null
busybox rm -f /data/log/*.txt 2>/dev/null
busybox rm -f /data/local/*.apk 2>/dev/null
busybox rm -f /data/local/*.log 2>/dev/null
busybox rm -f /data/local/*.txt 2>/dev/null
busybox rm -f /data/local/tmp/*.log 2>/dev/null
busybox rm -f /data/local/tmp/*.txt 2>/dev/null
busybox rm -f /data/last_alog/*.log 2>/dev/null
busybox rm -f /data/last_alog/*.txt 2>/dev/null
busybox rm -f /data/last_kmsg/*.log 2>/dev/null
busybox rm -f /data/last_kmsg/*.txt 2>/dev/null
busybox rm -f /data/mlog/* 2>/dev/null
busybox rm -f /data/tombstones/*.log 2>/dev/null
busybox rm -f /data/tombstones/*.txt 2>/dev/null
busybox rm -f /data/system/*.log 2>/dev/null
busybox rm -f /data/system/*.txt 2>/dev/null
busybox rm -f /data/system/dropbox/*.log 2>/dev/null
busybox rm -f /data/system/dropbox/*.txt 2>/dev/null
busybox rm -f /data/system/usagestats/*.log 2>/dev/null
busybox rm -f /data/system/usagestats/*.txt 2>/dev/null

export sampling_rate=10000
export up_threshold=80

busybox echo "memory cleaner--------[OK]" | busybox tee -a \$LS

for file in /data/anr/*.*
do
  if [ -e "\$file" ]
  then
	busybox echo "-anr not cleaned" | busybox tee -a \$LS
else
	busybox echo "-anr cleaned" | busybox tee -a \$LS
fi
done

for file in /data/local/tmp/*.*
do
  if [ -e "\$file" ]
  then
	busybox echo "-local/tmp not cleaned" | busybox tee -a \$LS 
else
	busybox echo "-local/tmp cleaned" | busybox tee -a \$LS
fi
done

for file in /data/cache/*.*
do
  if [ -e "\$file" ]
  then
	busybox echo "-cache not cleaned" | busybox tee -a \$LS
else
	busybox echo "-cache cleaned" | busybox tee -a \$LS
fi
done

for file in /data/last_log/*.*
do
  if [ -e "\$file" ]
  then
	busybox echo "-log not cleaned" | busybox tee -a \$LS
else
	busybox echo "-log cleaned" | busybox tee -a \$LS
fi
done

for file in /data/tombstones/*.*
do
  if [ -e "\$file" ]
  then
	busybox echo "-tombstones not cleaned" | busybox tee -a \$LS
else
	busybox echo "-tombstones cleaned" | busybox tee -a \$LS
fi
done

busybox echo "" | busybox tee -a \$LS
busybox echo "All junk directories are now cleaned" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Cleaner
busybox chown 0:0 $core/LS00Cleaner
#
#
#   Seeder Light
#
#
#
busybox cat >> $core/LS00Seeder_Light <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00Seeder.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Activating light seeder profile.." | busybox tee -a \$LS

busybox sysctl -e -w kernel.random.read_wakeup_threshold=128
busybox sysctl -e -w kernel.random.write_wakeup_threshold=256

busybox sleep 1

if grep "128" proc/sys/kernel/random/read_wakeup_threshold; then
busybox echo "Light seeder profile is activated.." | busybox tee -a \$LS
else
busybox echo "Light seeder profile is not activated.." | busybox tee -a \$LS
fi

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Seeder_Light
busybox chown 0:0 $core/LS00Seeder_Light
#
#
#   Seeder Enlarger
#
#
#
busybox cat >> $core/LS00Seeder_Enlarger <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00Seeder.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Activating enlarger seeder profile.." | busybox tee -a \$LS

busybox sysctl -e -w kernel.random.read_wakeup_threshold=64
busybox sysctl -e -w kernel.random.write_wakeup_threshold=896

busybox sleep 1

if grep "64" /proc/sys/kernel/random/read_wakeup_threshold; then
busybox echo "Enlarger seeder profile is activated.." | busybox tee -a \$LS
else
busybox echo "Enlarger seeder profile is not activated.." | busybox tee -a \$LS
fi

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Seeder_Enlarger
busybox chown 0:0 $core/LS00Seeder_Enlarger
#
#
#   Seeder Moderate
#
#
#
busybox cat >> $core/LS00Seeder_Moderate <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00Seeder.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Activating moderate seeder profile.." | busybox tee -a \$LS

busybox sysctl -e -w kernel.random.read_wakeup_threshold=1366
busybox sysctl -e -w kernel.random.write_wakeup_threshold=2048

busybox sleep 1

if grep "1366" /proc/sys/kernel/random/read_wakeup_threshold; then
busybox echo "Moderate seeder profile is activated.." | busybox tee -a \$LS
else
busybox echo "Moderate seeder profile is not activated.." | busybox tee -a \$LS
fi

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Seeder_Moderate
busybox chown 0:0 $core/LS00Seeder_Moderate
#
#
#   Seeder Aggressive
#
#
#
busybox cat >> $core/LS00Seeder_Aggressive <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00Seeder.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Activating aggressive seeder profile.." | busybox tee -a \$LS

busybox sysctl -e -w kernel.random.read_wakeup_threshold=1708
busybox sysctl -e -w kernel.random.write_wakeup_threshold=2048

busybox sleep 1

if grep "1708" /proc/sys/kernel/random/read_wakeup_threshold; then
busybox echo "Aggressive seeder profile is activated.." | busybox tee -a \$LS
else
busybox echo "Aggressive seeder profile is not activated.." | busybox tee -a \$LS
fi

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Seeder_Aggressive
busybox chown 0:0 $core/LS00Seeder_Aggressive
#
#
#   Ram Manager Multitasking
#
#
#
busybox cat >> $core/LS00RAM_Manager_MT <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00RAM_Manager.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log " | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Tweaking minfree, cost & debug values..." | busybox tee -a \$LS

# Cost
if [ -e /sys/module/lowmemorykiller/parameters/cost ]; then
busybox chmod 644 /sys/module/lowmemorykiller/parameters/cost
busybox echo "64" > /sys/module/lowmemorykiller/parameters/cost
fi

# Minfree Values 
RAM=\$((\$(busybox awk '/MemTotal/{print \$2}' /proc/meminfo)/1024))

lmk1=\$((RAM*2*1024/100/4));
lmk2=\$((RAM*3*1024/100/4));
lmk3=\$((RAM*4*1024/100/4));
lmk4=\$((RAM*5*1024/100/4));
lmk5=\$((RAM*6*1024/100/4));
lmk6=\$((RAM*7*1024/100/4));

busybox chmod 644 /sys/module/lowmemorykiller/parameters/minfree
busybox echo "\$lmk1,\$lmk2,\$lmk3,\$lmk4,\$lmk5,\$lmk6" > /sys/module/lowmemorykiller/parameters/minfree
busybox echo "" | busybox tee -a \$LS
busybox echo "Multitasking RAM manager for \$RAM mb devices successfully applied.." | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00RAM_Manager_MT
busybox chown 0:0 $core/LS00RAM_Manager_MT
#
#
#   Ram Manager Balanced
#
#
#
busybox cat >> $core/LS00RAM_Manager_BL <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00RAM_Manager.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log " | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Tweaking minfree, cost & debug values..." | busybox tee -a \$LS

# Cost
if [ -e /sys/module/lowmemorykiller/parameters/cost ]; then
busybox chmod 644 /sys/module/lowmemorykiller/parameters/cost
busybox echo "32" > /sys/module/lowmemorykiller/parameters/cost
fi

# Minfree Values 
RAM=\$((\$(busybox awk '/MemTotal/{print \$2}' /proc/meminfo)/1024))

lmk1=\$((RAM*3*1024/100/4));
lmk2=\$((RAM*4*1024/100/4));
lmk3=\$((RAM*5*1024/100/4));
lmk4=\$((RAM*7*1024/100/4));
lmk5=\$((RAM*9*1024/100/4));
lmk6=\$((RAM*10*1024/100/4));

busybox chmod 644 /sys/module/lowmemorykiller/parameters/minfree
busybox echo "\$lmk1,\$lmk2,\$lmk3,\$lmk4,\$lmk5,\$lmk6" > /sys/module/lowmemorykiller/parameters/minfree
busybox echo "" | busybox tee -a \$LS
busybox echo "Balanced RAM manager for \$RAM mb devices successfully applied.." | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00RAM_Manager_BL
busybox chown 0:0 $core/LS00RAM_Manager_BL
#
#
#   Ram Manager Gaming
#
#
#
busybox cat >> $core/LS00RAM_Manager_GM <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00RAM_Manager.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log " | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Tweaking minfree, cost & debug values..." | busybox tee -a \$LS

# Cost
if [ -e /sys/module/lowmemorykiller/parameters/cost ]; then
busybox chmod 644 /sys/module/lowmemorykiller/parameters/cost
busybox echo "16" > /sys/module/lowmemorykiller/parameters/cost
fi

# Minfree Values 
RAM=\$((\$(busybox awk '/MemTotal/{print \$2}' /proc/meminfo)/1024))

lmk1=\$((RAM*2*1024/100/4));
lmk2=\$((RAM*3*1024/100/4));
lmk3=\$((RAM*6*1024/100/4));
lmk4=\$((RAM*10*1024/100/4));
lmk5=\$((RAM*14*1024/100/4));
lmk6=\$((RAM*15*1024/100/4));

busybox chmod 644 /sys/module/lowmemorykiller/parameters/minfree
busybox echo "\$lmk1,\$lmk2,\$lmk3,\$lmk4,\$lmk5,\$lmk6" > /sys/module/lowmemorykiller/parameters/minfree
busybox echo "" | busybox tee -a \$LS
busybox echo "Gaming RAM manager for \$RAM mb devices successfully applied.." | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00RAM_Manager_GM
busybox chown 0:0 $core/LS00RAM_Manager_GM
#
#
#   OOM Killer Enabled
#
#
#
busybox cat >> $core/LS00OOM_Enabled <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00OOM_Killer.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Activating OOM killer.." | busybox tee -a \$LS

busybox sysctl -e -w vm.oom_dump_tasks=1
busybox sysctl -e -w vm.oom_kill_allocating_task=1

busybox echo "OOM killer is activated.." | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00OOM_Enabled
busybox chown 0:0 $core/LS00OOM_Enabled
#
#
#   OOM Killer Disabled
#
#
#
busybox cat >> $core/LS00OOM_Disabled <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00OOM_Killer.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Deactivating OOM killer.." | busybox tee -a \$LS

busybox sysctl -e -w vm.oom_dump_tasks=0
busybox sysctl -e -w vm.oom_kill_allocating_task=0

busybox echo "OOM killer is deactivated.." | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00OOM_Disabled
busybox chown 0:0 $core/LS00OOM_Disabled
#
#
#   Cache Reclaiming Lesser
#
#
#
busybox cat >> $core/LS00CR_Lesser <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00CR.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Lesser cache reclaiming activating" | busybox tee -a \$LS

busybox chmod 644 /proc/sys/vm/*
busybox sysctl -e -w vm.vfs_cache_pressure=10

busybox echo "" | busybox tee -a \$LS
busybox echo "Lesser cache reclaiming is activated" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00CR_Lesser
busybox chown 0:0 $core/LS00CR_Lesser
#
#
#   Cache Reclaiming Less
#
#
#
busybox cat >> $core/LS00CR_Less <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00CR.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Less cache reclaiming activating" | busybox tee -a \$LS

busybox chmod 644 /proc/sys/vm/*
busybox sysctl -e -w vm.vfs_cache_pressure=70

busybox echo "" | busybox tee -a \$LS
busybox echo "Less cache reclaiming is activated" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00CR_Less
busybox chown 0:0 $core/LS00CR_Less
#
#
#   Cache Reclaiming x2
#
#
#
busybox cat >> $core/LS00CR_x2 <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00CR.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "x2 cache reclaiming activating" | busybox tee -a \$LS

busybox chmod 644 /proc/sys/vm/*
busybox sysctl -e -w vm.vfs_cache_pressure=200

busybox echo "" | busybox tee -a \$LS
busybox echo "x2 cache reclaiming is activated" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00CR_x2
busybox chown 0:0 $core/LS00CR_x2
#
#
#   Medium Cache Allocation 
#
#
#
busybox cat >> $core/LS00Allocation_Medium <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00Allocation.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Medium cache allocation activating" | busybox tee -a \$LS

busybox chmod 644 /proc/sys/vm/*
# 150% of physical memory for allocations
busybox sysctl -w vm.overcommit_memory=1
busybox sysctl -w vm.overcommit_ratio=100

busybox echo "" | busybox tee -a \$LS
busybox echo "Medium cache allocation is activated" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Allocation_Medium
busybox chown 0:0 $core/LS00Allocation_Medium
#
#
#   Large Cache Allocation 
#
#
#
busybox cat >> $core/LS00Allocation_Large <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00Allocation.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Large cache allocation activating" | busybox tee -a \$LS

busybox chmod 644 /proc/sys/vm/*
# 150% of physical memory for allocations
busybox sysctl -w vm.overcommit_memory=1
busybox sysctl -w vm.overcommit_ratio=150

busybox echo "" | busybox tee -a \$LS
busybox echo "Large cache allocation is activated" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Allocation_Large
busybox chown 0:0 $core/LS00Allocation_Large
#
#
#  Light Kernel Tweaks
#
#
#
busybox cat >> $core/LS00Kernel_Tweaks_Light <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00Kernel_Tweaks.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Activating light kernel tweaks.." | busybox tee -a \$LS

# Kernel_tweaks
if [ -e /sys/kernel/dyn_fsync/Dyn_fsync_active ]; then
busybox echo "1" > /sys/kernel/dyn_fsync/Dyn_fsync_active
fi
if grep 1 /sys/kernel/dyn_fsync/Dyn_fsync_active; then
busybox echo "Dyn_fsync enabled" | busybox tee -a \$LS
else
busybox echo "Dyn_fsync doesn't exist on your kernel" | busybox tee -a \$LS
fi

#FS tweak
busybox sysctl -w fs.lease-break-time=10
busybox sysctl -w fs.inotify.max_queued_events=32000
busybox sysctl -w fs.inotify.max_user_instances=256
busybox sysctl -w fs.inotify.max_user_watches=10240

busybox echo "File system parameters are updated" | busybox tee -a \$LS

mem=\$((\$(busybox awk '/MemTotal/{print \$2}' /proc/meminfo)))
MFK=\$((mem*3/1024))

busybox chmod 644 /proc/sys/vm/*
busybox sysctl -w vm.dirty_expire_centisecs=500
busybox sysctl -w vm.dirty_writeback_centisecs=3000
busybox sysctl -w vm.block_dump=0
busybox sysctl -w vm.laptop_mode=0
busybox sysctl -w vm.min_free_kbytes=\$MFK
busybox sysctl -w vm.min_free_order_shift=4
busybox sysctl -w vm.oom_dump_tasks=1
busybox sysctl -w vm.page-cluster=2
if [ "\$mem" -lt 524288 ]; then
    busybox sysctl -w vm.dirty_background_ratio=15
    busybox sysctl -w vm.dirty_ratio=30
elif [ "\$mem" -lt 1048576 ]; then
    busybox sysctl -w vm.dirty_background_ratio=10
    busybox sysctl -w vm.dirty_ratio=20
  else
    busybox sysctl -w vm.dirty_background_ratio=5
    busybox sysctl -w vm.dirty_ratio=10
fi
if [ -e /sys/block/zram* ]; then
		busybox sysctl -w vm.swappiness=40
      else
		busybox sysctl -w vm.swappiness=20
fi
busybox echo "" | busybox tee -a \$LS
busybox echo "Light kernel tweaks are activated" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Kernel_Tweaks_Light
busybox chown 0:0 $core/LS00Kernel_Tweaks_Light
#
#
#  Heavy Kernel Tweaks
#
#
#
busybox cat >> $core/LS00Kernel_Tweaks_Heavy <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00Kernel_Tweaks.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Activating heavy kernel tweaks.." | busybox tee -a \$LS

# Kernel_tweaks
busybox sysctl -w kernel.msgmni=32000
busybox sysctl -w kernel.msgmax=8192
busybox sysctl -w kernel.msgmnb=16384
busybox sysctl -w kernel.shmmni=4096
busybox sysctl -w kernel.shmall=2097152
busybox sysctl -w kernel.shmmax=268435456
busybox sysctl -w kernel.sem='250 32000 100 128'
  
if [ -e /sys/kernel/dyn_fsync/Dyn_fsync_active ]; then
busybox echo "1" > /sys/kernel/dyn_fsync/Dyn_fsync_active
fi
if grep 1 /sys/kernel/dyn_fsync/Dyn_fsync_active; then
busybox echo "Dyn_fsync enabled" | busybox tee -a \$LS
else
busybox echo "Dyn_fsync doesn't exist on your kernel" | busybox tee -a \$LS
fi

#FS tweak
busybox sysctl -w fs.lease-break-time=5
busybox sysctl -w fs.inotify.max_queued_events=32000
busybox sysctl -w fs.inotify.max_user_instances=256
busybox sysctl -w fs.inotify.max_user_watches=10240

busybox echo "File system parameters are updated" | busybox tee -a \$LS

# VM tweak
mem=\$((\$(busybox awk '/MemTotal/{print \$2}' /proc/meminfo)))
MFK=\$((mem*3/1024))

busybox chmod 644 /proc/sys/vm/*
busybox sysctl -w vm.dirty_expire_centisecs=500
busybox sysctl -w vm.dirty_writeback_centisecs=3000
busybox sysctl -w vm.block_dump=0
busybox sysctl -w vm.laptop_mode=0
busybox sysctl -w vm.min_free_kbytes=\$MFK
busybox sysctl -w vm.min_free_order_shift=4
busybox sysctl -w vm.oom_dump_tasks=1
busybox sysctl -w vm.page-cluster=2
busybox sysctl -w vm.dirty_background_ratio=20
busybox sysctl -w vm.dirty_ratio=40
if [ -e /sys/block/zram* ]; then
		busybox sysctl -w vm.swappiness=40
      else
		busybox sysctl -w vm.swappiness=20
fi 
busybox echo "" | busybox tee -a \$LS
busybox echo "Heavy kernel tweaks are activated" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Kernel_Tweaks_Heavy
busybox chown 0:0 $core/LS00Kernel_Tweaks_Heavy
#
#
#   Net Tweaks (small buffers)
#
#
#
busybox cat >> $core/LS00Net_Small_Buffers <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00Net_Tweaks_Buffers.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a $LS
busybox echo "Activating small net buffers..." | busybox tee -a \$LS

setprop net.tcp.buffersize.hspa 4096,32768,65536,4096,32768,65536
setprop net.tcp.buffersize.umts 4096,32768,65536,4096,32768,65536
setprop net.tcp.buffersize.edge 4096,32768,65536,4096,32768,65536
setprop net.tcp.buffersize.gprs 4096,32768,65536,4096,32768,65536
setprop net.tcp.buffersize.hsdpa 4096,32768,65536,4096,32768,65536
setprop net.tcp.buffersize.wifi 4096,32768,65536,4096,32768,65536
setprop net.tcp.buffersize.evdo_b 4096,32768,65536,4096,32768,65536
setprop net.tcp.buffersize.lte 4096,32768,65536,4096,32768,65536
setprop net.tcp.buffersize.default 4096,32768,12582912,4096,32768,12582912

busybox echo "Small net buffers are added" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Net_Small_Buffers
busybox chown 0:0 $core/LS00Net_Small_Buffers
#
#
#   Net Tweaks (big buffers)
#
#
#
busybox cat >> $core/LS00Net_Big_Buffers <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00Net_Tweaks_Buffers.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a $LS
busybox echo "Activating big net buffers..." | busybox tee -a \$LS

setprop net.tcp.buffersize.default 6144,87380,110208,6144,16384,110208
setprop net.tcp.buffersize.wifi 262144,524288,1048576,262144,524288,1048576
setprop net.tcp.buffersize.lte 262144,524288,3145728,262144,524288,3145728
setprop net.tcp.buffersize.hsdpa 6144,262144,1048576,6144,262144,1048576
setprop net.tcp.buffersize.evdo_b 6144,262144,1048576,6144,262144,1048576
setprop net.tcp.buffersize.umts 6144,87380,110208,6144,16384,110208
setprop net.tcp.buffersize.hspa 6144,87380,262144,6144,16384,262144
setprop net.tcp.buffersize.gprs 6144,8760,11680,6144,8760,11680
setprop net.tcp.buffersize.edge 6144,26280,35040,6144,16384,35040
setprop ro.ril.enable.fd.plmn.prefix 23402,23410,23411

busybox echo "Big net buffers are added" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Net_Big_Buffers
busybox chown 0:0 $core/LS00Net_Big_Buffers
#
#
#   Net Tweaks (dns)
#
#
#
busybox cat >> $core/LS00Net_Tweaks_DNS <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00Net_Tweaks_DNS.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a $LS
busybox echo "Activating DNS tweak..." | busybox tee -a \$LS

setprop net.dns1 8.8.8.8
setprop net.dns2 8.8.4.4
setprop net.rmnet0.dns1 8.8.8.8
setprop net.rmnet0.dns2 8.8.4.4

busybox echo "DNS tweak is activated" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Net_Tweaks_DNS
busybox chown 0:0 $core/LS00Net_Tweaks_DNS
#
#
#   Net Tweaks (protection)
#
#
#
busybox cat >> $core/LS00Net_Protection <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00Net_Protection.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a $LS
busybox echo "Activating net protection..." | busybox tee -a \$LS

busybox sysctl -w net.ipv4.conf.all.rp_filter=2
busybox sysctl -w net.ipv4.conf.default.rp_filter=2
busybox sysctl -w net.ipv4.tcp_max_syn_backlog=1024
busybox sysctl -w net.ipv4.tcp_synack_retries=2

busybox echo "Net protection is activated" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Net_Protection
busybox chown 0:0 $core/LS00Net_Protection
#
#
#   Net Tweaks (ril)
#
#
#
busybox cat >> $core/LS00Net_Tweaks_RIL <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00Net_RIL.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a $LS
busybox echo "Activating ril tweaks..." | busybox tee -a \$LS

# Thanks to @zeppelinrox
setprop ro.ril.hsxpa 3
setprop ro.ril.gprsclass 12
setprop ro.ril.hep 1
setprop ro.ril.hsdpa.category 8
setprop ro.ril.enable.3g.prefix 1
setprop ro.ril.hsupa.category 6
setprop ro.ril.enable.sdr 1
setprop ro.ril.enable.gea3 1
setprop ro.ril.enable.a52 0
setprop ro.ril.enable.a53 1

busybox echo "Ril tweaks are activated" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Net_Tweaks_RIL
busybox chown 0:0 $core/LS00Net_Tweaks_RIL
#
#
#   IO Boost
#
#
#
busybox cat >> $core/LS00IO_Boost <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00IO_Boost.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Activating I/O boost tweak..." | busybox tee -a \$LS

for S in /sys/block/*
do
  if [ -f \$S/queue/rq_affinity ]; then
    busybox echo "1" > \$S/queue/rq_affinity
  fi
	if [ -f \$S/queue/rotational ]; then
		busybox echo "0" > \$S/queue/rotational
	fi
	if [ -f \$S/queue/iostats ]; then
		busybox echo "0" > \$S/queue/iostats
	fi
	if [ -f \$S/queue/nomerges ]; then
		busybox echo "1" > \$S/queue/nomerges
	fi
done

busybox echo "Queue parameters are changed" | busybox tee -a \$LS

busybox echo "" | busybox tee -a $LS
busybox echo "I/O boost tweak is activated" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00IO_Boost
busybox chown 0:0 $core/LS00IO_Boost
#
#
#   IO Extend Queue
#
#
#
busybox cat >> $core/LS00IO_Queue <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00IO_Queue.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Activating I/O extend queue..." | busybox tee -a \$LS

MMC=/sys/block/mmc*
for S in \$MMC;
do
	if [ -f \$S/queue/nr_requests ]; then
		busybox echo "1024" > \$S/queue/nr_requests
	fi
done

busybox echo "Queue parameters are changed" | busybox tee -a \$LS

busybox echo "" | busybox tee -a $LS
busybox echo "I/O extend queue is activated" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00IO_Queue
busybox chown 0:0 $core/LS00IO_Queue
#
#
#   Debugging
#
#
#
busybox cat >> $core/LS00Debugging <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00Debugging.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Disabling debugging.." | busybox tee -a \$LS

if [ -e /sys/module/lowmemorykiller/parameters/debug_level ]; then
    busybox chmod 644 /sys/module/lowmemorykiller/parameters/debug_level
    busybox echo "0" > /sys/module/lowmemorykiller/parameters/debug_level
fi

for parameter in /sys/module/*
   do
if [ -e $parameter/parameters/debug_mask ]; then
    busybox chmod 644 $parameter/parameters/debug_mask
    busybox echo "0" > $parameter/parameters/debug_mask
fi
done

busybox echo "" | busybox tee -a \$LS
busybox echo "Debugging are disabled" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Debugging
busybox chown 0:0 $core/LS00Debugging
#
#
#   Kernel Panic
#
#
#
busybox cat >> $core/LS00Kernel_Panic <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00Kernel_Panic.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Disabling kernel panic.." | busybox tee -a \$LS

# Kernel_panic
busybox sysctl -w vm.panic_on_oom=0
busybox sysctl -w kernel.softlockup_panic=0
busybox sysctl -w kernel.panic_on_oops=0
busybox sysctl -w kernel.panic=0

busybox echo "" | busybox tee -a \$LS
busybox echo "Kernel panic is disabled" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Kernel_Panic
busybox chown 0:0 $core/LS00Kernel_Panic
#
#
#   Kernel Sleepers
#
#
#
busybox cat >> $core/LS00Kernel_Sleepers <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00Kernel_Sleepers.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Applying kernel sleepers.." | busybox tee -a \$LS

# Kernel sleepers
if [ -e "/sys/kernel/debug/sched_features" ]; then
busybox chmod 644 /sys/kernel/debug/sched_features
mount -t debugfs none /sys/kernel/debug
busybox mount -t debugfs none /sys/kernel/debug
busybox echo "NO_AFFINE_WAKEUPS " > /sys/kernel/debug/sched_features
busybox echo "ARCH_POWER " >> /sys/kernel/debug/sched_features
busybox echo "CACHE_HOT_BUDDY " >> /sys/kernel/debug/sched_features
busybox echo "NO_DOUBLE_TICK " >> /sys/kernel/debug/sched_features
busybox echo "NO_FORCE_SD_OVERLAP " >> /sys/kernel/debug/sched_features
busybox echo "GENTLE_FAIR_SLEEPERS " >> /sys/kernel/debug/sched_features
busybox echo "NO_HRTICK " >> /sys/kernel/debug/sched_features
busybox echo "LAST_BUDDY " >> /sys/kernel/debug/sched_features
busybox echo "LB_BIAS " >> /sys/kernel/debug/sched_features
busybox echo "NO_LB_MIN " >> /sys/kernel/debug/sched_features
busybox echo "NO_NEW_FAIR_SLEEPERS " >> /sys/kernel/debug/sched_features
busybox echo "NO_NEXT_BUDDY " >> /sys/kernel/debug/sched_features
busybox echo "NONTASK_POWER " >> /sys/kernel/debug/sched_features
busybox echo "NO_NORMALIZED_SLEEPERS " >> /sys/kernel/debug/sched_features
busybox echo "NO_OWNER_SPIN " >> /sys/kernel/debug/sched_features
busybox echo "RT_RUNTIME_SHARE " >> /sys/kernel/debug/sched_features
busybox echo "START_DEBIT " >> /sys/kernel/debug/sched_features
busybox echo "TTWU_QUEUE " >> /sys/kernel/debug/sched_features
busybox echo "NO_WAKEUP_OVERLAP " >> /sys/kernel/debug/sched_feature
busybox echo "WAKEUP_PREEMPTION " >> /sys/kernel/debug/sched_features
umount /sys/kernel/debug
busybox umount /sys/kernel/debug
fi

busybox echo "" | busybox tee -a \$LS
busybox echo "Kernel sleepers applied" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Kernel_Sleepers
busybox chown 0:0 $core/LS00Kernel_Sleepers
#
#
#   Kernel samepage merging
#
#
#
busybox cat >> $core/LS00KSM <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00KSM.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a $LS
busybox echo "Activating Kernel samepage merging" | busybox tee -a \$LS

# Kernel samepage merging
busybox chmod 644 /sys/kernel/mm/ksm/*
busybox echo "1" > /sys/kernel/mm/ksm/run
busybox echo "64" > /sys/kernel/mm/ksm/pages_to_scan
busybox echo "500" > /sys/kernel/mm/ksm/sleep_millisecs

busybox echo "" | busybox tee -a \$LS
busybox echo "Kernel samepage merging is activated" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00KSM
busybox chown 0:0 $core/LS00KSM
#
#
#   SD Tweak
#
#
#
busybox cat >> $core/LS00SD <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00SD.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Activating SD speed tweak..." | busybox tee -a \$LS

L=256

MMC=/sys/block/mmc*
for S in \$MMC;
do
	if [ -f \$S/queue/read_ahead_kb ];
	then
		busybox echo "\$L" > \$S/queue/read_ahead_kb;
	fi;
	if [ -f \$S/bdi/read_ahead_kb ];
        then
              busybox echo "\$L" > \$S/bdi/read_ahead_kb;
        fi;
done

busybox echo "" | busybox tee -a \$LS
busybox echo "SD speed tweak is activated" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00SD
busybox chown 0:0 $core/LS00SD
#
#
#   Zipalign
#
#
#
busybox cat >> $core/LS00Zipalign <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00Zipalign.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Starting Automatic ZipAlign" | busybox tee -a \$LS

if [ -f /system/xbin/zipalign ]; then

ZIPALIGNDB=/data/zipalign.db

if [ ! -f \$ZIPALIGNDB ]; then
	touch \$ZIPALIGNDB;
fi;

for DIR in /system/app /data/app /system/priv-app;
do
	cd \$DIR;
	for APK in *.apk */*.apk;
	do
		if [ \$APK -ot \$ZIPALIGNDB ] && [ \$(grep "\$DIR/\$APK" \$ZIPALIGNDB|wc -l) -gt 0 ]; then
			echo "Already checked: \$DIR/\$APK" | tee -a \$LS;
		else
			ZIPCHECK=\$(/system/xbin/zipalign -c -v 4 \$APK | grep FAILED | wc -l);
			if [ \$ZIPCHECK == "1" ]; then
				echo "Now aligning: \$DIR/\$APK" | tee -a \$LS;
				/system/xbin/zipalign -f 4 \$APK /data/local/\$APK;
				rc="\$?";
				if [ \$rc -eq 0 ]; then
					if [ -e "/data/local/\$APK" ]; then
						cp -f -p "/data/local/\$APK" "\$APK" | tee -a \$LS;
						busybox rm -f "/data/local/\$APK";
						grep "\$DIR/\$APK" \$ZIPALIGNDB > /dev/null || echo \$DIR/\$APK >> \$ZIPALIGNDB;
					else
						echo "ZipAligning \$APK Failed (no output file)"  | tee -a \$LS;
					fi;
				else
					[ -f "/data/local/\$APK" ] && busybox rm -f "/data/local/\$APK"
					echo "ZipAligning \$APK Failed (rc: \$rc)"  | tee -a \$LS;
				fi;
			else
				echo "Already aligned: \$DIR/\$APK" | tee -a \$LS;
				grep "\$DIR/\$APK" \$ZIPALIGNDB > /dev/null || echo $DIR/\$APK >> \$ZIPALIGNDB;
			fi;
		fi;
	done;
done;

busybox touch \$ZIPALIGNDB
busybox echo "Automatic ZipAlign finished" | busybox tee -a \$LS
else
busybox echo "Your device doesn't have zipalign binary" | busybox tee -a \$LS
fi

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Zipalign
busybox chown 0:0 $core/LS00Zipalign
#
#
#   Fast Charge
#
#
#
busybox cat >> $core/LS00Fast_Charge <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00Fast_Charge.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Activating fast charging mode..." | busybox tee -a \$LS

#Force fast-charge
if [ -e /sys/kernel/fast_charge/force_fast_charge ]; then
       busybox echo "1" > /sys/kernel/fast_charge/force_fast_charge
fi
if grep 1 /sys/kernel/fast_charge/force_fast_charge; then
busybox echo "Force fast charge enabled enabled" | busybox tee -a \$LS
else
busybox echo "Force fast charge doesn't exist on your kernel" | busybox tee -a \$LS
fi

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Fast_Charge
busybox chown 0:0 $core/LS00Fast_Charge
#
#
#   Google Services Drain Fix
#
#
#
busybox cat >> $core/LS00GSDF <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
# Thanks to @Alcolawl 
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00GSDF.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Activating GP services drain fix..." | busybox tee -a \$LS

su -c pm enable com.google.android.gms/.update.SystemUpdateActivity 
su -c pm enable com.google.android.gms/.update.SystemUpdateService
su -c pm enable com.google.android.gms/.update.SystemUpdateService\$ActiveReceiver 
su -c pm enable com.google.android.gms/.update.SystemUpdateService\$Receiver 
su -c pm enable com.google.android.gms/.update.SystemUpdateService\$SecretCodeReceiver 
su -c pm enable com.google.android.gsf/.update.SystemUpdateActivity 
su -c pm enable com.google.android.gsf/.update.SystemUpdatePanoActivity 
su -c pm enable com.google.android.gsf/.update.SystemUpdateService 
su -c pm enable com.google.android.gsf/.update.SystemUpdateService\$Receiver 
su -c pm enable com.google.android.gsf/.update.SystemUpdateService\$SecretCodeReceiver

busybox echo "" | busybox tee -a \$LS
busybox echo "GP services drain fix is activated" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00GSDF
busybox chown 0:0 $core/LS00GSDF
#
#
#   Kill Google Apps
#
#
#
busybox cat >> $core/LS00KGA <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00KGA.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox sleep 20

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Killing GAPPS processes.." | busybox tee -a \$LS

busybox killall -9 com.google.android.gms
busybox killall -9 com.google.android.gms.persistent
busybox killall -9 com.google.process.gapps
busybox killall -9 com.google.android.gsf
busybox killall -9 com.google.android.gsf.persistent

busybox echo "" | busybox tee -a \$LS
busybox echo "Killing google apps is done!" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00KGA
busybox chown 0:0 $core/LS00KGA
#
#
#   Kill Media Server
#
#
#
busybox cat >> $core/LS00KMS <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00KMS.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Killing media server.." | busybox tee -a \$LS

if [ "\$(pgrep media)" ] && [ "\$(pgrep mediaserver)" ]; then
busybox killall -9 android.process.media;
busybox killall -9 mediaserver;
fi

busybox echo "" | busybox tee -a \$LS
busybox echo "Killing media server is done!" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00KMS
busybox chown 0:0 $core/LS00KMS
#
#
#   Zram
#
#
#
busybox cat >> $core/LS00Zram <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00Zram.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Activating ZRAM.." | busybox tee -a \$LS

RAM=\$((\$(busybox awk '/MemTotal/{print \$2}' /proc/meminfo)/1024))
ZRAM=\$((RAM/4))
algorithm=lz4

if [ -f /sys/block/zram0/disksize ]; then
if [ -f /sys/block/zram0/comp_algorithm ]; then
busybox echo "1" > /sys/module/zswap/parameters/enabled
busybox echo "\$algorithm" > /sys/block/zram0/comp_algorithm
fi
busybox swapoff /dev/block/zram0
busybox echo "1" /sys/devices/virtual/block/zram0/reset
busybox echo \$((ZRAM*1024*1024)) > /sys/block/zram0/disksize
busybox mkswap /dev/block/zram0
busybox swapon /dev/block/zram0
busybox echo "ZRAM is activated" | busybox tee -a \$LS
else
busybox echo "Your kernel doesn't support zram" | busybox tee -a \$LS
fi

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Zram
busybox chown 0:0 $core/LS00Zram
#
#
#   Wifi Sleeper
#
#
#
busybox cat >> $core/LS00Wifi_Sleeper <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00Wifi_Sleeper.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Activating wifi sleeper.." | busybox tee -a \$LS

# wifi_idle_wait value = 30 seconds
sqlite=/system/xbin/sqlite3
wifi_idle_wait=30000

RETURN_VALUE=\$(\$sqlite /data/data/com.android.providers.settings/databases/settings.db "select value from secure where name='wifi_idle_ms'")

if [ "\$RETURN_VALUE" = '' ]; then
   \$sqlite /data/data/com.android.providers.settings/databases/settings.db "insert into secure (name, value) values ('wifi_idle_ms', \$wifi_idle_wait )"
else
   \$sqlite /data/data/com.android.providers.settings/databases/settings.db "update secure set value=\$wifi_idle_wait where name='wifi_idle_ms'"
fi

busybox echo "" | busybox tee -a \$LS
busybox echo "Wifi sleeper is activated.." | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
#
#
#   Flag Tuner
#
#
#
busybox cat >> $core/LS00Flag_Tuner <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00Flag_Tuner.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Activating Flag tuner..." | busybox tee -a \$LS

setprop ENFORCE_PROCESS_LIMIT false
setprop MAX_SERVICE_INACTIVITY false
setprop MIN_HIDDEN_APPS false
setprop CONTENT_APP_IDLE_OFFSET false
setprop EMPTY_APP_IDLE_OFFSET false
setprop ACTIVITY_INACTIVITY_RESET_TIME false
setprop MIN_RECENT_TASKS false
setprop APP_SWITCH_DELAY_TIME false
setprop PROC_START_TIMEOUT false
setprop CPU_MIN_CHECK_DURATION false
setprop GC_TIMEOUT false
setprop SERVICE_TIMEOUT false
setprop MIN_CRASH_INTERVAL false

busybox echo "" | busybox tee -a \$LS
busybox echo "Flag tuner is activated" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Flag_Tuner
busybox chown 0:0 $core/LS00Flag_Tuner
#
#
#   Voice Call
#
#
#
busybox cat >> $core/LS00Voice_Call <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00Voice_Call.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Activating better call quality..." | busybox tee -a \$LS

setprop ro.ril.enable.amr.wideband 1

busybox echo "" | busybox tee -a \$LS
busybox echo "Better call quality is activated" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Voice_Call
busybox chown 0:0 $core/LS00Voice_Call
#
#
#   Blackscreen Issue
#
#
#
busybox cat >> $core/LS00Blackscreen <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00Blackscreen.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Activating black screen issue fix.." | busybox tee -a \$LS

setprop ro.lge.proximity.delay 25
setprop mot.proximity.delay 25

busybox echo "" | busybox tee -a \$LS
busybox echo "Black screen issue fix is activated" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Blackscreen
busybox chown 0:0 $core/LS00Blackscreen
#
#
#   Improve Battery
#
#
#
busybox cat >> $core/LS00Improve_Battery <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00Improve_Battery.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Activating battery improvements..." | busybox tee -a \$LS

setprop debug.sf.hw 1
setprop ro.ril.power_collapse 0
setprop ro.ril.disable.power.collapse 1
setprop persist.sys.use_dithering 0
setprop wifi.supplicant_scan_interval 180
setprop power_supply.wakeup enable
setprop power.saving.mode 1
setprop ro.config.hw_power_saving 1
setprop ro.config.hw_power_saving true
setprop persist.radio.add_power_save 1

busybox echo "" | busybox tee -a \$LS
busybox echo "Battery improvments are enabled" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Improve_Battery
busybox chown 0:0 $core/LS00Improve_Battery
#
#
#   Better Scrolling
#
#
#
busybox cat >> $core/LS00Scrolling <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00Scrolling.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Enabling better scolling.." | busybox tee -a \$LS

# Scrolling cache
setprop persist.sys.scrollingcache 3

busybox echo "Scrolling cache disabled.." | busybox tee -a \$LS

setprop ro.max.fling_velocity 12000
setprop ro.min.fling_velocity 8000

busybox echo "Other parameters tweaked.." | busybox tee -a \$LS

if [ -e /sys/module/tpd_setting/parameters/tpd_mode ]; then
busybox chmod 644 /sys/module/tpd_setting/parameters/tpd_mode
busybox echo "1" > /sys/module/tpd_setting/parameters/tpd_mode
elif [ -e /sys/module/hid_magicmouse/parameters/scroll_speed ]; then
busybox chmod 644 /sys/module/hid_magicmouse/parameters/scroll_speed
busybox echo "63" > /sys/module/hid_magicmouse/parameters/scroll_speed
fi

busybox echo "" | busybox tee -a \$LS
busybox echo "Better scrolling is enabled" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Scrolling
busybox chown 0:0 $core/LS00Scrolling
#
#
#   Faster Boot
#
#
#
busybox cat >> $core/LS00Faster_Boot <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00Faster_Boot.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Activating faster boot..." | busybox tee -a \$LS

setprop ro.config.hw_quickpoweron true

busybox echo "" | busybox tee -a \$LS
busybox echo "Faster boot is activated" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Faster_Boot
busybox chown 0:0 $core/LS00Faster_Boot
#
#
#   Better Image Quality
#
#
#
busybox cat >> $core/LS00Image_Quality <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00Image_Quality.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Activating better image quality..." | busybox tee -a \$LS

setprop ro.media.enc.jpeg.quality 100
setprop ro.media.enc.hprof.vid.fps 60
setprop ro.media.enc.hprof.vid.bps 8000000
setprop ro.media.capture.maxres 8m
setprop ro.media.panorama.defres 3264x1840
setprop ro.media.panorama.frameres 1280x720
setprop ro.camcorder.videoModes true
setprop ro.media.enc.hprof.vid.fps 60
setprop ro.media.dec.aud.wma.enabled 1
setprop ro.media.dec.vid.wmv.enabled 1
setprop ro.media.cam.preview.fps 0
setprop ro.media.capture.flash led
setprop ro.media.capture.flashMinV 3300000
setprop ro.media.capture.torchIntensity 40
setprop ro.media.capture.flashIntensity 70
setprop ro.media.capture.fast.fps 4
setprop ro.media.capture.slow.fps 120

busybox echo "" | busybox tee -a \$LS
busybox echo "Better image quality is activated" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Image_Quality
busybox chown 0:0 $core/LS00Image_Quality
#
#
#   Faster Streaming
#
#
#
busybox cat >> $core/LS00Faster_Streaming <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00Faster_Streaming.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Activating faster streaming..." | busybox tee -a \$LS

setprop media.stagefright.enable-player true
setprop media.stagefright.enable-meta true
setprop media.stagefright.enable-scan true
setprop media.stagefright.enable-http true
setprop media.stagefright.enable-record false
setprop media.stagefright.enable-aac true
setprop media.stagefright.enable-qcp true

busybox echo "" | busybox tee -a \$LS
busybox echo "Faster streaming is activated" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Faster_Streaming
busybox chown 0:0 $core/LS00Faster_Streaming
#
#
#   Liquid UI
#
#
#
busybox cat >> $core/LS00Liquid_UI <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00Liquid_UI.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Activating Liquid UI..." | busybox tee -a \$LS

setprop touch.pressure.scale 2

busybox echo "" | busybox tee -a \$LS
busybox echo "LiquidUI is activated" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Liquid_UI
busybox chown 0:0 $core/LS00Liquid_UI
#
#
#   Disable Logcats
#
#
#
busybox cat >> $core/LS00Disable_Logcats <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00Disable_Logcats.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Disabling logcats..." | busybox tee -a \$LS

setprop logcat.live disable
busybox rm -f /dev/log/main
setprop debugtool.anrhistory 0
setprop profiler.debugmonitor false
setprop profiler.launch false
setprop profiler.hung.dumpdobugreport false
setprop persist.android.strictmode 0

busybox echo "" | busybox tee -a \$LS
busybox echo "Logcats are disabled" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
#
#
#   Fast Dormancy
#
#
#
busybox cat >> $core/LS00Fast_Dormancy <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00Fast_Dormancy.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a $\LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Activating fast dormancy..." | busybox tee -a \$LS

setprop ro.fast.dormancy 1
setprop ro.ril.fast.dormancy.rule 1
setprop persist.radio.data_no_toggle 1

busybox echo "" | busybox tee -a \$LS
busybox echo "Fast dormancy is activated" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Fast_Dormancy
busybox chown 0:0 $core/LS00Fast_Dormancy
#
#
#   Misc Tweaks
#
#
#
busybox cat >> $core/LS00Misc_Tweaks <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00Misc_Tweaks.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Adding L speed tweaks..." | busybox tee -a \$LS

setprop profiler.force_disable_err_rpt 1
setprop ro.com.google.networklocation 0
setprop ro.telephony.call_ring.delay 0

busybox echo "" | busybox tee -a \$LS
busybox echo "L speed tweaks added" | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Misc_Tweaks
busybox chown 0:0 $core/LS00Misc_Tweaks
#
#
#   Assertive Display
#
#
#
busybox cat >> $core/LS00Assertive_Display <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

LS=/system/L_SPEED/LOGS/LS00Assertive_Display.log

if [ -f \$LS ]; then
busybox rm \$LS;
fi;

busybox echo "# L Speed log" | busybox tee -a \$LS
busybox echo "" | busybox tee -a \$LS
busybox echo "Activating assertive display calibration..." | busybox tee -a \$LS


setprop ro.qcom.ad 1
setprop ro.qcom.ad.calib.data /system/etc/ad_calib.cfg

busybox echo "" | busybox tee -a \$LS
busybox echo "Assertive display calibration is activated..." | busybox tee -a \$LS

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Assertive_Display
busybox chown 0:0 $core/LS00Assertive_Display
busybox cat >> $core/LS00ad_calib.cfg <<EOF
#                   Assertive Display Calibration Output File Format
# Calibration config file consists of one or more sections. Each section is set
# of parameter values stored on one line each. Number of parameters (hence number
# of lines in each section is fixed. Order in which parameters are specified in
# given section is fixed as well.
# Comments are supported in configuration file to improve readability of
# calibration configuration parameters. Any line begining with '#' is considered
# as comment and will not be processed further.
# Blank lines are allowed and are ignored. They can be used to improve
# readability of assertive display calibration output file.
# Sections: Any line begining with '=' indicates start of new section in
# calibration output file. Sections, parameters which are part of section and
# order in which they will appear in calibration output file is kept outside
# scope of this documentation in order to have flexibility in development of
# assertive display calibration system. This information can be shared between
# APICAL and Qualcomm as part of assertive display bring ups on given platforms.
# There should not be any spaces betweetn '=' and section name.
# Version 1.0 of calibration output format supports following sections:
# version - Contains assertive display calibration output file format version
# init -  Contains assertive display parameters which are independent of
#	  assertive display mode
# config - Contains assertive display parameters which are dependent on specific
#	   assertive display mode
# Each parameter for assertive display calibration is stored on new line. If
# parameter consists of more than one values (set of values), each value is
# separated by single space (' ') character. In version 1.0  of assertive
# display calibration output file format, all numerical values are in decimal
# unsigned integer format, limited by 32 bits. Range for values or valid value
# for given parameter is outside scope of this documentation. This information
# can be shared between APICAL and Qualcomm as part of assertive display bring
# ups on given platforms.
=version
1.0
# APICAL mode indepent initialization Params
=init
#asym lut
0 211 414 609 796 975 1148 1315 1475 1630 1779 1922 2061 2195 2325 2451 2572 2690 2804 2915 3022 3126 3227 3325 3420 3513 3603 3691 3776 3859 3940 4019 4095
#color correction lut
255 278 302 326 350 374 398 422 446 470 494 517 541 565 589 613 637 661 684 708 732 755 779 803 826 850 874 897 921 945 968 992 1016
# i_control
7 70
# black lvl
0
# white lvl
1023
# variance
65
# limit amplitude
240
# i_dither
0
# slope max
60
# slope min
128
# dither control
5
# format
3
# autosize
0
# frame width
720
# frame height
1280
# logo vertical position
0
# logo horizontal position
0
# BL_linearity_LUT
0 16 32 48 64 80 96 112 128 145 161 177 193 209 225 241 257 273 289 305 321 337 353 369 385 401 418 434 450 466 482 498 514 530 546 562 578 594 610 626 642 658 674 691 707 723 739 755 771 787 803 819 835 851 867 883 899 915 931 947 964 980 996 1012 1028 1044 1060 1076 1092 1108 1124 1140 1156 1172 1188 1204 1220 1237 1253 1269 1285 1301 1317 1333 1349 1365 1381 1397 1413 1429 1445 1461 1477 1493 1510 1526 1542 1558 1574 1590 1606 1622 1638 1654 1670 1686 1702 1718 1734 1750 1766 1783 1799 1815 1831 1847 1863 1879 1895 1911 1927 1943 1959 1975 1991 2007 2023 2039 2056 2072 2088 2104 2120 2136 2152 2168 2184 2200 2216 2232 2248 2264 2280 2296 2312 2329 2345 2361 2377 2393 2409 2425 2441 2457 2473 2489 2505 2521 2537 2553 2569 2585 2602 2618 2634 2650 2666 2682 2698 2714 2730 2746 2762 2778 2794 2810 2826 2842 2858 2875 2891 2907 2923 2939 2955 2971 2987 3003 3019 3035 3051 3067 3083 3099 3115 3131 3148 3164 3180 3196 3212 3228 3244 3260 3276 3292 3308 3324 3340 3356 3372 3388 3404 3421 3437 3453 3469 3485 3501 3517 3533 3549 3565 3581 3597 3613 3629 3645 3661 3677 3694 3710 3726 3742 3758 3774 3790 3806 3822 3838 3854 3870 3886 3902 3918 3934 3950 3967 3983 3999 4015 4031 4047 4063 4079 4095
# BL_linearity_inverse_LUT
0 16 32 48 64 80 96 112 128 145 161 177 193 209 225 241 257 273 289 305 321 337 353 369 385 401 418 434 450 466 482 498 514 530 546 562 578 594 610 626 642 658 674 691 707 723 739 755 771 787 803 819 835 851 867 883 899 915 931 947 964 980 996 1012 1028 1044 1060 1076 1092 1108 1124 1140 1156 1172 1188 1204 1220 1237 1253 1269 1285 1301 1317 1333 1349 1365 1381 1397 1413 1429 1445 1461 1477 1493 1510 1526 1542 1558 1574 1590 1606 1622 1638 1654 1670 1686 1702 1718 1734 1750 1766 1783 1799 1815 1831 1847 1863 1879 1895 1911 1927 1943 1959 1975 1991 2007 2023 2039 2056 2072 2088 2104 2120 2136 2152 2168 2184 2200 2216 2232 2248 2264 2280 2296 2312 2329 2345 2361 2377 2393 2409 2425 2441 2457 2473 2489 2505 2521 2537 2553 2569 2585 2602 2618 2634 2650 2666 2682 2698 2714 2730 2746 2762 2778 2794 2810 2826 2842 2858 2875 2891 2907 2923 2939 2955 2971 2987 3003 3019 3035 3051 3067 3083 3099 3115 3131 3148 3164 3180 3196 3212 3228 3244 3260 3276 3292 3308 3324 3340 3356 3372 3388 3404 3421 3437 3453 3469 3485 3501 3517 3533 3549 3565 3581 3597 3613 3629 3645 3661 3677 3694 3710 3726 3742 3758 3774 3790 3806 3822 3838 3854 3870 3886 3902 3918 3934 3950 3967 3983 3999 4015 4031 4047 4063 4079 4095
# alpha
512
# BL_ATT
0 128 256 384 512 640 737 820 898 973 1047 1124 1204 1289 1379 1475 1575 1681 1794 1912 2036 2167 2305 2450 2601 2760 2927 3101 3283 3473 3672 3879 4095
# ALS_offset
10000
# ALS_thresh
0.1
#APICAL mode specific configuration
=config
# mode
1
# ambient calib lut
0 2048 4096 6144 8192 10240 12288 14336 16384 18432 20480 22528 24576 26624 28672 30720 32768 34815 36863 38911 40959 43007 45055 47103 49151 51199 53247 55295 57343 59391 61439 63487 65535
# back_min
0
# back_max
4096
# backlight scale
4096
# ambient_light_min
0
# filter
1738 6
# calibration_abcd
12 95 0 0
#str limit
128
# temp filter recurs
5
# stabilization iterations
256

EOF
busybox chmod 755 $core/LS00ad_calib.cfg
busybox chown 0:0 $core/LS00ad_calib.cfg
#
#
#   Boost binary
#
#
#
rm -rf /system/xbin/boost
busybox cat >> $core/LS00Boost <<EOF
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#=======================================================================#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
#=======================================================================#

mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null

busybox clear
busybox echo ""
busybox free | busybox awk '/Mem/{print ">>>...Memory Before Boosting: "\$4/1024" MB";}'
busybox sleep 1
busybox echo ""
busybox echo "Dropping cache"
sync
busybox sleep 1
busybox sysctl -w vm.drop_caches=3
busybox sleep 1
dc=/proc/sys/vm/drop_caches
dc_v=\$(busybox cat \$dc)
if [ "\$dc_v" -gt 1 ]; then
busybox sysctl -w vm.drop_caches=1
fi
busybox echo ""
busybox echo ""
busybox echo "BOOSTED!!!"
busybox echo ""
busybox echo ""
busybox free | busybox awk '/Mem/{print ">>>...Memory After Boosting : "\$4/1024" MB";}'
busybox sleep 3

mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null

EOF
busybox chmod 755 $core/LS00Boost
busybox chown 0:0 $core/LS00Boost
cp -f $core/LS00Boost /system/xbin/boost
busybox chmod 755 /system/xbin/boost
busybox chown 0:2000 /system/xbin/boost
mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null
if [ ! -f $init/LSPEED ]; then
busybox echo "  Loading default configuration..."
if [ -f $core/LS00Cleaner ]; then
busybox cp -f $core/LS00Cleaner $init/LS00Cleaner
busybox chmod 755 $init/LS00Cleaner
busybox chown 0:2000 $init/LS00Cleaner
fi
if [ -f $core/LS00RAM_Manager_BL ]; then
busybox cp -f $core/LS00RAM_Manager_BL $init/LS00RAM_Manager_BL
busybox chmod 755 $init/LS00RAM_Manager_BL
busybox chown 0:2000 $init/LS00RAM_Manager_BL
fi
if [ -f $core/LS00Kernel_Tweaks_Light ]; then
busybox cp -f $core/LS00Kernel_Tweaks_Light $init/LS00Kernel_Tweaks_Light
busybox chmod 755 $init/LS00Kernel_Tweaks_Light
busybox chown 0:2000 $init/LS00Kernel_Tweaks_Light
fi
if [ -f $core/LS00Debugging ]; then
busybox cp -f $core/LS00Debugging $init/LS00Debugging
busybox chmod 755 $init/LS00Debugging
busybox chown 0:2000 $init/LS00Debugging
fi
if [ -f $core/LS00Kernel_Panic ]; then
busybox cp -f $core/LS00Kernel_Panic $init/LS00Kernel_Panic
busybox chmod 755 $init/LS00Kernel_Panic
busybox chown 0:2000 $init/LS00Kernel_Panic
fi
if [ -f $core/LS00SD ]; then
busybox cp -f $core/LS00SD $init/LS00SD
busybox chmod 755 $init/LS00SD
busybox chown 0:2000 $init/LS00SD
fi
if [ -f $core/LS00Improve_Battery ]; then
busybox cp -f $core/LS00Improve_Battery $init/LS00Improve_Battery
busybox chmod 755 $init/LS00Improve_Battery
busybox chown 0:2000 $init/LS00Improve_Battery
fi
if [ -f $init/LS00Disable_Logcats ]; then
busybox cp -f $core/LS00Disable_Logcats $init/LS00Disable_Logcats
busybox chmod 755 $init/LS00Disable_Logcats
busybox chown 0:2000 $init/LS00Disable_Logcats
fi
else
if [ -f $init/LS00MCPS ]; then
busybox cp -f $core/LS00MCPS $init/LS00MCPS
busybox chmod 755 $init/LS00MCPS
busybox chown 0:2000 $init/LS00MCPS
fi
if [ -f $init/LS00CPU_Optimizer ]; then
busybox cp -f $core/LS00CPU_Optimizer $init/LS00CPU_Optimizer
busybox chmod 755 $init/LS00CPU_Optimizer
busybox chown 0:2000 $init/LS00CPU_Optimizer
fi
if [ -f $init/LS00Cleaner ]; then
busybox cp -f $core/LS00Cleaner $init/LS00Cleaner
busybox chmod 755 $init/LS00Cleaner
busybox chown 0:2000 $init/LS00Cleaner
fi
if [ -f $init/LS00Seeder_Light ]; then
busybox cp -f $core/LS00Seeder_Light $init/LS00Seeder_Light
busybox chmod 755 $init/LS00Seeder_Light
busybox chown 0:2000 $init/LS00Seeder_Light
fi 
if [ -f $init/LS00Seeder_Enlarger ]; then
busybox cp -f $core/LS00Seeder_Enlarger $init/LS00Seeder_Enlarger
busybox chmod 755 $init/LS00Seeder_Enlarger
busybox chown 0:2000 $init/LS00Seeder_Enlarger
fi
if [ -f $init/LS00Seeder_Moderate ]; then
busybox cp -f $core/LS00Seeder_Moderate $init/LS00Seeder_Moderate
busybox chmod 755 $init/LS00Seeder_Moderate
busybox chown 0:2000 $init/LS00Seeder_Moderate
fi
if [ -f $init/LS00Seeder_Aggressive ]; then
busybox cp -f $core/LS00Seeder_Aggressive $init/LS00Seeder_Aggressive
busybox chmod 755 $init/LS00Seeder_Aggressive
busybox chown 0:2000 $init/LS00Seeder_Aggressive
fi
if [ -f $init/LS00RAM_Manager_MT ]; then
busybox cp -f $core/LS00RAM_Manager_MT $init/LS00RAM_Manager_MT
busybox chmod 755 $init/LS00RAM_Manager_MT
busybox chown 0:2000 $init/LS00RAM_Manager_MT
fi
if [ -f $init/LS00RAM_Manager_BL ]; then
busybox cp -f $core/LS00RAM_Manager_BL $init/LS00RAM_Manager_BL
busybox chmod 755 $init/LS00RAM_Manager_BL
busybox chown 0:2000 $init/LS00RAM_Manager_BL
fi
if [ -f $init/LS00RAM_Manager_GM ]; then
busybox cp -f $core/LS00RAM_Manager_GM $init/LS00RAM_Manager_GM
busybox chmod 755 $init/LS00RAM_Manager_GM
busybox chown 0:2000 $init/LS00RAM_Manager_GM
fi
if [ -f $init/LS00OOM_Enabled ]; then
busybox cp -f $core/LS00OOM_Enabled $init/LS00OOM_Enabled
busybox chmod 755 $init/LS00OOM_Enabled
busybox chown 0:2000 $init/LS00OOM_Enabled
fi
if [ -f $init/LS00OOM_Disabled ]; then
busybox cp -f $core/LS00OOM_Disabled $init/LS00OOM_Disabled
busybox chmod 755 $init/LS00OOM_Disabled
busybox chown 0:2000 $init/LS00OOM_Disabled
fi
if [ -f $init/LS00CR_Lesser ]; then
busybox cp -f $core/LS00CR_Lesser $init/LS00CR_Lesser
busybox chmod 755 $init/LS00CR_Lesser
busybox chown 0:2000 $init/LS00CR_Lesser
fi
if [ -f $init/LS00CR_Less ]; then
busybox cp -f $core/LS00CR_Less $init/LS00CR_Less
busybox chmod 755 $init/LS00CR_Less
busybox chown 0:2000 $init/LS00CR_Less
fi
if [ -f $init/LS00CR_x2 ]; then
busybox cp -f $core/LS00CR_x2 $init/LS00CR_x2
busybox chmod 755 $init/LS00CR_x2
busybox chown 0:2000 $init/LS00CR_x2
fi
if [ -f $init/S00Allocation_Medium ]; then
busybox cp -f $core/S00Allocation_Medium $init/S00Allocation_Medium
busybox chmod 755 $init/S00Allocation_Medium
busybox chown 0:2000 $init/S00Allocation_Medium
fi
if [ -f $init/S00Allocation_Large ]; then
busybox cp -f $core/S00Allocation_Large $init/S00Allocation_Large
busybox chmod 755 $init/S00Allocation_Large
busybox chown 0:2000 $init/S00Allocation_Large
fi
if [ -f $init/LS00Kernel_Tweaks_Light ]; then
busybox cp -f $core/LS00Kernel_Tweaks_Light $init/LS00Kernel_Tweaks_Light
busybox chmod 755 $init/LS00Kernel_Tweaks_Light
busybox chown 0:2000 $init/LS00Kernel_Tweaks_Light
fi
if [ -f $init/LS00Kernel_Tweaks_Heavy ]; then
busybox cp -f $core/LS00Kernel_Tweaks_Heavy $init/LS00Kernel_Tweaks_Heavy
busybox chmod 755 $init/LS00Kernel_Tweaks_Heavy
busybox chown 0:2000 $init/LS00Kernel_Tweaks_Heavy
fi
if [ -f $init/LS00Net_Small_Buffers ]; then
busybox cp -f $core/LS00Net_Small_Buffers $init/LS00Net_Small_Buffers
busybox chmod 755 $init/LS00Net_Small_Buffers
busybox chown 0:2000 $init/LS00Net_Small_Buffers
fi
if [ -f $init/LS00Net_Big_Buffers ]; then
busybox cp -f $core/LS00Net_Big_Buffers $init/LS00Net_Big_Buffers
busybox chmod 755 $init/LS00Net_Big_Buffers
busybox chown 0:2000 $init/LS00Net_Big_Buffers
fi
if [ -f $init/LS00Net_Tweaks_DNS ]; then
busybox cp -f $core/LS00Net_Tweaks_DNS $init/LS00Net_Tweaks_DNS
busybox chmod 755 $init/LS00Net_Tweaks_DNS
busybox chown 0:2000 $init/LS00Net_Tweaks_DNS
fi
if [ -f $init/LS00Net_Protection ]; then
busybox cp -f $core/LS00Net_Protection $init/LS00Net_Protection
busybox chmod 755 $init/LS00Net_Protection
busybox chown 0:2000 $init/LS00Net_Protection
fi
if [ -f $init/LS00Net_Tweaks_RIL ]; then
busybox cp -f $core/LS00Net_Tweaks_RIL $init/LS00Net_Tweaks_RIL
busybox chmod 755 $init/LS00Net_Tweaks_RIL
busybox chown 0:2000 $init/LS00Net_Tweaks_RIL
fi
if [ -f $init/LS00IO_Boost ]; then
busybox cp -f $core/LS00IO_Boost $init/LS00IO_Boost
busybox chmod 755 $init/LS00IO_Boost
busybox chown 0:2000 $init/LS00IO_Boost
fi
if [ -f $init/LS00IO_Queue ]; then
busybox cp -f $core/LS00IO_Queue $init/LS00IO_Queue
busybox chmod 755 $init/LS00IO_Queue
busybox chown 0:2000 $init/LS00IO_Queue
fi
if [ -f $init/LS00Debugging ]; then
busybox cp -f $core/LS00Debugging $init/LS00Debugging
busybox chmod 755 $init/LS00Debugging
busybox chown 0:2000 $init/LS00Debugging
fi
if [ -f $init/LS00Kernel_Panic ]; then
busybox cp -f $core/LS00Kernel_Panic $init/LS00Kernel_Panic
busybox chmod 755 $init/LS00Kernel_Panic
busybox chown 0:2000 $init/LS00Kernel_Panic
fi
if [ -f $init/LS00Kernel_Sleepers ]; then
busybox cp -f $core/LS00Kernel_Sleepers $init/LS00Kernel_Sleepers
busybox chmod 755 $init/LS00Kernel_Sleepers
busybox chown 0:2000 $init/LS00Kernel_Sleepers
fi
if [ -f $init/LS00KSM ]; then
busybox cp -f $core/LS00KSM $init/LS00KSM
busybox chmod 755 $init/LS00KSM
busybox chown 0:2000 $init/LS00KSM
fi
if [ -f $init/LS00SD ]; then
busybox cp -f $core/LS00SD $init/LS00SD
busybox chmod 755 $init/LS00SD
busybox chown 0:2000 $init/LS00SD
fi
if [ -f $init/LS00Zipalign ]; then
busybox cp -f $core/LS00Zipalign $init/LS00Zipalign
busybox chmod 755 $init/LS00Zipalign
busybox chown 0:2000 $init/LS00Zipalign
fi
if [ -f $init/LS00Fast_Charge ]; then
busybox cp -f $core/LS00Fast_Charge $init/LS00Fast_Charge
busybox chmod 755 $init/LS00Fast_Charge
busybox chown 0:2000 $init/LS00Fast_Charge
fi
if [ -f $init/LS00GSDF ]; then
busybox cp -f $core/LS00GSDF $init/LS00GSDF
busybox chmod 755 $init/LS00GSDF
busybox chown 0:2000 $init/LS00GSDF
fi
if [ -f $init/LS00KGA ]; then
busybox cp -f $core/LS00KGA $init/LS00KGA
busybox chmod 755 $init/LS00KGA
busybox chown 0:2000 $init/LS00KGA
fi
if [ -f $init/LS00KMS ]; then
busybox cp -f $core/LS00KMS $init/LS00KMS
busybox chmod 755 $init/LS00KMS
busybox chown 0:2000 $init/LS00KMS
fi
if [ -f $init/LS00Zram ]; then
busybox cp -f $core/LS00Zram $init/LS00Zram
busybox chmod 755 $init/LS00Zram
busybox chown 0:2000 $init/LS00Zram
fi
if [ -f $init/LS00Wifi_Sleeper ]; then
busybox cp -f $core/LS00Wifi_Sleeper $init/LS00Wifi_Sleeper
busybox chmod 755 $init/LS00Wifi_Sleeper
busybox chown 0:2000 $init/LS00Wifi_Sleeper
fi
if [ -f $init/LS00Flag_Tuner ]; then
busybox cp -f $core/LS00Flag_Tuner $init/LS00Flag_Tuner
busybox chmod 755 $init/LS00Flag_Tuner
busybox chown 0:2000 $init/LS00Flag_Tuner
fi
if [ -f $init/LS00Voice_Call ]; then
busybox cp -f $core/LS00Voice_Call $init/LS00Voice_Call
busybox chmod 755 $init/LS00Voice_Call
busybox chown 0:2000 $init/LS00Voice_Call
fi
if [ -f $init/LS00Blackscreen ]; then
busybox cp -f $core/LS00Blackscreen $init/LS00Blackscreen
busybox chmod 755 $init/LS00Blackscreen
busybox chown 0:2000 $init/LS00Blackscreen
fi
if [ -f $init/LS00Improve_Battery ]; then
busybox cp -f $core/LS00Improve_Battery $init/LS00Improve_Battery
busybox chmod 755 $init/LS00Improve_Battery
busybox chown 0:2000 $init/LS00Improve_Battery
fi
if [ -f $init/LS00Scrolling ]; then
busybox cp -f $core/LS00Scrolling $init/LS00Scrolling
busybox chmod 755 $init/LS00Scrolling
busybox chown 0:2000 $init/LS00Scrolling
fi
if [ -f $init/LS00Faster_Boot ]; then
busybox cp -f $core/LS00Faster_Boot $init/LS00Faster_Boot
busybox chmod 755 $init/LS00Faster_Boot
busybox chown 0:2000 $init/LS00Faster_Boot
fi
if [ -f $init/LS00Image_Quality ]; then
busybox cp -f $core/LS00Image_Quality $init/LS00Image_Quality
busybox chmod 755 $init/LS00Image_Quality
busybox chown 0:2000 $init/LS00Image_Quality
fi
if [ -f $init/LS00Faster_Streaming ]; then
busybox cp -f $core/LS00Faster_Streaming $init/LS00Faster_Streaming
busybox chmod 755 $init/LS00Faster_Streaming
busybox chown 0:2000 $init/LS00Faster_Streaming
fi
if [ -f $init/LS00Liquid_UI ]; then
busybox cp -f $core/LS00Liquid_UI $init/LS00Liquid_UI
busybox chmod 755 $init/LS00Liquid_UI
busybox chown 0:2000 $init/LS00Liquid_UI
fi
if [ -f $init/LS00Disable_Logcats ]; then
busybox cp -f $core/LS00Disable_Logcats $init/LS00Disable_Logcats
busybox chmod 755 $init/LS00Disable_Logcats
busybox chown 0:2000 $init/LS00Disable_Logcats
fi
if [ -f $init/LS00Fast_Dormancy ]; then
busybox cp -f $core/LS00Fast_Dormancy $init/LS00Fast_Dormancy
busybox chmod 755 $init/LS00Fast_Dormancy
busybox chown 0:2000 $init/LS00Fast_Dormancy
fi
if [ -f $init/LS00Misc_Tweaks ]; then
busybox cp -f $core/LS00Misc_Tweaks $init/LS00Misc_Tweaks
busybox chmod 755 $init/LS00Misc_Tweaks
busybox chown 0:2000 $init/LS00Misc_Tweaks
fi
if [ -f $init/LS00Assertive_Display ]; then
busybox cp -f $core/LS00Assertive_Display $init/LS00Assertive_Display
busybox chmod 755 $init/LS00Assertive_Display
busybox chown 0:2000 $init/LS00Assertive_Display
busybox cp -f $core/LS00ad_calib.cfg /system/etc/LS00ad_calib.cfg
busybox chmod 755 /system/etc/LS00ad_calib.cfg
busybox chown 0:2000 /system/etc/LS00ad_calib.cfg
fi
fi
if [ ! -f $init/LSPEED ]; then
if [ ! -d /tmp ]; then
busybox mkdir -p /tmp 
busybox chmod 755 /tmp
fi
busybox cp -f $core/LS00LSPEED $init/LSPEED
busybox chmod 755 $init/LSPEED
busybox chown 0:2000 $init/LSPEED
sh $init/LSPEED
fi
busybox sleep $timelong 
  busybox clear
busybox echo "Checking selinux status"
busybox sleep $timeshort
if [ "$sestat" = "Enforcing" ]; then
        busybox echo "Your selinux status is $sestat"
          busybox echo ""; busybox echo ""; busybox echo ""; 
            busybox sleep $timeshort
             busybox echo "Time to configure Android Optimizer (Riki Naoe) ;) "
    elif [ "$sestat" = "Permissive" ]; then
              busybox echo "Your selinux status is $sestat"
                busybox echo ""; busybox echo ""; busybox echo "";
                  busybox echo "Time to configure Android Optimizer (Riki Naoe) ;) "    
          else 
             busybox echo "Your device doesn't have selinux, this option is unavailable"
               busybox echo ""; busybox echo ""; busybox echo "";
                 busybox sleep $timeshort
                   busybox echo "Time to configure Android Optimizer (Riki Naoe) ;) "
                fi
busybox echo ""
mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null
busybox sleep $timelonger
while true; do
busybox clear
mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null
if [ -f /tmp/LSPEED.log ]; then
	LS_stat="\e[1;32mEnabled\e[0m"
else
	LS_stat="\e[1;31mEnable init.d\e[0m"
fi
LEVEL=$(busybox cat /sys/class/power_supply/battery/capacity) 2>/dev/null
if [ -f /system/su.d/LS00init_d.sh ]; then
	init_meth="\e[1;32msu.d\e[0m"
elif [ -f /system/etc/install-recovery-2.sh ]; then
  init_meth="\e[1;32mInstall-recovery-2.sh\e[0m"
else
	init_meth="\e[1;30mDefault\e[0m"
fi
if [ -f $init/LS00MCPS ]; then
	mcps="\e[1;32mOn\e[0m"
else
	mcps="\e[1;31mOff\e[0m"
fi
if [ -f $init/LS00CPU_Optimizer ]; then
	cpu_opt="\e[1;32mOn\e[0m"
else
	cpu_opt="\e[1;31mOff\e[0m"
fi
sestat=$(getenforce) 2>/dev/null
if [ "$sestat" = "Enforcing" ]; then
  selinux="\e[1;31mEnforcing\e[0m"
elif [ "$sestat" = "Permissive" ]; then
  selinux="\e[1;32mPermissive\e[0m"
else
  selinux="\e[1;30mDisabled\e[0m"
fi
if [ -f $init/LS00Cleaner ]; then
	cleaner="\e[1;32mOn boot\e[0m"
else
	cleaner="\e[1;31mOff\e[0m"
fi
if [ -f $init/LS00Seeder_Light ]; then
	seeder_profile="\e[1;33mLight\e[0m"
elif [ -f $init/LS00Seeder_Enlarger ]; then
	seeder_profile="\e[1;35mEnlarger\e[0m"
elif [ -f $init/LS00Seeder_Moderate ]; then
	seeder_profile="\e[1;36mModerate\e[0m"
elif [ -f $init/LS00Seeder_Aggressive ]; then
	seeder_profile="\e[1;34mAggressive\e[0m"
else
	seeder_profile="\e[1;31mOff\e[0m"
fi
if [ -f $init/LS00RAM_Manager_MT ]; then
	ram_profile="\e[1;33mMultitasking\e[0m"
elif [ -f $init/LS00RAM_Manager_BL ]; then
	ram_profile="\e[1;36mBalanced\e[0m"
elif [ -f $init/LS00RAM_Manager_GM ]; then
	ram_profile="\e[1;34mGaming\e[0m"
else
	ram_profile="\e[1;30mDefault\e[0m"
fi
if [ -f $init/LS00OOM_Enabled ]; then
	oom="\e[1;32mEnabled\e[0m"
elif [ -f $init/LS00OOM_Disabled ]; then
	oom="\e[1;31mDisabled\e[0m"
else
	oom="\e[1;30mDefault\e[0m"
fi
if [ -f $init/LS00CR_Lesser ]; then
	reclaiming="\e[1;33mLesser\e[0m"
elif [ -f $init/LS00CR_Less ]; then
	reclaiming="\e[1;36mLess\e[0m"
elif [ -f $init/LS00CR_x2 ]; then
	reclaiming="\e[1;34mx2\e[0m"
else
	reclaiming="\e[1;30mDefault\e[0m"
fi
if [ -f $init/LS00Allocation_Medium ]; then
  allocation="\e[1;33mMedium\e[0m"
elif [ -f $init/LS00Allocation_Large ]; then
  allocation="\e[1;36mLarge\e[0m"
else
  allocation="\e[1;30mDefault\e[0m"
fi
if [ -f $init/LS00Kernel_Tweaks_Light ]; then
	kernel_tweaks="\e[1;33mLight\e[0m"
elif [ -f $init/LS00Kernel_Tweaks_Heavy ]; then
  kernel_tweaks="\e[1;36mHeavy\e[0m"
else
	kernel_tweaks="\e[1;30mDefault\e[0m"
fi
if [ -f $init/LS00Net_Small_Buffers ]; then
  buffers="\e[1;32mOn\e[0m"
elif [ -f $init/LS00Net_Big_Buffers ]; then
  buffers="\e[1;32mOn\e[0m"
else
  buffers="\e[1;31mOff\e[0m"
fi
if [ -f $init/LS00Net_Tweaks_DNS ]; then
  dns="\e[1;32mOn\e[0m"
else
  dns="\e[1;31mOff\e[0m"
fi
if [ -f $init/LS00Net_Protection ]; then
  protection="\e[1;32mOn\e[0m"
else
  protection="\e[1;31mOff\e[0m"
fi
if [ -f $init/LS00Net_Tweaks_RIL ]; then
  ril="\e[1;32mOn\e[0m"
else
  ril="\e[1;31mOff\e[0m"
fi
if [ -f /system/etc/hosts ]; then
if grep -q adblocker /system/etc/hosts; then
	adblocker="\e[1;32m`busybox date -r /system/etc/hosts`\e[0m"
else
	adblocker="\e[1;31mOff\e[0m"
fi
fi
if [ -f $init/LS00IO_Boost ]; then
  IO_boost="\e[1;32mOn\e[0m"
else
  IO_boost="\e[1;31mOff\e[0m"
fi
if [ -f $init/LS00IO_Queue ]; then
  IO_queue="\e[1;32mOn\e[0m"
else
  IO_queue="\e[1;31mOff\e[0m"
fi
if [ -f $init/LS00Debugging ]; then
	debug="\e[1;32mOn\e[0m"
else
	debug="\e[1;31mOff\e[0m"
fi
if [ -f $init/LS00Kernel_Panic ]; then
	panic="\e[1;32mOn\e[0m"
else
	panic="\e[1;31mOff\e[0m"
fi
if [ -f $init/LS00Kernel_Sleepers ]; then
	sleepers="\e[1;32mOn\e[0m"
else
	sleepers="\e[1;31mOff\e[0m"
fi
if [ -f $init/LS00KSM ]; then
	KSM="\e[1;32mOn\e[0m"
else
	KSM="\e[1;31mOff\e[0m"
fi
if [ -f $init/LS00SD ]; then
	SD="\e[1;32mOn\e[0m"
else
	SD="\e[1;31mOff\e[0m"
fi
if [ -f $init/LS00Zipalign ]; then
	zipalign="\e[1;32mOn\e[0m"
else
	zipalign="\e[1;31mOff\e[0m"
fi
if [ -f $init/LS00Fast_Charge ]; then
	fast_charge="\e[1;32mOn\e[0m"
else
	fast_charge="\e[1;31mOff\e[0m"
fi
if [ -f $init/LS00GSDF ]; then
	google_services="\e[1;32mOn\e[0m"
else
	google_services="\e[1;31mOff\e[0m"
fi
if [ -f $init/LS00KGA ]; then
	google_apps="\e[1;32mOn\e[0m"
else
	google_apps="\e[1;31mOff\e[0m"
fi
if [ -f $init/LS00KMS ]; then
	media_server="\e[1;32mOn\e[0m"
else
	media_server="\e[1;31mOff\e[0m"
fi
if [ -f $init/LS00Zram ]; then
	zram="\e[1;32mOn\e[0m"
else
	zram="\e[1;31mOff\e[0m"
fi
if [ -f $init/LS00Wifi_Sleeper ]; then
	wifi_sleeper="\e[1;32mOn\e[0m"
else
	wifi_sleeper="\e[1;31mOff\e[0m"
fi
if [ -f $init/LS00Flag_Tuner ]; then
	flag="\e[1;32mOn\e[0m"
else
	flag="\e[1;31mOff\e[0m"
fi
if [ -f $init/LS00Voice_Call ]; then
	voice_call="\e[1;32mOn\e[0m"
else
	voice_call="\e[1;31mOff\e[0m"
fi
if [ -f $init/LS00Blackscreen ]; then
	blackscreen="\e[1;32mOn\e[0m"
else
	blackscreen="\e[1;31mOff\e[0m"
fi
if [ -f $init/LS00Improve_Battery ]; then
	improve_battery="\e[1;32mOn\e[0m"
else
	improve_battery="\e[1;31mOff\e[0m"
fi
if [ -f $init/LS00Scrolling ]; then
	scrolling="\e[1;32mOn\e[0m"
else
	scrolling="\e[1;31mOff\e[0m"
fi
if [ -f $init/LS00Faster_Boot ]; then
	faster_boot="\e[1;32mOn\e[0m"
else
	faster_boot="\e[1;31mOff\e[0m"
fi
if [ -f $init/LS00Image_Quality ]; then
	image_quality="\e[1;32mOn\e[0m"
else
	image_quality="\e[1;31mOff\e[0m"
fi
if [ -f $init/LS00Faster_Streaming ]; then
	streaming="\e[1;32mOn\e[0m"
else
	streaming="\e[1;31mOff\e[0m"
fi
if [ -f $init/LS00Liquid_UI ]; then
	liquid_UI="\e[1;32mOn\e[0m"
else
	liquid_UI="\e[1;31mOff\e[0m"
fi
if [ -f $init/LS00Disable_Logcats ]; then
	logcat="\e[1;32mOn\e[0m"
else
	logcat="\e[1;31mOff\e[0m"
fi
if [ -f $init/LS00Fast_Dormancy ]; then
	fast_dormancy="\e[1;32mOn\e[0m"
else
	fast_dormancy="\e[1;31mOff\e[0m"
fi
if [ -f $init/LS00Misc_Tweaks ]; then
	misc="\e[1;32mOn\e[0m"
else
	misc="\e[1;31mOff\e[0m"
fi
if [ -f $init/LS00Assertive_Display ]; then
	assertive_display="\e[1;32mOn\e[0m"
else
	assertive_display="\e[1;31mOff\e[0m"
fi
if [ -d $backup ]; then
  backup_time="\e[1;32m`busybox date -r $backup`\e[0m"
else
  backup_time="\e[1;31mNo backup\e[0m"
fi
busybox echo $divider
busybox echo -e "              \e[1;31m...       ...\e[0m"
busybox echo -e "               \e[1;31m\ \. ^ ./ /\e[0m"
busybox echo -e "    Welcome to  \e[1;31m\../ \../\e[0m IZARD $ver"
busybox echo $divider
busybox echo -e "Current state: $LS_stat"
busybox echo $divider
busybox echo -e "1. Boost NOW"
busybox echo -e "2. FStrim NOW"
busybox echo -e "3. Battery Calibration"
busybox echo $divider
busybox echo -e "4. Init.d support   | $init_meth"
busybox echo -e "5. CPU Tuner        | $mcps;$cpu_opt"
busybox echo -e "6. Selinux          | $selinux"
busybox echo -e "7. Cleaner          | $cleaner"
busybox echo -e "8. Seeder           | $seeder_profile"
busybox echo -e "9. RAM Manager      | $ram_profile"
busybox echo -e "10.OOM Killer       | $oom"
busybox echo -e "11.Cache Reclaiming | $reclaiming"
busybox echo -e "12.Cache Allocation | $allocation"
busybox echo -e "13.Kernel Tweaks    | $kernel_tweaks"
busybox echo -e "14.LNET Optimizer   | $buffers;$dns;$protection;$ril"
busybox echo -e "15.AdBlocker        | $adblocker"
busybox echo -e "16.IO Tweak         | $IO_boost;$IO_queue"
busybox echo $divider
busybox echo -e "17.Disable debugging                | $debug"
busybox echo -e "18.Disable kernel panic             | $panic"
busybox echo -e "19.Kernel sleepers optimization     | $sleepers"
busybox echo -e "20.Kernel samepage merging          | $KSM"
busybox echo -e "21.SD tweak                         | $SD"
busybox echo -e "22.Zipalign                         | $zipalign"
busybox echo -e "23.Fast charge                      | $fast_charge"
busybox echo -e "24.Google services drain fix        | $google_services"
busybox echo -e "25.Kill Google Apps on boot         | $google_apps"
busybox echo -e "26.Kill media server on boot        | $media_server"
busybox echo -e "27.ZRAM                             | $zram"
busybox echo -e "28.Wifi sleeper                     | $wifi_sleeper"
busybox echo -e "29.Flag tuner                       | $flag"
busybox echo -e "30.Better voice call quality        | $voice_call"
busybox echo -e "31.Fix blackscreen issue after call | $blackscreen"
busybox echo -e "32.Improve battery                  | $improve_battery"
busybox echo -e "33.Better scrolling                 | $scrolling"
busybox echo -e "34.Faster boot                      | $faster_boot"
busybox echo -e "35.Improve image quality            | $image_quality"
busybox echo -e "36.Faster streaming                 | $streaming"
busybox echo -e "37.Liquid smooth UI (less lag)      | $liquid_UI"
busybox echo -e "38.Disable logcat                   | $logcat"
busybox echo -e "39.Fast dormancy                    | $fast_dormancy"
busybox echo -e "40.Misc tweaks                      | $misc"
busybox echo -e "41.Assertive Display                | $assertive_display"
busybox echo $divider
busybox echo "0. Backup&Restore"
busybox echo "x. Load default"
busybox echo "u. Uninstall"
busybox echo "r. Reboot now"
busybox echo $divider
busybox echo "e. Exit"
busybox echo $divider
busybox echo ""
busybox echo -n "Mamili ka ng Option:"
read -r character
case $character in 
1)busybox clear
busybox echo ""
busybox free | busybox awk '/Mem/{print ">>>...Memory Before Boosting: "$4/1024" MB";}'
busybox sleep $timeshort
busybox echo ""
busybox echo "Dropping cache"
sync
busybox sleep $timeshort
busybox sysctl -w vm.drop_caches=3
busybox sleep $timeshort
dc=/proc/sys/vm/drop_caches
dc_v=$(busybox cat $dc)
if [ "$dc_v" -gt 1 ]; then
busybox sysctl -w vm.drop_caches=1
fi
busybox echo ""
busybox echo ""
busybox echo "BOOSTED!!!"
busybox echo ""
busybox echo ""
busybox free | busybox awk '/Mem/{print ">>>...Memory After Boosting : "$4/1024" MB";}'
busybox sleep $timelonger;;
2)busybox clear
  busybox echo ""
if [ -e /system/bin/fstrim ]; then
	busybox echo "Triming cache, please wait..."
       /system/bin/fstrim -v /cache;
	busybox echo ""
	busybox echo "Triming data, please wait..."
       /system/bin/fstrim -v /data;
	busybox echo ""
	busybox echo "Triming system, please wait"
       /system/bin/fstrim -v /system;
elif [ -e /system/xbin/fstrim ]; then
  busybox echo "Triming cache, please wait..."
       /system/xbin/fstrim -v /cache;
	busybox echo ""
	busybox echo "Triming data, please wait..."
       /system/xbin/fstrim -v /data;
	busybox echo ""
	busybox echo "Triming system, please wait"
       /system/xbin/fstrim -v /system;
else
  busybox echo "Your device doesn't support fstrim"
fi
	busybox sleep $timeshort
	busybox echo ""
	busybox echo "Done !!!"
	busybox sleep $timelong;;
3)busybox clear
	busybox echo ""
	busybox echo "Kailangan puno battery mo..."
	busybox echo ""
	busybox sleep $timeshort
	busybox echo "Checking, wait lang..."
	busybox echo ""
	busybox sleep $timeshort
	if [ "$LEVEL" = "100" ] ; then
		mount -o remount,rw /data
    busybox mount -o remount,rw /data
		busybox sleep $timeshort
		busybox rm -f /data/system/batterystats.bin
		busybox echo ""
		busybox echo ""
		busybox sleep $timelong
		busybox echo ""
		busybox echo "Calibrated na ang device mo.."
		busybox echo ""
		busybox echo "Please reboot the device..."
		busybox sleep $timelong
	else
		busybox echo ""
		busybox echo ""
		busybox sleep $timelong
		busybox echo ""
		busybox echo "Di pa puno battery mo..."
		busybox sleep $timelong
	fi;;
4)while true; do
busybox clear
if [ -f /system/su.d/LS00init_d.sh ]; then
	init_meth="\e[1;32msu.d\e[0m"
elif [ -f /system/etc/install-recovery-2.sh ]; then
  init_meth="\e[1;32mInstall-recovery-2.sh\e[0m"
else
	init_meth="\e[1;30mDefault\e[0m"
fi
	busybox echo -e -n " To use this, please flash superSU first
 If first doesnt work, try second
 
    current: $init_meth

 1. su.d
 2. install-recovery-2.sh
 
 0. Exit
 
  Choose enabling method:"
	read -r option
	if [ "$option" -eq 1 ]; then
		busybox echo ""
		busybox echo ""
if [ ! -f /system/su.d/LS00init_d.sh ]; then
		busybox rm -rf /system/etc/install-recovery-2.sh
    busybox rm -rf /system/xbin/sysinit
fi
  busybox cp -f $core/LS00Init_d.sh /system/su.d/LS00init_d.sh
	busybox chmod 755 /system/su.d/LS00init_d.sh
	busybox chown 0:0 /system/su.d/LS00init_d.sh
    busybox cp -f $core/LS00Sysinit /system/xbin/sysinit
    busybox chmod 755 /system/xbin/sysinit
    busybox chown 0:0 /system/xbin/sysinit
		busybox echo ""
		$timeshorter
   busybox echo "Init.d enabled"
		busybox echo "Please reboot"
		$timeshort
elif [ "$option" -eq 2 ]; then
	 busybox echo ""
if [ ! -f /system/etc/install-recovery-2.sh ]; then
		busybox rm -rf /system/su.d/LS00init_d.sh
    busybox rm -rf /system/xbin/sysinit
fi
  busybox cp -f $core/LS00Init_d.sh /system/etc/install-recovery-2.sh
  busybox chmod 755 /system/etc/install-recovery-2.sh
	busybox chown 0:0 /system/etc/install-recovery-2.sh
    busybox cp -f $core/LS00Sysinit /system/xbin/sysinit
    busybox chmod 755 /system/xbin/sysinit
    busybox chown 0:0 /system/xbin/sysinit
		busybox echo ""
		$timeshorter
   busybox echo "Init.d enabled"
		busybox echo "Please reboot"
		$timeshort
elif [ "$option" -eq 0 ]; then
break
	fi
done;;
5)while true; do
busybox clear
online=$(busybox cat /sys/devices/system/cpu/online)
if [ "$online" = "0" ] ; then
online_norm=1
elif [ "$online" = "0-1" ] ; then
online_norm=2
elif [ "$online" = "0-2" ] ; then
online_norm=3
elif [ "$online" = "0-3" ] ; then
online_norm=4
fi
max_cores=$(busybox cat /sys/devices/system/cpu/possible)
if [ "$max_cores" = "0" ] ; then
max_cores_norm=1
elif [ "$max_cores" = "0-1" ] ; then
max_cores_norm=2
elif [ "$max_cores" = "0-2" ] ; then
max_cores_norm=3
elif [ "$max_cores" = "0-3" ] ; then
max_cores_norm=4
fi
  if [ -f $init/LS00MCPS ]; then
	mcps="\e[1;32mOn\e[0m"
    else
	mcps="\e[1;31mOff\e[0m"
fi
  if [ -f $init/LS00CPU_Optimizer ]; then
	cpu_opt="\e[1;32mOn\e[0m"
    else
	cpu_opt="\e[1;31mOff\e[0m"
fi
	busybox echo -e -n "   Welcome to CPU tuner
  
  Cores: $max_cores_norm
  Online cores: $online_norm

1. Multicore power saver   | $mcps
2. CPU optimizer           | $cpu_opt

0. Exit
 
   Please select an option: "
	read -r option
	if [ "$option" -eq 1 ]; then
      if [ -f $init/LS00MCPS ]; then
busybox rm -rf $init/LS00MCPS
      else
busybox cp -f $core/LS00MCPS $init/LS00MCPS
busybox chmod 755 $init/LS00MCPS
busybox chown 0:2000 $init/LS00MCPS
fi
    elif [ "$option" -eq 2 ]; then
      if [ -f $init/LS00CPU_Optimizer ]; then
busybox rm -rf $init/LS00CPU_Optimizer
     else
busybox cp -f $core/LS00CPU_Optimizer $init/LS00CPU_Optimizer
busybox chmod 755 $init/LS00CPU_Optimizer
busybox chown 0:2000 $init/LS00CPU_Optimizer
fi
    elif [ "$option" -eq 0 ]; then
break
    fi
done;;
6)if [ "$sestat" = "Enforcing" ]; then
        busybox rm -rf /system/su.d/LS00Selinux_Enforce 2>/dev/null
        busybox cp -f $core/LS00Selinux_Permissive /system/su.d/LS00Selinux_Permissive
        busybox chmod 755 /system/su.d/LS00Selinux_Permissive
        busybox chown 0:2000 /system/su.d/LS00Selinux_Permissive
        sh /system/su.d/LS00Selinux_Permissive 2>/dev/null
    elif [ "$sestat" = "Permissive" ]; then
        busybox rm -rf /system/su.d/LS00Selinux_Permissive 2>/dev/null
        busybox cp -f $core/LS00Selinux_Enforce /system/su.d/LS00Selinux_Enforce
        busybox chmod 755 /system/su.d/LS00Selinux_Enforce
        busybox chown 0:2000 /system/su.d/LS00Selinux_Enforce
        sh /system/su.d/LS00Selinux_Enforce 2>/dev/null
          else 
             busybox echo "  Your device doesn't have selinux, this option is unavailable"
                 busybox sleep $timelong
      fi;;
7)while true; do
busybox clear
if [ -f $init/LS00Cleaner ]; then
	cleaner="\e[1;32mOn boot\e[0m"
else
	cleaner="\e[1;31mOff\e[0m"
fi
	busybox echo -e -n "   Welcome to Cleaner menu


1. Clean junk files now
2. Clean app cache
3. Set cleaner on boot   | $cleaner
4. Wipe cache partition
5. Wipe dalvik-cache
 
0. Go back
 
   Please select an option: "
	read -r option
	if [ "$option" -eq 1 ]; then
  busybox echo "Cleaning junk files"
busybox sleep $timeshort
busybox echo""
busybox echo "Please wait!!!"
busybox sleep $timelong
mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
mount -o remount,rw /data 2>/dev/null
mount -o remount,rw /cache 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw /data 2>/dev/null
busybox mount -o remount,rw /cache 2>/dev/null
busybox rm -f /cache/*.apk 2>/dev/null
busybox rm -f /cache/*.tmp 2>/dev/null
busybox rm -f /cache/*.log 2>/dev/null
busybox rm -f /cache/*.txt 2>/dev/null
busybox rm -f /cache/recovery/* 2>/dev/null
busybox rm -f /data/*.log 2>/dev/null
busybox rm -f /data/*.txt 2>/dev/null
busybox rm -f /data/anr/*.log 2>/dev/null
busybox rm -f /data/anr/*.txt 2>/dev/null
busybox rm -f /data/backup/pending/*.tmp 2>/dev/null
busybox rm -f /data/cache/*.* 2>/dev/null
busybox rm -f /data/dalvik-cache/*.apk 2>/dev/null
busybox rm -f /data/dalvik-cache/*.tmp 2>/dev/null
busybox rm -f /data/dalvik-cache/*.log 2>/dev/null
busybox rm -f /data/dalvik-cache/*.txt 2>/dev/null
busybox rm -f /data/data/*.log 2>/dev/null
busybox rm -f /data/data/*.txt 2>/dev/null
busybox rm -f /data/log/*.log 2>/dev/null
busybox rm -f /data/log/*.txt 2>/dev/null
busybox rm -f /data/local/*.apk 2>/dev/null
busybox rm -f /data/local/*.log 2>/dev/null
busybox rm -f /data/local/*.txt 2>/dev/null
busybox rm -f /data/local/tmp/*.log 2>/dev/null
busybox rm -f /data/local/tmp/*.txt 2>/dev/null
busybox rm -f /data/last_alog/*.log 2>/dev/null
busybox rm -f /data/last_alog/*.txt 2>/dev/null
busybox rm -f /data/last_kmsg/*.log 2>/dev/null
busybox rm -f /data/last_kmsg/*.txt 2>/dev/null
busybox rm -f /data/mlog/* 2>/dev/null
busybox rm -f /data/tombstones/*.log 2>/dev/null
busybox rm -f /data/tombstones/*.txt 2>/dev/null
busybox rm -f /data/system/*.log 2>/dev/null
busybox rm -f /data/system/*.txt 2>/dev/null
busybox rm -f /data/system/dropbox/*.log 2>/dev/null
busybox rm -f /data/system/dropbox/*.txt 2>/dev/null
busybox rm -f /data/system/usagestats/*.log 2>/dev/null
busybox rm -f /data/system/usagestats/*.txt 2>/dev/null
busybox echo "Cleaning is done"
busybox sleep $timelong
    elif [ "$option" -eq 2 ]; then
busybox echo "Cleaning app cache"
busybox sleep $timeshort
busybox echo""
busybox echo "Please wait!!!"
	CACHE_DIR=$(busybox find / -type d -iname ./cache* 2>/dev/null)
	for dir in ${CACHE_DIR[*]}; do
		busybox find "$dir" -type f -delete 2>/dev/null
  done
busybox echo "Cleaning is done"  
  busybox sleep $timelong
    elif [ "$option" -eq 3 ]; then
      if [ -f $init/LS00Cleaner ]; then
busybox rm -rf $init/LS00Cleaner
     else
busybox cp -f $core/LS00Cleaner $init/LS00Cleaner
busybox chmod 755 $init/LS00Cleaner
busybox chown 0:2000 $init/LS00Cleaner
fi
    elif [ "$option" -eq 4 ]; then
    while true; do
  busybox clear
busybox echo "Wiping cache parttion..."
busybox echo ""
busybox echo ""
busybox sleep $timeshort
busybox rm -rf /cache/*
	  busybox echo "Cache partition wiped"
	  busybox echo ""
busybox echo -n "#Do you want to reboot now..?
[ Yes = 1 | No = 2 ]: "
read -r option
if [ "$option" -eq 1 ]; then
	busybox echo ""
	busybox echo "Rebooting device"
	busybox echo "3"
	busybox sleep $timeshort
	busybox echo "2"
	busybox sleep $timeshort
	busybox echo "1"
	busybox sleep $timeshort
  reboot
	busybox echo "1" > /proc/sys/kernel/sysrq
  busybox echo "b" > /proc/sysrq-trigger;
else
break
fi
done   
    elif [ "$option" -eq 5 ]; then
    while true; do
  busybox clear
busybox echo "Wiping dalvik-cache parttion..."
busybox echo ""
busybox echo ""
busybox sleep $timeshort
busybox rm -rf /data/dalvik-cache/*
	  busybox echo "Dalvik-cache partition wiped"
	  busybox echo ""
busybox echo -n "#Do you want to reboot now..?
[ Yes = 1 | No = 2 ]: "
read -r option
if [ "$option" -eq 1 ]; then
	busybox echo ""
	busybox echo "Rebooting device"
	busybox echo "3"
	busybox sleep $timeshort
	busybox echo "2"
	busybox sleep $timeshort
	busybox echo "1"
	busybox sleep $timeshort
  reboot
	busybox echo "1" > /proc/sys/kernel/sysrq
  busybox echo "b" > /proc/sysrq-trigger;
else
break
fi
done   
    elif [ "$option" -eq 0 ]; then
break
    fi
done;;
8)while true; do
busybox clear
entropy=$(busybox cat /proc/sys/kernel/random/entropy_avail)
if [ -f $init/LS00Seeder_Light ]; then
	seeder_profile="\e[1;33mLight\e[0m"
elif [ -f $init/LS00Seeder_Enlarger ]; then
	seeder_profile="\e[1;35mEnlarger\e[0m"
elif [ -f $init/LS00Seeder_Moderate ]; then
	seeder_profile="\e[1;36mModerate\e[0m"
elif [ -f $init/LS00Seeder_Aggressive ]; then
	seeder_profile="\e[1;34mAggressive\e[0m"
else
	seeder_profile="\e[1;31mOff\e[0m"
fi
	busybox echo -e -n "   Seeder menu
 
     Current: $seeder_profile
     Current Entropy: $entropy

1. Default
2. Light
3. Enlarger
4. Moderate
5. Aggressive
 
0. Go back

   Please select an option: "
	read -r option
	if [ "$option" -eq 1 ]; then
    busybox rm -rf $init/LS00Seeder_Light 2>/dev/null
    busybox rm -rf $init/LS00Seeder_Enlarger 2>/dev/null
    busybox rm -rf $init/LS00Seeder_Moderate 2>/dev/null
    busybox rm -rf $init/LS00Seeder_Aggressive 2>/dev/null
  elif [ "$option" -eq 2 ]; then
busybox rm -rf $init/LS00Seeder_Light 2>/dev/null
busybox rm -rf $init/LS00Seeder_Enlarger 2>/dev/null
busybox rm -rf $init/LS00Seeder_Moderate 2>/dev/null
busybox rm -rf $init/LS00Seeder_Aggressive 2>/dev/null
busybox cp -f $core/LS00Seeder_Light $init/LS00Seeder_Light
busybox chmod 755 $init/LS00Seeder_Light
busybox chown 0:2000 $init/LS00Seeder_Light
sh $init/LS00Seeder_Light 2>/dev/null
  elif [ "$option" -eq 3 ]; then
busybox rm -rf $init/LS00Seeder_Light 2>/dev/null
busybox rm -rf $init/LS00Seeder_Enlarger 2>/dev/null
busybox rm -rf $init/LS00Seeder_Moderate 2>/dev/null
busybox rm -rf $init/LS00Seeder_Aggressive 2>/dev/null
busybox cp -f $core/LS00Seeder_Enlarger $init/LS00Seeder_Enlarger
busybox chmod 755 $init/LS00Seeder_Enlarger
busybox chown 0:2000 $init/LS00Seeder_Enlarger
sh $init/LS00Seeder_Enlarger 2>/dev/null
  elif [ "$option" -eq 4 ]; then
busybox rm -rf $init/LS00Seeder_Light 2>/dev/null
busybox rm -rf $init/LS00Seeder_Enlarger 2>/dev/null
busybox rm -rf $init/LS00Seeder_Moderate 2>/dev/null
busybox rm -rf $init/LS00Seeder_Aggressive 2>/dev/null
busybox cp -f $core/LS00Seeder_Moderate $init/LS00Seeder_Moderate
busybox chmod 755 $init/LS00Seeder_Moderate
busybox chown 0:2000 $init/LS00Seeder_Moderate
sh $init/LS00Seeder_Moderate 2>/dev/null
  elif [ "$option" -eq 5 ]; then
busybox rm -rf $init/LS00Seeder_Light 2>/dev/null
busybox rm -rf $init/LS00Seeder_Enlarger 2>/dev/null
busybox rm -rf $init/LS00Seeder_Moderate 2>/dev/null
busybox rm -rf $init/LS00Seeder_Aggressive 2>/dev/null
busybox cp -f $core/LS00Seeder_Aggressive $init/LS00Seeder_Aggressive
busybox chmod 755 $init/LS00Seeder_Aggressive
busybox chown 0:2000 $init/LS00Seeder_Aggressive
sh $init/LS00Seeder_Aggressive 2>/dev/null
    elif [ "$option" -eq 0 ]; then
break
    fi
done;;
9)while true; do
busybox clear
busybox chmod 644 /sys/module/lowmemorykiller/parameters/minfree
minfree1=$(busybox awk -F , '{print $1}' /sys/module/lowmemorykiller/parameters/minfree);
minfree2=$(busybox awk -F , '{print $2}' /sys/module/lowmemorykiller/parameters/minfree);
minfree3=$(busybox awk -F , '{print $3}' /sys/module/lowmemorykiller/parameters/minfree);
minfree4=$(busybox awk -F , '{print $4}' /sys/module/lowmemorykiller/parameters/minfree);
minfree5=$(busybox awk -F , '{print $5}' /sys/module/lowmemorykiller/parameters/minfree);
minfree6=$(busybox awk -F , '{print $6}' /sys/module/lowmemorykiller/parameters/minfree);
minfreemb1=$((minfree1*4/1024));
minfreemb2=$((minfree2*4/1024));
minfreemb3=$((minfree3*4/1024));
minfreemb4=$((minfree4*4/1024));
minfreemb5=$((minfree5*4/1024));
minfreemb6=$((minfree6*4/1024));
if [ -f $init/LS00RAM_Manager_MT ]; then
	ram_profile="\e[1;33mMultitasking\e[0m"
elif [ -f $init/LS00RAM_Manager_BL ]; then
	ram_profile="\e[1;36mBalanced\e[0m"
elif [ -f $init/LS00RAM_Manager_GM ]; then
	ram_profile="\e[1;34mGaming\e[0m"
else
	ram_profile="\e[1;30mDefault\e[0m"
fi
	busybox echo -e -n "   Ram manager
 
     Current: $ram_profile
     Current levels: $minfreemb1,$minfreemb2,$minfreemb3,$minfreemb4,$minfreemb5,$minfreemb6
     
1. Default
2. Multitasking
3. Balanced
4. Gaming
 
0. Go back

   Please select an option: "
	read -r option
	if [ "$option" -eq 1 ]; then
    busybox rm -rf $init/LS00RAM_Manager_MT 2>/dev/null
    busybox rm -rf $init/LS00RAM_Manager_BL 2>/dev/null
    busybox rm -rf $init/LS00RAM_Manager_GM 2>/dev/null
  elif [ "$option" -eq 2 ]; then
busybox rm -rf $init/LS00RAM_Manager_MT 2>/dev/null
busybox rm -rf $init/LS00RAM_Manager_BL 2>/dev/null
busybox rm -rf $init/LS00RAM_Manager_GM 2>/dev/null
busybox cp -f $core/LS00RAM_Manager_MT $init/LS00RAM_Manager_MT
busybox chmod 755 $init/LS00RAM_Manager_MT
busybox chown 0:2000 $init/LS00RAM_Manager_MT
sh $init/LS00RAM_Manager_MT 2>/dev/null
  elif [ "$option" -eq 3 ]; then
busybox rm -rf $init/LS00RAM_Manager_MT 2>/dev/null
busybox rm -rf $init/LS00RAM_Manager_BL 2>/dev/null
busybox rm -rf $init/LS00RAM_Manager_GM 2>/dev/null
busybox cp -f $core/LS00RAM_Manager_BL $init/LS00RAM_Manager_BL
busybox chmod 755 $init/LS00RAM_Manager_BL
busybox chown 0:2000 $init/LS00RAM_Manager_BL
sh $init/LS00RAM_Manager_BL 2>/dev/null
  elif [ "$option" -eq 4 ]; then
busybox rm -rf $init/LS00RAM_Manager_MT 2>/dev/null
busybox rm -rf $init/LS00RAM_Manager_BL 2>/dev/null
busybox rm -rf $init/LS00RAM_Manager_GM 2>/dev/null
busybox cp -f $core/LS00RAM_Manager_GM $init/LS00RAM_Manager_GM
busybox chmod 755 $init/LS00RAM_Manager_GM
busybox chown 0:2000 $init/LS00RAM_Manager_GM
sh $init/LS00RAM_Manager_GM 2>/dev/null
    elif [ "$option" -eq 0 ]; then
break
    fi
done;;
10)while true; do
busybox clear
if [ -f $init/LS00OOM_Enabled ]; then
	oom="\e[1;32mEnabled\e[0m"
elif [ -f $init/LS00OOM_Disabled ]; then
	oom="\e[1;31mDisabled\e[0m"
else
	oom="\e[1;30mDefault\e[0m"
fi
	busybox echo -e -n "   OOM Killer
 
     Current: $oom

1. Default
2. Enabled
3. Disabled
 
0. Go back
 
   Please select an option: "
	read -r option
	if [ "$option" -eq 1 ]; then
    busybox rm -rf $init/LS00OOM_Enabled 2>/dev/null
    busybox rm -rf $init/LS00OOM_Disabled 2>/dev/null
  elif [ "$option" -eq 2 ]; then
busybox rm -rf $init/LS00OOM_Enabled 2>/dev/null
busybox rm -rf $init/LS00OOM_Disabled 2>/dev/null
busybox cp -f $core/LS00OOM_Enabled $init/LS00OOM_Enabled
busybox chmod 755 $init/LS00OOM_Enabled
busybox chown 0:2000 $init/LS00OOM_Enabled
  elif [ "$option" -eq 3 ]; then
busybox rm -rf $init/LS00OOM_Enabled 2>/dev/null
busybox rm -rf $init/LS00OOM_Disabled 2>/dev/null
busybox cp -f $core/LS00OOM_Disabled $init/LS00OOM_Disabled
busybox chmod 755 $init/LS00OOM_Disabled
busybox chown 0:2000 $init/LS00OOM_Disabled
    elif [ "$option" -eq 0 ]; then
break
    fi
done;;
11)while true; do
busybox clear
if [ -f $init/LS00CR_Lesser ]; then
	reclaiming="\e[1;33mLesser\e[0m"
elif [ -f $init/LS00CR_Less ]; then
	reclaiming="\e[1;36mLess\e[0m"
elif [ -f $init/LS00CR_x2 ]; then
	reclaiming="\e[1;34mx2\e[0m"
else
	reclaiming="\e[1;30mDefault\e[0m"
fi
	busybox echo -e -n "   Cache reclaiming
 
     Current: $reclaiming

1. Default
2. Lesser
3. Less
4. x2
 
0. Go back
 
   Please select an option: "
	read -r option
	if [ "$option" -eq 1 ]; then
    busybox rm -rf $init/LS00CR_Lesser 2>/dev/null
    busybox rm -rf $init/LS00CR_Less 2>/dev/null
    busybox rm -rf $init/LS00CR_x2 2>/dev/null
  elif [ "$option" -eq 2 ]; then
busybox rm -rf $init/LS00CR_Lesser 2>/dev/null
busybox rm -rf $init/LS00CR_Less 2>/dev/null
busybox rm -rf $init/LS00CR_x2 2>/dev/null
busybox cp -f $core/LS00CR_Lesser $init/LS00CR_Lesser
busybox chmod 755 $init/LS00CR_Lesser
busybox chown 0:2000 $init/LS00CR_Lesser
	elif [ "$option" -eq 3 ]; then
  busybox rm -rf $init/LS00CR_Lesser 2>/dev/null
  busybox rm -rf $init/LS00CR_Less 2>/dev/null
  busybox rm -rf $init/LS00CR_x2 2>/dev/null
busybox cp -f $core/LS00CR_Less $init/LS00CR_Less
busybox chmod 755 $init/LS00CR_Less
busybox chown 0:2000 $init/LS00CR_Less
	elif [ "$option" -eq 4 ]; then
  busybox rm -rf $init/LS00CR_Lesser 2>/dev/null
  busybox rm -rf $init/LS00CR_Less 2>/dev/null
  busybox rm -rf $init/LS00CR_x2 2>/dev/null
busybox cp -f $core/LS00CR_x2 $init/LS00CR_x2
busybox chmod 755 $init/LS00CR_x2
busybox chown 0:2000 $init/LS00CR_x2
    elif [ "$option" -eq 0 ]; then
break
    fi
done;;
12)while true; do
busybox clear
if [ -f $init/LS00Allocation_Medium ]; then
  allocation="\e[1;33mMedium\e[0m"
elif [ -f $init/LS00Allocation_Large ]; then
  allocation="\e[1;36mLarge\e[0m"
else
  allocation="\e[1;30mDefault\e[0m"
fi
	busybox echo -e -n "   Cache allocation
 
     Current: $allocation

1. Default
2. Medium
3. Large

0. Go back
 
   Please select an option: "
	read -r option
	if [ "$option" -eq 1 ]; then
    busybox rm -rf $init/LS00Allocation_Medium 2>/dev/null
    busybox rm -rf $init/LS00Allocation_Large 2>/dev/null
  elif [ "$option" -eq 2 ]; then
busybox rm -rf $init/LS00Allocation_Medium 2>/dev/null
busybox rm -rf $init/LS00Allocation_Large 2>/dev/null
busybox cp -f $core/LS00Allocation_Medium $init/LS00Allocation_Medium
busybox chmod 755 $init/LS00Allocation_Medium
busybox chown 0:2000 $init/LS00Allocation_Medium
	elif [ "$option" -eq 3 ]; then
busybox rm -rf $init/LS00Allocation_Medium 2>/dev/null
busybox rm -rf $init/LS00Allocation_Large 2>/dev/null
busybox cp -f $core/LS00Allocation_Large $init/LS00Allocation_Large
busybox chmod 755 $init/LS00Allocation_Large
busybox chown 0:2000 $init/LS00Allocation_Large

    elif [ "$option" -eq 0 ]; then
break
    fi
done;;
13)while true; do
busybox clear
if [ -f $init/LS00Kernel_Tweaks_Light ]; then
	kernel_tweaks="\e[1;33mLight\e[0m"
elif [ -f $init/LS00Kernel_Tweaks_Heavy ]; then
  kernel_tweaks="\e[1;36mHeavy\e[0m"
else
	kernel_tweaks="\e[1;30mDefault\e[0m"
fi
	busybox echo -e -n "   Kernel tweaks menu
 
     Current: $kernel_tweaks

1. Default
2. Light
3. Heavy

0. Go back
 
   Please select an option: "
	read -r option
	if [ "$option" -eq 1 ]; then
    busybox rm -rf $init/LS00Kernel_Tweaks_Light 2>/dev/null
    busybox rm -rf $init/LS00Kernel_Tweaks_Heavy 2>/dev/null
  elif [ "$option" -eq 2 ]; then
busybox rm -rf $init/LS00Kernel_Tweaks_Light 2>/dev/null
busybox rm -rf $init/LS00Kernel_Tweaks_Heavy 2>/dev/null
busybox cp -f $core/LS00Kernel_Tweaks_Light $init/LS00Kernel_Tweaks_Light
busybox chmod 755 $init/LS00Kernel_Tweaks_Light
busybox chown 0:2000 $init/LS00Kernel_Tweaks_Light
	elif [ "$option" -eq 3 ]; then
busybox rm -rf $init/LS00Kernel_Tweaks_Light 2>/dev/null
busybox rm -rf $init/LS00Kernel_Tweaks_Heavy 2>/dev/null
busybox cp -f $core/LS00Kernel_Tweaks_Heavy $init/LS00Kernel_Tweaks_Heavy
busybox chmod 755 $init/LS00Kernel_Tweaks_Heavy
busybox chown 0:2000 $init/LS00Kernel_Tweaks_Heavy
    elif [ "$option" -eq 0 ]; then
break
    fi
done;;
14)while true; do
busybox clear
if [ -f $init/LS00Net_Small_Buffers ]; then
  buffers="\e[1;33mSmall\e[0m"
elif [ -f $init/LS00Net_Big_Buffers ]; then
  buffers="\e[1;36mBig\e[0m"
else
  buffers="\e[1;30mDefault\e[0m"
fi
if [ -f $init/LS00Net_Tweaks_DNS ]; then
  dns="\e[1;32mEnabled\e[0m"
else
  dns="\e[1;31mDisabled\e[0m"
fi
if [ -f $init/LS00Net_Protection ]; then
  protection="\e[1;32mEnabled\e[0m"
else
  protection="\e[1;31mDisabled\e[0m"
fi
if [ -f $init/LS00Net_Tweaks_RIL ]; then
  ril="\e[1;32mEnabled\e[0m"
else
  ril="\e[1;31mDisabled\e[0m"
fi
	busybox echo -e -n "   LNET Optimizer
 
1. Buffers    | $buffers
2. DNS        | $dns
3. Protection | $protection
4. Ril        | $ril

0. Go back
 
   Please select an option: "
	read -r option
	if [ "$option" -eq 1 ]; then
    while true; do
    busybox clear
      if [ -f $init/LS00Net_Small_Buffers ]; then
        buffers="\e[1;33mSmall\e[0m"
      elif [ -f $init/LS00Net_Big_Buffers ]; then
        buffers="\e[1;36mBig\e[0m"
      else
        buffers="\e[1;30mDefault\e[0m"
      fi
	  busybox echo -e -n "   Buffer menu
    
        Current: $buffers
 
  1. Default buffers
  2. Small buffers
  3. Big buffers

  0. Go back
  
     Please select an option: "
   	  read -r option 
    if [ "$option" -eq 1 ]; then
busybox rm -rf $init/LS00Net_Small_Buffers 2>/dev/null
busybox rm -rf $init/LS00Net_Big_Buffers 2>/dev/null
	elif [ "$option" -eq 2 ]; then
busybox rm -rf $init/LS00Net_Small_Buffers 2>/dev/null
busybox rm -rf $init/LS00Net_Big_Buffers 2>/dev/null
busybox cp -f $core/LS00Net_Small_Buffers $init/LS00Net_Small_Buffers
busybox chmod 755 $init/LS00Net_Small_Buffers
busybox chown 0:2000 $init/LS00Net_Small_Buffers
	elif [ "$option" -eq 3 ]; then
busybox rm -rf $init/LS00Net_Small_Buffers 2>/dev/null
busybox rm -rf $init/LS00Net_Big_Buffers 2>/dev/null
busybox cp -f $core/LS00Net_Big_Buffers $init/LS00Net_Big_Buffers
busybox chmod 755 $init/LS00Net_Big_Buffers
busybox chown 0:2000 $init/LS00Net_Big_Buffers
  elif [ "$option" -eq 0 ]; then
break
    fi 
    done
  elif [ "$option" -eq 2 ]; then
 if [ -f $init/LS00Net_Tweaks_DNS ]; then
busybox rm -rf $init/LS00Net_Tweaks_DNS 2>/dev/null
else
busybox cp -f $core/LS00Net_Tweaks_DNS $init/LS00Net_Tweaks_DNS
busybox chmod 755 $init/LS00Net_Tweaks_DNS
busybox chown 0:2000 $init/LS00Net_Tweaks_DNS
fi
	elif [ "$option" -eq 3 ]; then
 if [ -f $init/LS00Net_Protection ]; then
busybox rm -rf $init/LS00Net_Protection 2>/dev/null
else
busybox cp -f $core/LS00Net_Protection $init/LS00Net_Protection
busybox chmod 755 $init/LS00Net_Protection
busybox chown 0:2000 $init/LS00Net_Protection
fi
	elif [ "$option" -eq 4 ]; then
 if [ -f $init/LS00Net_Tweaks_RIL ]; then
busybox rm -rf $init/LS00Net_Tweaks_RIL 2>/dev/null
else
busybox cp -f $core/LS00Net_Tweaks_RIL $init/LS00Net_Tweaks_RIL
busybox chmod 755 $init/LS00Net_Tweaks_RIL
busybox chown 0:2000 $init/LS00Net_Tweaks_RIL
fi
  elif [ "$option" -eq 0 ]; then
break
    fi
done;;
15)while true; do
busybox clear
if grep -q adblocker /system/etc/hosts; then
	adblocker="\e[1;32m`busybox date -r /system/etc/hosts`\e[0m"
else
	adblocker="\e[1;31mOff\e[0m"
fi
	busybox echo -e -n "   AdBlocker
 
     Current: $adblocker
     info: Kailangan may net ka.

1. Enable/Update
2. Disable

0. Go back
 
   Please select an option: "
	read -r option
	if [ "$option" -eq 1 ]; then
   busybox rm -rf /system/etc/hosts
   busybox wget -O /system/etc/host4 "http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext"
   busybox wget -O /system/etc/host3 "http://adaway.org/hosts.txt"
   busybox cat /system/etc/host4 >> /system/etc/host3; busybox rm -rf /system/etc/host4
   busybox wget -O /system/etc/host2 "http://hosts-file.net/ad_servers.txt"
   busybox cat /system/etc/host3 >> /system/etc/host2; busybox rm -rf /system/etc/host3
   busybox wget -O /system/etc/host1 "http://winhelp2002.mvps.org/hosts.txt"
   busybox cat /system/etc/host2 >> /system/etc/host1; busybox rm -rf /system/etc/host2
   busybox sed '/^#/ d' /system/etc/host1 > /system/etc/host; 
   busybox rm -rf /system/etc/host1
   busybox sort /system/etc/host | busybox uniq -u > /system/etc/hosts; busybox rm -rf /system/etc/host
   busybox sed '/localhost/d' /system/etc/hosts > /system/etc/host; busybox rm -rf /system/etc/hosts
   busybox sed -i -e 's/0.0.0.0/127.0.0.1/g' /system/etc/host; busybox sed -i '1i #adblocker' /system/etc/host
   busybox sed -i '2i 127.0.0.1 localhost' /system/etc/host; busybox sed -i '3i ::1 localhost' /system/etc/host
   busybox awk '{$1=$1}1' OFS=" " /system/etc/host > /system/etc/hosts
   busybox sed -i -e '$a\' /system/etc/hosts
   busybox rm -rf /system/etc/host
   busybox chmod 644 /system/etc/hosts
   busybox chown 0:0 /system/etc/hosts
	elif [ "$option" -eq 2 ]; then
 busybox rm -rf /system/etc/hosts
 busybox cat >> /system/etc/hosts <<EOF

127.0.0.1		    localhost

EOF
busybox chmod 644 /system/etc/hosts
busybox chown 0:0 /system/etc/hosts
    elif [ "$option" -eq 0 ]; then
break
    fi
done;;
16)while true; do
busybox clear
if [ -f $init/LS00IO_Boost ]; then
  IO_boost="\e[1;32mOn\e[0m"
else
  IO_boost="\e[1;31mOff\e[0m"
fi
if [ -f $init/LS00IO_Queue ]; then
  IO_queue="\e[1;32mOn\e[0m"
else
  IO_queue="\e[1;31mOff\e[0m"
fi
	busybox echo -e -n "   IO tweaks menu
 
1. IO Boost         | $IO_boost
2. IO Extend Queue  | $IO_queue

0. Go back
 
   Please select an option: "
	read -r option
  if [ "$option" -eq 1 ]; then
  if [ -f $init/LS00IO_Boost ]; then
busybox rm -rf $init/LS00IO_Boost 2>/dev/null
else
busybox cp -f $core/LS00IO_Boost $init/LS00IO_Boost
busybox chmod 755 $init/LS00IO_Boost
busybox chown 0:2000 $init/LS00IO_Boost
fi
	elif [ "$option" -eq 2 ]; then
  if [ -f $init/LS00IO_Queue ]; then
busybox rm -rf $init/LS00IO_Queue 2>/dev/null
else
busybox cp -f $core/LS00IO_Queue $init/LS00IO_Queue
busybox chmod 755 $init/LS00IO_Queue
busybox chown 0:2000 $init/LS00IO_Queue
fi
    elif [ "$option" -eq 0 ]; then
break
    fi
done;;
17) if [ -f $init/LS00Debugging ]; then
busybox rm -rf $init/LS00Debugging
     else
busybox cp -f $core/LS00Debugging $init/LS00Debugging
busybox chmod 755 $init/LS00Debugging
busybox chown 0:2000 $init/LS00Debugging
fi;;
18) if [ -f $init/LS00Kernel_Panic ]; then
busybox rm -rf $init/LS00Kernel_Panic
     else
busybox cp -f $core/LS00Kernel_Panic $init/LS00Kernel_Panic
busybox chmod 755 $init/LS00Kernel_Panic
busybox chown 0:2000 $init/LS00Kernel_Panic
fi;;
19) if [ -f $init/LS00Kernel_Sleepers ]; then
busybox rm -rf $init/LS00Kernel_Sleepers
     else
busybox cp -f $core/LS00Kernel_Sleepers $init/LS00Kernel_Sleepers
busybox chmod 755 $init/LS00Kernel_Sleepers
busybox chown 0:2000 $init/LS00Kernel_Sleepers
fi;;
20) if [ -f $init/LS00KSM ]; then
busybox rm -rf $init/LS00KSM
     else
busybox cp -f $core/LS00KSM $init/LS00KSM
busybox chmod 755 $init/LS00KSM
busybox chown 0:2000 $init/LS00KSM
fi;;
21) if [ -f $init/LS00SD ]; then
busybox rm -rf $init/LS00SD
     else
busybox cp -f $core/LS00SD $init/LS00SD
busybox chmod 755 $init/LS00SD
busybox chown 0:2000 $init/LS00SD
fi;;
22) if [ -f $init/LS00Zipalign ]; then
busybox rm -rf $init/LS00Zipalign
     else
busybox cp -f $core/LS00Zipalign $init/LS00Zipalign
busybox chmod 755 $init/LS00Zipalign
busybox chown 0:2000 $init/LS00Zipalign
fi;;
23) if [ -f $init/LS00Fast_Charge ]; then
busybox rm -rf $init/LS00Fast_Charge
     else
busybox cp -f $core/LS00Fast_Charge $init/LS00Fast_Charge
busybox chmod 755 $init/LS00Fast_Charge
busybox chown 0:2000 $init/LS00Fast_Charge
fi;;
24) if [ -f $init/LS00GSDF ]; then
busybox rm -rf $init/LS00GSDF
     else
busybox cp -f $core/LS00GSDF $init/LS00GSDF
busybox chmod 755 $init/LS00GSDF
busybox chown 0:2000 $init/LS00GSDF
fi;;
25) if [ -f $init/LS00KGA ]; then
busybox rm -rf $init/LS00KGA
     else
busybox cp -f $core/LS00KGA $init/LS00KGA
busybox chmod 755 $init/LS00KGA
busybox chown 0:2000 $init/LS00KGA
fi;;
26) if [ -f $init/LS00KMS ]; then
busybox rm -rf $init/LS00KMS
     else
busybox cp -f $core/LS00KMS $init/LS00KMS
busybox chmod 755 $init/LS00KMS
busybox chown 0:2000 $init/LS00KMS
fi;;
27) if [ -f $init/LS00Zram ]; then
busybox rm -rf $init/LS00Zram
     else
busybox cp -f $core/LS00Zram $init/LS00Zram
busybox chmod 755 $init/LS00Zram
busybox chown 0:2000 $init/LS00Zram
fi;;
28) if [ -f $init/LS00Wifi_Sleeper ]; then
busybox rm -rf $init/LS00Wifi_Sleeper
     else
busybox cp -f $core/LS00Wifi_Sleeper $init/LS00Wifi_Sleeper
busybox chmod 755 $init/LS00Wifi_Sleeper
busybox chown 0:2000 $init/LS00Wifi_Sleeper
fi;;
29) if [ -f $init/LS00Flag_Tuner ]; then
busybox rm -rf $init/LS00Flag_Tuner
     else
busybox cp -f $core/LS00Flag_Tuner $init/LS00Flag_Tuner
busybox chmod 755 $init/LS00Flag_Tuner
busybox chown 0:2000 $init/LS00Flag_Tuner
fi;;
30) if [ -f $init/LS00Voice_Call ]; then
busybox rm -rf $init/LS00Voice_Call
     else
busybox cp -f $core/LS00Voice_Call $init/LS00Voice_Call
busybox chmod 755 $init/LS00Voice_Call
busybox chown 0:2000 $init/LS00Voice_Call
fi;;
31) if [ -f $init/LS00Blackscreen ]; then
busybox rm -rf $init/LS00Blackscreen
     else
busybox cp -f $core/LS00Blackscreen $init/LS00Blackscreen
busybox chmod 755 $init/LS00Blackscreen
busybox chown 0:2000 $init/LS00Blackscreen
fi;;
32) if [ -f $init/LS00Improve_Battery ]; then
busybox rm -rf $init/LS00Improve_Battery
     else
busybox cp -f $core/LS00Improve_Battery $init/LS00Improve_Battery
busybox chmod 755 $init/LS00Improve_Battery
busybox chown 0:2000 $init/LS00Improve_Battery
fi;; 
33) if [ -f $init/LS00Scrolling ]; then
busybox rm -rf $init/LS00Scrolling
     else
busybox cp -f $core/LS00Scrolling $init/LS00Scrolling
busybox chmod 755 $init/LS00Scrolling
busybox chown 0:2000 $init/LS00Scrolling
fi;;
34) if [ -f $init/LS00Faster_Boot ]; then
busybox rm -rf $init/LS00Faster_Boot
     else
busybox cp -f $core/LS00Faster_Boot $init/LS00Faster_Boot
busybox chmod 755 $init/LS00Faster_Boot
busybox chown 0:2000 $init/LS00Faster_Boot
fi;;
35) if [ -f $init/LS00Image_Quality ]; then
busybox rm -rf $init/LS00Image_Quality
     else
busybox cp -f $core/LS00Image_Quality $init/LS00Image_Quality
busybox chmod 755 $init/LS00Image_Quality
busybox chown 0:2000 $init/LS00Image_Quality
fi;;
36) if [ -f $init/LS00Faster_Streaming ]; then
busybox rm -rf $init/LS00Faster_Streaming
     else
busybox cp -f $core/LS00Faster_Streaming $init/LS00Faster_Streaming
busybox chmod 755 $init/LS00Faster_Streaming
busybox chown 0:2000 $init/LS00Faster_Streaming
fi;;
37) if [ -f $init/LS00Liquid_UI ]; then
busybox rm -rf $init/LS00Liquid_UI
     else
busybox cp -f $core/LS00Liquid_UI $init/LS00Liquid_UI
busybox chmod 755 $init/LS00Liquid_UI
busybox chown 0:2000 $init/LS00Liquid_UI
fi;;
38) if [ -f $init/LS00Disable_Logcats ]; then
busybox rm -rf $init/LS00Disable_Logcats
     else
busybox cp -f $core/LS00Disable_Logcats $init/LS00Disable_Logcats
busybox chmod 755 $init/LS00Disable_Logcats
busybox chown 0:2000 $init/LS00Disable_Logcats
fi;;
39) if [ -f $init/LS00Fast_Dormancy ]; then
busybox rm -rf $init/LS00Fast_Dormancy
     else
busybox cp -f $core/LS00Fast_Dormancy $init/LS00Fast_Dormancy
busybox chmod 755 $init/LS00Fast_Dormancy
busybox chown 0:2000 $init/LS00Fast_Dormancy
fi;; 
40) if [ -f $init/LS00Misc_Tweaks ]; then
busybox rm -rf $init/LS00Misc_Tweaks
     else
busybox cp -f $core/LS00Misc_Tweaks $init/LS00Misc_Tweaks
busybox chmod 755 $init/LS00Misc_Tweaks
busybox chown 0:2000 $init/LS00Misc_Tweaks
fi;;
41) if [ -f $init/LS00Assertive_Display ]; then
busybox rm -rf $init/LS00Assertive_Display
busybox rm -rf /system/etc/LS00ad_calib.cfg
     else
busybox cp -f $core/LS00Assertive_Display $init/LS00Assertive_Display
busybox chmod 755 $init/LS00Assertive_Display
busybox chown 0:2000 $init/LS00Assertive_Display
busybox cp -f $core/LS00ad_calib.cfg /system/etc/LS00ad_calib.cfg
busybox chmod 755 /system/etc/LS00ad_calib.cfg
busybox chown 0:2000 /system/etc/LS00ad_calib.cfg
fi;;
0)while true; do
busybox clear
if [ -d $backup ]; then
  backup_time="\e[1;32m`busybox date -r $backup`\e[0m"
else
  backup_time="\e[1;31mNo backup\e[0m"
fi
 busybox echo -e "Last backup:$backup_time"
 busybox echo "1.Backup current setup"
 busybox echo "2.Restore backup"
 busybox echo "3.Delete backup"
 busybox echo "4.Back"
 busybox echo ""
 busybox echo -n "Please select an option: " 
read -r option
  if [ "$option" -eq 1 ]; then
  busybox echo "Creating backup!!!"
	busybox rm -rf $backup
	busybox sleep $timeshort
	busybox mkdir -p $backup
	busybox sleep $timeshort
  for file in $init/LS00*
    do
      busybox cp -f $file $backup
  done
	busybox clear
	busybox echo "Backup created!!!"
	busybox sleep $timelong
  elif [ "$option" -eq 2 ]; then
mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null
if [ -d $backup ]; then
for file in $init/LS00*
do
  busybox rm -rf $file 2>/dev/null
done
if [ -f $backup/LS00MCPS ]; then
busybox cp -f $core/LS00MCPS $init/LS00MCPS
busybox chmod 755 $init/LS00MCPS
busybox chown 0:2000 $init/LS00MCPS
fi
if [ -f $backup/LS00CPU_Optimizer ]; then
busybox cp -f $core/LS00CPU_Optimizer $init/LS00CPU_Optimizer
busybox chmod 755 $init/LS00CPU_Optimizer
busybox chown 0:2000 $init/LS00CPU_Optimizer
fi
if [ -f $backup/LS00Cleaner ]; then
busybox cp -f $core/LS00Cleaner $init/LS00Cleaner
busybox chmod 755 $init/LS00Cleaner
busybox chown 0:2000 $init/LS00Cleaner
fi
if [ -f $backup/LS00Seeder_Light ]; then
busybox cp -f $core/LS00Seeder_Light $init/LS00Seeder_Light
busybox chmod 755 $init/LS00Seeder_Light
busybox chown 0:2000 $init/LS00Seeder_Light
fi 
if [ -f $backup/LS00Seeder_Enlarger ]; then
busybox cp -f $core/LS00Seeder_Enlarger $init/LS00Seeder_Enlarger
busybox chmod 755 $init/LS00Seeder_Enlarger
busybox chown 0:2000 $init/LS00Seeder_Enlarger
fi
if [ -f $backup/LS00Seeder_Moderate ]; then
busybox cp -f $core/LS00Seeder_Moderate $init/LS00Seeder_Moderate
busybox chmod 755 $init/LS00Seeder_Moderate
busybox chown 0:2000 $init/LS00Seeder_Moderate
fi
if [ -f $backup/LS00Seeder_Aggressive ]; then
busybox cp -f $core/LS00Seeder_Aggressive $init/LS00Seeder_Aggressive
busybox chmod 755 $init/LS00Seeder_Aggressive
busybox chown 0:2000 $init/LS00Seeder_Aggressive
fi
if [ -f $backup/LS00RAM_Manager_MT ]; then
busybox cp -f $core/LS00RAM_Manager_MT $init/LS00RAM_Manager_MT
busybox chmod 755 $init/LS00RAM_Manager_MT
busybox chown 0:2000 $init/LS00RAM_Manager_MT
fi
if [ -f $backup/LS00RAM_Manager_BL ]; then
busybox cp -f $core/LS00RAM_Manager_BL $init/LS00RAM_Manager_BL
busybox chmod 755 $init/LS00RAM_Manager_BL
busybox chown 0:2000 $init/LS00RAM_Manager_BL
fi
if [ -f $backup/LS00RAM_Manager_GM ]; then
busybox cp -f $core/LS00RAM_Manager_GM $init/LS00RAM_Manager_GM
busybox chmod 755 $init/LS00RAM_Manager_GM
busybox chown 0:2000 $init/LS00RAM_Manager_GM
fi
if [ -f $backup/LS00OOM_Enabled ]; then
busybox cp -f $core/LS00OOM_Enabled $init/LS00OOM_Enabled
busybox chmod 755 $init/LS00OOM_Enabled
busybox chown 0:2000 $init/LS00OOM_Enabled
fi
if [ -f $backup/LS00OOM_Disabled ]; then
busybox cp -f $core/LS00OOM_Disabled $init/LS00OOM_Disabled
busybox chmod 755 $init/LS00OOM_Disabled
busybox chown 0:2000 $init/LS00OOM_Disabled
fi
if [ -f $backup/LS00CR_Lesser ]; then
busybox cp -f $core/LS00CR_Lesser $init/LS00CR_Lesser
busybox chmod 755 $init/LS00CR_Lesser
busybox chown 0:2000 $init/LS00CR_Lesser
fi
if [ -f $backup/LS00CR_Less ]; then
busybox cp -f $core/LS00CR_Less $init/LS00CR_Less
busybox chmod 755 $init/LS00CR_Less
busybox chown 0:2000 $init/LS00CR_Less
fi
if [ -f $backup/LS00CR_x2 ]; then
busybox cp -f $core/LS00CR_x2 $init/LS00CR_x2
busybox chmod 755 $init/LS00CR_x2
busybox chown 0:2000 $init/LS00CR_x2
fi
if [ -f $backup/LS00Allocation_Medium ]; then
busybox cp -f $core/S00Allocation_Medium $init/S00Allocation_Medium
busybox chmod 755 $init/S00Allocation_Medium
busybox chown 0:2000 $init/S00Allocation_Medium
fi
if [ -f $backup/S00Allocation_Large ]; then
busybox cp -f $core/S00Allocation_Large $init/S00Allocation_Large
busybox chmod 755 $init/S00Allocation_Large
busybox chown 0:2000 $init/S00Allocation_Large
fi
if [ -f $backup/LS00Kernel_Tweaks_Light ]; then
busybox cp -f $core/LS00Kernel_Tweaks_Light $init/LS00Kernel_Tweaks_Light
busybox chmod 755 $init/LS00Kernel_Tweaks_Light
busybox chown 0:2000 $init/LS00Kernel_Tweaks_Light
fi
if [ -f $backup/LS00Kernel_Tweaks_Heavy ]; then
busybox cp -f $core/LS00Kernel_Tweaks_Heavy $init/LS00Kernel_Tweaks_Heavy
busybox chmod 755 $init/LS00Kernel_Tweaks_Heavy
busybox chown 0:2000 $init/LS00Kernel_Tweaks_Heavy
fi
if [ -f $backup/LS00Net_Small_Buffers ]; then
busybox cp -f $core/LS00Net_Small_Buffers $init/LS00Net_Small_Buffers
busybox chmod 755 $init/LS00Net_Small_Buffers
busybox chown 0:2000 $init/LS00Net_Small_Buffers
fi
if [ -f $backup/LS00Net_Big_Buffers ]; then
busybox cp -f $core/LS00Net_Big_Buffers $init/LS00Net_Big_Buffers
busybox chmod 755 $init/LS00Net_Big_Buffers
busybox chown 0:2000 $init/LS00Net_Big_Buffers
fi
if [ -f $backup/LS00Net_Tweaks_DNS ]; then
busybox cp -f $core/LS00Net_Tweaks_DNS $init/LS00Net_Tweaks_DNS
busybox chmod 755 $init/LS00Net_Tweaks_DNS
busybox chown 0:2000 $init/LS00Net_Tweaks_DNS
fi
if [ -f $backup/LS00Net_Protection ]; then
busybox cp -f $core/LS00Net_Protection $init/LS00Net_Protection
busybox chmod 755 $init/LS00Net_Protection
busybox chown 0:2000 $init/LS00Net_Protection
fi
if [ -f $backup/LS00Net_Tweaks_RIL ]; then
busybox cp -f $core/LS00Net_Tweaks_RIL $init/LS00Net_Tweaks_RIL
busybox chmod 755 $init/LS00Net_Tweaks_RIL
busybox chown 0:2000 $init/LS00Net_Tweaks_RIL
fi
if [ -f $backup/LS00IO_Boost ]; then
busybox cp -f $core/LS00IO_Boost $init/LS00IO_Boost
busybox chmod 755 $init/LS00IO_Boost
busybox chown 0:2000 $init/LS00IO_Boost
fi
if [ -f $backup/LS00IO_Queue ]; then
busybox cp -f $core/LS00IO_Queue $init/LS00IO_Queue
busybox chmod 755 $init/LS00IO_Queue
busybox chown 0:2000 $init/LS00IO_Queue
fi
if [ -f $backup/LS00Debugging ]; then
busybox cp -f $core/LS00Debugging $init/LS00Debugging
busybox chmod 755 $init/LS00Debugging
busybox chown 0:2000 $init/LS00Debugging
fi
if [ -f $backup/LS00Kernel_Panic ]; then
busybox cp -f $core/LS00Kernel_Panic $init/LS00Kernel_Panic
busybox chmod 755 $init/LS00Kernel_Panic
busybox chown 0:2000 $init/LS00Kernel_Panic
fi
if [ -f $backup/LS00Kernel_Sleepers ]; then
busybox cp -f $core/LS00Kernel_Sleepers $init/LS00Kernel_Sleepers
busybox chmod 755 $init/LS00Kernel_Sleepers
busybox chown 0:2000 $init/LS00Kernel_Sleepers
fi
if [ -f $backup/LS00KSM ]; then
busybox cp -f $core/LS00KSM $init/LS00KSM
busybox chmod 755 $init/LS00KSM
busybox chown 0:2000 $init/LS00KSM
fi
if [ -f $backup/LS00SD ]; then
busybox cp -f $core/LS00SD $init/LS00SD
busybox chmod 755 $init/LS00SD
busybox chown 0:2000 $init/LS00SD
fi
if [ -f $backup/LS00Net_Tweaks ]; then
busybox cp -f $core/LS00Net_Tweaks $init/LS00Net_Tweaks
busybox chmod 755 $init/LS00Net_Tweaks
busybox chown 0:2000 $init/LS00Net_Tweaks
fi
if [ -f $backup/LS00Zipalign ]; then
busybox cp -f $core/LS00Zipalign $init/LS00Zipalign
busybox chmod 755 $init/LS00Zipalign
busybox chown 0:2000 $init/LS00Zipalign
fi
if [ -f $backup/LS00Fast_Charge ]; then
busybox cp -f $core/LS00Fast_Charge $init/LS00Fast_Charge
busybox chmod 755 $init/LS00Fast_Charge
busybox chown 0:2000 $init/LS00Fast_Charge
fi
if [ -f $backup/LS00GSDF ]; then
busybox cp -f $core/LS00GSDF $init/LS00GSDF
busybox chmod 755 $init/LS00GSDF
busybox chown 0:2000 $init/LS00GSDF
fi
if [ -f $backup/LS00KGA ]; then
busybox cp -f $core/LS00KGA $init/LS00KGA
busybox chmod 755 $init/LS00KGA
busybox chown 0:2000 $init/LS00KGA
fi
if [ -f $backup/LS00KMS ]; then
busybox cp -f $core/LS00KMS $init/LS00KMS
busybox chmod 755 $init/LS00KMS
busybox chown 0:2000 $init/LS00KMS
fi
if [ -f $backup/LS00Zram ]; then
busybox cp -f $core/LS00Zram $init/LS00Zram
busybox chmod 755 $init/LS00Zram
busybox chown 0:2000 $init/LS00Zram
fi
if [ -f $backup/LS00Wifi_Sleeper ]; then
busybox cp -f $core/LS00Wifi_Sleeper $init/LS00Wifi_Sleeper
busybox chmod 755 $init/LS00Wifi_Sleeper
busybox chown 0:2000 $init/LS00Wifi_Sleeper
fi
if [ -f $backup/LS00Flag_Tuner ]; then
busybox cp -f $core/LS00Flag_Tuner $init/LS00Flag_Tuner
busybox chmod 755 $init/LS00Flag_Tuner
busybox chown 0:2000 $init/LS00Flag_Tuner
fi
if [ -f $backup/LS00Voice_Call ]; then
busybox cp -f $core/LS00Voice_Call $init/LS00Voice_Call
busybox chmod 755 $init/LS00Voice_Call
busybox chown 0:2000 $init/LS00Voice_Call
fi
if [ -f $backup/LS00Blackscreen ]; then
busybox cp -f $core/LS00Blackscreen $init/LS00Blackscreen
busybox chmod 755 $init/LS00Blackscreen
busybox chown 0:2000 $init/LS00Blackscreen
fi
if [ -f $backup/LS00Improve_Battery ]; then
busybox cp -f $core/LS00Improve_Battery $init/LS00Improve_Battery
busybox chmod 755 $init/LS00Improve_Battery
busybox chown 0:2000 $init/LS00Improve_Battery
fi
if [ -f $backup/LS00Scrolling ]; then
busybox cp -f $core/LS00Scrolling $init/LS00Scrolling
busybox chmod 755 $init/LS00Scrolling
busybox chown 0:2000 $init/LS00Scrolling
fi
if [ -f $backup/LS00Faster_Boot ]; then
busybox cp -f $core/LS00Faster_Boot $init/LS00Faster_Boot
busybox chmod 755 $init/LS00Faster_Boot
busybox chown 0:2000 $init/LS00Faster_Boot
fi
if [ -f $backup/LS00Image_Quality ]; then
busybox cp -f $core/LS00Image_Quality $init/LS00Image_Quality
busybox chmod 755 $init/LS00Image_Quality
busybox chown 0:2000 $init/LS00Image_Quality
fi
if [ -f $backup/LS00Faster_Streaming ]; then
busybox cp -f $core/LS00Faster_Streaming $init/LS00Faster_Streaming
busybox chmod 755 $init/LS00Faster_Streaming
busybox chown 0:2000 $init/LS00Faster_Streaming
fi
if [ -f $backup/LS00Liquid_UI ]; then
busybox cp -f $core/LS00Liquid_UI $init/LS00Liquid_UI
busybox chmod 755 $init/LS00Liquid_UI
busybox chown 0:2000 $init/LS00Liquid_UI
fi
if [ -f $backup/LS00Disable_Logcats ]; then
busybox cp -f $core/LS00Disable_Logcats $init/LS00Disable_Logcats
busybox chmod 755 $init/LS00Disable_Logcats
busybox chown 0:2000 $init/LS00Disable_Logcats
fi
if [ -f $backup/LS00Fast_Dormancy ]; then
busybox cp -f $core/LS00Fast_Dormancy $init/LS00Fast_Dormancy
busybox chmod 755 $init/LS00Fast_Dormancy
busybox chown 0:2000 $init/LS00Fast_Dormancy
fi
if [ -f $backup/LS00Misc_Tweaks ]; then
busybox cp -f $core/LS00Misc_Tweaks $init/LS00Misc_Tweaks
busybox chmod 755 $init/LS00Misc_Tweaks
busybox chown 0:2000 $init/LS00Misc_Tweaks
fi
if [ -f $backup/LS00Assertive_Display ]; then
busybox cp -f $core/LS00Assertive_Display $init/LS00Assertive_Display
busybox chmod 755 $init/LS00Assertive_Display
busybox chown 0:2000 $init/LS00Assertive_Display
busybox cp -f $core/LS00ad_calib.cfg /system/etc/LS00ad_calib.cfg
busybox chmod 755 /system/etc/LS00ad_calib.cfg
busybox chown 0:2000 /system/etc/LS00ad_calib.cfg
fi
busybox echo "Backup restored!!!"
busybox sleep $timelong
else
busybox clear
busybox echo "Walang naka back-up"
busybox sleep $timelong
fi
mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null
  elif [ "$option" -eq 3 ]; then
    busybox rm -rf $backup
    	busybox echo "Inalis na ang back-up!!!"
	busybox sleep $timelong
  elif [ "$option" -eq 4 ]; then
break
fi
done;;
d|D)su -c "LD_LIBRARY_PATH=/vendor/lib:/system/lib am start $donation";;
x|X)for file in $init/LS00*
do
  busybox rm -rf $file 2>/dev/null
done
if [ -f $core/LS00Cleaner ]; then
busybox cp -f $core/LS00Cleaner $init/LS00Cleaner
busybox chmod 755 $init/LS00Cleaner
busybox chown 0:2000 $init/LS00Cleaner
fi
if [ -f $core/LS00RAM_Manager_BL ]; then
busybox cp -f $core/LS00RAM_Manager_BL $init/LS00RAM_Manager_BL
busybox chmod 755 $init/LS00RAM_Manager_BL
busybox chown 0:2000 $init/LS00RAM_Manager_BL
fi
if [ -f $core/LS00Kernel_Tweaks_Light ]; then
busybox cp -f $core/LS00Kernel_Tweaks_Light $init/LS00Kernel_Tweaks_Light
busybox chmod 755 $init/LS00Kernel_Tweaks_Light
busybox chown 0:2000 $init/LS00Kernel_Tweaks_Light
fi
if [ -f $core/LS00Debugging ]; then
busybox cp -f $core/LS00Debugging $init/LS00Debugging
busybox chmod 755 $init/LS00Debugging
busybox chown 0:2000 $init/LS00Debugging
fi
if [ -f $core/LS00Kernel_Panic ]; then
busybox cp -f $core/LS00Kernel_Panic $init/LS00Kernel_Panic
busybox chmod 755 $init/LS00Kernel_Panic
busybox chown 0:2000 $init/LS00Kernel_Panic
fi
if [ -f $core/LS00SD ]; then
busybox cp -f $core/LS00SD $init/LS00SD
busybox chmod 755 $init/LS00SD
busybox chown 0:2000 $init/LS00SD
fi
if [ -f $core/LS00Improve_Battery ]; then
busybox cp -f $core/LS00Improve_Battery $init/LS00Improve_Battery
busybox chmod 755 $init/LS00Improve_Battery
busybox chown 0:2000 $init/LS00Improve_Battery
fi
if [ -f $init/LS00Disable_Logcats ]; then
busybox cp -f $core/LS00Disable_Logcats $init/LS00Disable_Logcats
busybox chmod 755 $init/LS00Disable_Logcats
busybox chown 0:2000 $init/LS00Disable_Logcats
fi;;
t|T)su -c "LD_LIBRARY_PATH=/vendor/lib:/system/lib am start $thread";;
u|U)for file in $init/LS00*
do
  busybox rm -rf $file 2>/dev/null
done 
busybox rm -rf $init/LSPEED 2>/dev/null; 
busybox rm -rf $core 2>/dev/null;
for file in /system/su.d/LS00*
do
  busybox rm -rf $file 2>/dev/null
done
busybox rm -rf /system/etc/LS00ad_calib.cfg 2>/dev/null; 
busybox rm -rf /system/xbin/boost 2>/dev/null; 
busybox rm -rf /system/bin/LS 2>/dev/null;
busybox clear;
exit;;
r|R)busybox clear; 
	busybox echo "Mag-rereboot in"
	busybox echo "3"
	busybox sleep $timeshort
	busybox echo "2"
	busybox sleep $timeshort
	busybox echo "1"
	busybox sleep $timeshort
  reboot;
	busybox echo "1" > /proc/sys/kernel/sysrq;
  busybox echo "b" > /proc/sysrq-trigger;;
e|E)busybox clear;
mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null
exit;;
*)busybox clear;
busybox echo "#Invalid Option, please try again"
busybox sleep $timeshort
esac
done


