[Sony Cross-Device General] munjeni:
Yes, correct. One more thing...

#!/vendor/bin/busybox sh

# Disable printing/echo of commands
set +x

#####################################################################
##### THIS IS NOT THE SAME ON EVERY DEVICE, CHANGE!!! ###############
#####################################################################
[COLOR="Blue"]
NODE_MMC=179
NODE_FOTA=179
NAME_FOTA="mmcblk0p16"
NAME_FOTA_D=16[/COLOR]

#####################################################################

INIT="/init.bin"
BB=/vendor/bin/busybox
BOOTIMG=/vendor/bin/bootimg
PROPERTIES=/default.prop
TWRP=/vendor/twrp.xz

LED_RED="/sys/class/leds/led:rgb_red"
LED_GREEN="/sys/class/leds/led:rgb_green"
LED_BLUE="/sys/class/leds/led:rgb_blue"

DEV_FOTA="/dev/block/${NAME_FOTA}"

LOG_FILE="/bootlog.txt"

KEY_EVENT_DELAY=3
WARMBOOT_RECOVERY=0x77665502

set_led_color_comp() {
local max
${BB} read <$1/max_brightness max
[ -z "$max" ] && max=255
${BB} echo $(($max * $2 / 255)) >$1/brightness
}

set_led_color() {
set_led_color_comp ${LED_RED} $1
set_led_color_comp ${LED_GREEN} $2
set_led_color_comp ${LED_BLUE} $3
}

start_internal_recovery() {
set_led_color 255 100 0
${BB} sed -i ${PROPERTIES} \
-e "s!\(ro.debuggable=\)0!\11!" \
-e "s!\(ro.secure=\)1!\10!" \
-e "s!\(ro.allow.mock.location=\)0!\11!" \
-e "s!\(ro.adb.secure=\)1!\10!" \
-e "s!\(ro.build.type=\)user!\1userdebug!"
${BB} grep -q ro.build.type ${PROPERTIES}
[ $? -ne 0 ] && ${BB} echo >>${PROPERTIES} ro.build.type=userdebug
${BB} grep -q ro.adb.secure ${PROPERTIES}
[ $? -ne 0 ] && ${BB} echo >>${PROPERTIES} ro.adb.secure=0

${BB} rm -f /init*.rc /init*.sh
${BB} unxz -c ${TWRP} | ${BB} cpio -idm

for lnk in start stop getprop setprop load_policy; do
${BB} ln -s toolbox /sbin/${lnk}
done
${BB} ln -s toybox /sbin/restorecon

${BOOTIMG} seinject -Z recovery -P /sepolicy -o /sepolicy
${BOOTIMG} seinject -Z init -P /sepolicy -o /sepolicy
${BOOTIMG} seinject -Z init_shell -P /sepolicy -o /sepolicy
${BOOTIMG} seinject -Z kernel -P /sepolicy -o /sepolicy

${BB} umount /proc
${BB} umount /sys
${BB} rm -rf /dev/* ${TWRP}
exec /init
}

start_fota_recovery() {
set_led_color 255 100 0
${BB} mknod -m 600 ${DEV_FOTA} b ${NODE_FOTA} ${NAME_FOTA_D}
${BB} mkdir -m 755 -p /recovery
${BOOTIMG} unpackelf -q -r /recovery/rd.gz -i ${DEV_FOTA}
if [ $? -eq 0 ]; then
${BB} echo "Found ELF recovery image" >> ${LOG_FILE}
else
${BOOTIMG} unpackimg -r /recovery/rd.gz -i ${DEV_FOTA}
if [ $? -eq 0 ]; then
${BB} echo "Found android recovery image" >> ${LOG_FILE}
fi
fi

${BB} rm -f /init*.rc /init*.sh
${BB} gunzip -c /recovery/rd.gz | ${BB} cpio -idm

${BB} umount /proc
${BB} umount /sys
${BB} rm -rf /dev/* /recovery ${BOOTIMG} ${TWRP}
exec /init
}

${BB} mount -o remount,rw /
${BB} cd /

# Log current date/time
${BB} date >> ${LOG_FILE}

# Redirect stdout and stderr to log file
exec >> ${LOG_FILE} 2>&1

# Re-enable printing commands
set -x

${BB} rm -rf /init
${BB} mv ${INIT} /init

[COLOR="Red"]${BB} mkdir -m 755 -p /backp
${BB} tar pczf /backp/system.tar.gz /[/COLOR]

# create directories
${BB} mkdir -m 755 -p /dev/block
${BB} mkdir -m 755 -p /dev/input
${BB} mkdir -m 555 -p /proc
${BB} mkdir -m 755 -p /sys

# create device nodes
# Per linux Documentation/devices.txt
${BB} mknod -m 600 /dev/block/mmcblk0 b ${NODE_MMC} 0
for i in $(${BB} seq 0 12); do
${BB} mknod -m 600 /dev/input/event${i} c 13 $(${BB} expr 64 + ${i})
done
${BB} mknod -m 666 /dev/null c 1 3

# mount filesystems
${BB} mount -t proc proc /proc
${BB} mount -t sysfs sysfs /sys

Check for cmdline
if ${BB} grep -q warmboot=${WARMBOOT_RECOVERY} /proc/cmdline; then
${BB} echo "Recovery request from cmdline" >> ${LOG_FILE}
start_internal_recovery
fi

# Recovery prompt
set_led_color 255 255 0
${BB} timeout -t ${KEY_EVENT_DELAY} ${BOOTIMG} keycheck
KEY=$?

# Volume up or reboot recovery: Use internal recovery
if [ $KEY -eq 115 ]; then
${BB} echo "Entering internal TWRP Recovery Mode" >> ${LOG_FILE}
start_internal_recovery
fi

# Volume down: Use recovery from fotakernel partition
if [ $KEY -eq 114 ] ; then
${BB} echo "Entering Recovery Mode" >> ${LOG_FILE}
start_fota_recovery
fi

${BB} echo "Booting Normally" >> ${LOG_FILE}
set_led_color 0 0 0

${BB} umount /proc
${BB} umount /sys
${BB} rm -rf /dev/* ${BOOTIMG} ${TWRP}
[COLOR="Red"]${BB} cp -fr /vendor/bin/busybox /busybox
${BB} rm -rf /vendor
/busybox tar xzf /backp/system.tar.gz
/busybox rm -rf /backp /busybox[/COLOR]
exec /init

Look into red code, thats my hack to tobias init script, that is a workaround for bootloop which I'm getting with tobias vendor folder! My z1c don't use vendor that way, if I use tobias vendor folder I have a kernel panic and bootloop! Red code might break all things from tobias vendor folder like busybox and etc since red code deletes whole tobias vendor folder and extracts original ramdisk over / ! You will need to figure out things for your devices, I realy not going to mess with it so don't ask me anything about it. Ask tobias to fix that for your device model & your kernel! Anyway I have fixed a lot of bugs in his init script. If you need corect init script over incorect one first of things you need to do is you need to modify blue lines, thats important for your device model! If you no want my hack than remove red line.