Skip to content

Instantly share code, notes, and snippets.

@fi01
Created October 22, 2013 01:38
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save fi01/7093910 to your computer and use it in GitHub Desktop.
Save fi01/7093910 to your computer and use it in GitHub Desktop.
私が使っているCWMと通常起動を分岐させるスクリプトです。
起動時に音量キーを連打するとCWM起動になります。
bootイメージを展開して/initを/init.origにリネームし、代わりにこのスクリプトを/initに配置します。
busybox環境を/binに配置します。
CWM起動用のramdiskをtarで固めて/bin/recovery.tar.gzに配置します。
また、/bin/_suを配置しておくと良いと思います。
SH-04EとSH-06Eはexecでinit.origを実行すると何故か電波を掴まないので、CWMを起動しない場合はreboot recoveryします。
この機種は通常起動のブートイメージをrecoveryに焼いて下さい。
#!/bin/sh
export PATH=/bin:/sbin
busybox mount -t sysfs sysfs /sys
busybox mount -t tmpfs tmpfs /dev
busybox mkdir /dev/block
busybox mkdir /dev/input
busybox mknod -m a=rw /dev/null c 1 3
busybox mknod -m a=rw /dev/kmsg c 1 11
busybox mknod -m a=rw /dev/block/mmcblk0p18 b 179 18
# Power key
busybox mknod -m a=rw /dev/input/event0 c 13 64
# Volume keys
busybox mknod -m a=rw /dev/input/event6 c 13 70
busybox mkdir /cache
busybox chown 1000.2001 /cache
busybox chmod 770 /cache
busybox mount -t ext4 /dev/block/mmcblk0p18 /cache
busybox echo Checking keys... >/dev/kmsg
if busybox [ ! -e /cache/recovery/boot ]
then
busybox cat /dev/input/event6 >/dev/keycheck &
busybox sleep 3
busybox kill -9 $!
fi
if busybox [ -s /dev/keycheck -o -e /cache/recovery/boot ]
then
busybox echo Entering CWM >/dev/kmsg
busybox rm /cache/recovery/boot
busybox umount /cache
busybox umount /sys
busybox umount /dev
#/sbin/reboot recovery
rm -r /sbin
rm -f etc init* uevent* default*
busybox tar zxf /bin/recovery.tar.gz
busybox chroot / /init
else
busybox echo Skip CWM >/dev/kmsg
fi
busybox touch /cache/recovery/boot
busybox umount /cache
busybox umount /sys
busybox umount /dev
/sbin/reboot recovery
busybox mv /init.orig /init
exec /init
#!/bin/sh
export PATH=/bin:/sbin
busybox mount -t sysfs sysfs /sys
busybox mount -t tmpfs tmpfs /dev
busybox mkdir /dev/block
busybox mkdir /dev/input
busybox mknod -m a=rw /dev/null c 1 3
busybox mknod -m a=rw /dev/kmsg c 1 11
busybox mknod -m a=rw /dev/block/mmcblk0p16 b 179 16
# Volume keys
busybox mknod -m a=rw /dev/input/event0 c 13 64
# Power key
busybox mknod -m a=rw /dev/input/event1 c 13 65
busybox mount -t ext4 /dev/block/mmcblk0p16 /cache
busybox echo Checking keys... >/dev/kmsg
busybox cat /dev/input/event0 >/dev/keycheck &
busybox sleep 3
busybox kill -9 $!
if busybox [ -s /dev/keycheck -o -e /cache/recovery/boot ]
then
busybox echo Entering CWM >/dev/kmsg
busybox rm /cache/recovery/boot
busybox umount /cache
busybox umount /sys
busybox umount /dev
#/sbin/reboot recovery
rm -r /sbin
rm -f etc init* uevent* default*
busybox tar zxf /bin/recovery.tar.gz
busybox chroot / /init
else
busybox echo Skip CWM >/dev/kmsg
fi
busybox chmod 755 /bin
busybox chown 0.0 /bin/_su
busybox chmod 6755 /bin/_su
busybox umount /cache
busybox umount /sys
busybox umount /dev
busybox mv /init.orig /init
exec /init
#!/bin/sh
export PATH=/bin:/sbin
busybox mount -t sysfs sysfs /sys
busybox mount -t tmpfs tmpfs /dev
busybox mkdir /dev/block
busybox mkdir /dev/input
busybox mknod -m a=rw /dev/null c 1 3
busybox mknod -m a=rw /dev/kmsg c 1 11
busybox mknod -m a=rw /dev/block/mmcblk0p18 b 179 18
# Power key
busybox mknod -m a=rw /dev/input/event0 c 13 64
# Volume keys
busybox mknod -m a=rw /dev/input/event8 c 13 72
busybox mkdir /cache
busybox chown 1000.2001 /cache
busybox chmod 770 /cache
busybox mount -t ext4 /dev/block/mmcblk0p18 /cache
busybox echo Checking keys... >/dev/kmsg
if busybox [ ! -e /cache/recovery/boot ]
then
busybox cat /dev/input/event8 >/dev/keycheck &
busybox sleep 3
busybox kill -9 $!
fi
if busybox [ -s /dev/keycheck -o -e /cache/recovery/boot ]
then
busybox echo Entering CWM >/dev/kmsg
busybox rm /cache/recovery/boot
busybox umount /cache
busybox umount /sys
busybox umount /dev
#/sbin/reboot recovery
rm -r /sbin
rm -f etc init* uevent* default*
busybox tar zxf /bin/recovery.tar.gz
busybox chroot / /init
else
busybox echo Skip CWM >/dev/kmsg
fi
busybox touch /cache/recovery/boot
busybox umount /cache
busybox umount /sys
busybox umount /dev
/sbin/reboot recovery
busybox mv /init.orig /init
exec /init
#!/bin/sh
export PATH=/bin:/sbin
busybox mount -t sysfs sysfs /sys
busybox mount -t tmpfs tmpfs /dev
busybox mkdir /dev/block
busybox mkdir /dev/input
busybox mknod -m a=rw /dev/null c 1 3
busybox mknod -m a=rw /dev/kmsg c 1 11
busybox mknod -m a=rw /dev/block/mmcblk0p16 b 179 16
# Volume keys
busybox mknod -m a=rw /dev/input/event0 c 13 64
# Power key
busybox mknod -m a=rw /dev/input/event1 c 13 65
busybox mount -t ext4 /dev/block/mmcblk0p16 /cache
busybox echo Checking keys... >/dev/kmsg
if busybox [ ! -e /cache/recovery/boot ]
then
busybox cat /dev/input/event0 >/dev/keycheck &
busybox sleep 3
busybox kill -9 $!
fi
if busybox [ -s /dev/keycheck -o -e /cache/recovery/boot ]
then
busybox echo Entering CWM >/dev/kmsg
busybox rm /cache/recovery/boot
busybox umount /cache
busybox umount /sys
busybox umount /dev
#/sbin/reboot recovery
rm -r /sbin
rm -f etc init* uevent* default*
busybox tar zxf /bin/recovery.tar.gz
busybox chroot / /init
else
busybox echo Skip CWM >/dev/kmsg
fi
busybox chmod 755 /bin
busybox chown 0.0 /bin/_su
busybox chmod 6755 /bin/_su
busybox umount /cache
busybox umount /sys
busybox umount /dev
busybox mv /init.orig /init
exec /init
#!/bin/sh
export PATH=/bin:/sbin
busybox mount -t sysfs sysfs /sys
busybox mount -t tmpfs tmpfs /dev
busybox mkdir /dev/block
busybox mkdir /dev/input
busybox mknod -m a=rw /dev/null c 1 3
busybox mknod -m a=rw /dev/kmsg c 1 11
busybox mknod -m a=rw /dev/block/mmcblk0p21 b 179 21
# Volume keys
busybox mknod -m a=rw /dev/input/event0 c 13 64
# Power key
busybox mknod -m a=rw /dev/input/event7 c 13 71
busybox mount -t ext4 /dev/block/mmcblk0p21 /cache
busybox echo Checking keys... >/dev/kmsg
busybox cat /dev/input/event0 >/dev/keycheck &
busybox sleep 3
busybox kill -9 $!
if busybox [ -s /dev/keycheck -o -e /cache/recovery/boot ]
then
busybox echo Entering CWM >/dev/kmsg
busybox rm /cache/recovery/boot
busybox umount /cache
busybox umount /sys
busybox umount /dev
#/sbin/reboot recovery
rm -r /sbin
rm -f etc init* uevent* default*
busybox tar zxf /bin/recovery.tar.gz
busybox chroot / /init
else
busybox echo Skip CWM >/dev/kmsg
fi
busybox chmod 755 /bin
busybox chown 0.0 /bin/_su
busybox chmod 6755 /bin/_su
busybox umount /cache
busybox umount /sys
busybox umount /dev
busybox mv /init.orig /init
exec /init
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment