Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/system/bin/sh
- #Script to enable init.d/2nd-init.d by Ryuinferno, _alexndr & Geofferey @ XDA
- #Warning! May eat your cat!
- CREATORS="Ryuinferno, _alexndr & Geofferey @ XDA"
- echo "Checking for the presence of sysinit in /system/bin..."
- sleep 1
- if [ -z "`cat /system/bin/sysinit | grep "run-parts"`" ]; then
- echo "No init.d support found"
- export INIT=init.d
- export SYSINIT=sysinit
- else
- echo ""
- echo "Found init.d support already"
- export INIT=2nd-init.d
- export SYSINIT=sysinit2
- fi
- selection=
- until [ "$selection" = "*" ]; do
- echo ""
- echo "Universal init.d & 2nd-init.d Enabler "
- echo ""
- echo "Scripted By: $CREATORS"
- echo ""
- echo "Install Method"
- echo "1 - Enable via recovery-install.sh"
- echo "2 - Enable via init.local.rc"
- echo "3 - Enable via init.qcom.post_boot.sh"
- echo ""
- echo -n "Make your choice: "
- read selection
- echo ""
- case $selection in
- 1) error_msg(){
- echo "You do not need this mod..."
- sleep 1
- echo "If you are reapplying, please delete these files if present:"
- echo "/system/bin/$SYSINIT"
- sleep 1
- echo "/system/etc/install-recovery.sh"
- sleep 1
- echo "/system/etc/install-recovery-2.sh"
- sleep 1
- echo "And run again..."
- sleep 1
- echo "If $INIT is still not working, read the FAQ part in my thread..."
- sleep 1
- echo "Aborting..."
- mount -o remount,ro -t auto /system
- echo ""
- echo "Ryuinferno & Geofferey @ XDA"
- exit 1
- }
- echo "$INIT Enabler by Ryuinferno & Geofferey @ XDA"
- echo ""
- sleep 1
- id=`id`;
- id=`echo ${id#*=}`;
- id=`echo ${id%%\(*}`;
- id=`echo ${id%% *}`
- if [ "$id" != "0" ] && [ "$id" != "root" ]; then
- echo "Script NOT running as root!"
- sleep 1
- echo "Superuser access not granted!"
- sleep 1
- echo "Please type 'su' first before running this script..."
- exit 1
- else
- echo "Hello Supaa User! :P"
- echo ""
- sleep 1
- fi
- if [ ! "'which busybox'" ]; then
- echo "busybox NOT INSTALLED!"
- sleep 1
- echo "Please install busybox first!"
- exit 1
- else
- echo "busybox found!"
- sleep 1
- fi
- bbb=0
- if [ ! "`which grep`" ]; then
- bbb=1
- echo "grep applet NOT FOUND!"
- sleep 1
- else
- echo "Awesome! grep found! :D"
- sleep 1
- fi
- if [ ! "`which run-parts`" ]; then
- bbb=1
- echo "run-parts applet NOT FOUND!"
- sleep 1
- else
- echo "Good! run-parts found! :)"
- echo ""
- sleep 1
- fi
- if [ $bbb -eq 1 ] ; then
- echo ""
- echo "Required applets are NOT FOUND!"
- echo ""
- sleep 1
- echo "Please reinstall busybox!"
- exit 1
- fi
- echo "Great! Let's proceed..."
- echo ""
- sleep 1
- echo "Press enter to continue..."
- read enterKey
- clear
- sleep 1
- echo "Mounting system as rewritable..."
- mount -o remount,rw -t auto /system
- sleep 1
- echo ""
- echo "Checking for the presence of $SYSINIT in /system/bin..."
- sleep 1
- if [ -e /system/bin/$SYSINIT ]; then
- echo "$SYSINIT found..."
- if [ -z "`cat /system/bin/$SYSINIT | grep "$INIT"`" ]; then
- echo "Adding lines to $SYSINIT..."
- echo "" >> /system/bin/$SYSINIT
- echo "# $INIT support" >> /system/bin/$SYSINIT
- echo "" >> /system/bin/$SYSINIT
- echo "export PATH=/sbin:/system/sbin:/system/bin:/system/xbin" >> /system/bin/$SYSINIT
- echo "run-parts /system/etc/$INIT" >> /system/bin/$SYSINIT
- echo "" >> /system/bin/$SYSINIT
- else
- echo ""
- echo "Your $SYSINIT should already be running the scripts in $INIT folder at boot..."
- error_msg
- fi
- else
- echo "$SYSINIT not found, creating file..."
- echo "#!/system/bin/sh" > /system/bin/$SYSINIT
- echo "# $INIT support" >> /system/bin/$SYSINIT
- echo "" >> /system/bin/$SYSINIT
- echo "export PATH=/sbin:/system/sbin:/system/bin:/system/xbin" >> /system/bin/$SYSINIT
- echo "run-parts /system/etc/$INIT" >> /system/bin/$SYSINIT
- echo "" >> /system/bin/$SYSINIT
- fi
- sleep 1
- echo "Setting correct permissions and ownership for $SYSINIT..."
- chmod 755 /system/bin/$SYSINIT
- chown 0.2000 /system/bin/$SYSINIT
- sleep 1
- echo ""
- echo "Checking for the presence of install-recovery.sh..."
- sleep 1
- if [ -f /system/etc/install-recovery.sh ] && [ -z "`cat /system/etc/install-recovery.sh | grep "daemon"`" ]; then
- if [ ! -z "`cat /system/etc/install-recovery.sh | grep "$INIT"`" ];then
- echo "Your install-recovery.sh seems to be already modified for $INIT..."
- error_msg
- fi
- echo "install-recovery.sh found, renaming it as install-recovery-2.sh..."
- mv /system/etc/install-recovery.sh /system/etc/install-recovery-2.sh
- echo "Recreating install-recovery.sh..."
- echo "#!/system/bin/sh" > /system/etc/install-recovery.sh
- echo "# $INIT support" >> /system/etc/install-recovery.sh
- echo "" >> /system/etc/install-recovery.sh
- echo "/system/bin/$SYSINIT" >> /system/etc/install-recovery.sh
- echo "" >> /system/etc/install-recovery.sh
- echo "# excecuting extra commands" >> /system/etc/install-recovery.sh
- echo "/system/etc/install-recovery-2.sh" >> /system/etc/install-recovery.sh
- echo "" >> /system/etc/install-recovery.sh
- elif [ -f /system/etc/install-recovery.sh ] && [ ! -z "`cat /system/etc/install-recovery.sh | grep "daemon"`" ]; then
- if [ -f /system/etc/install-recovery-2.sh ] && [ ! -z "`cat /system/etc/install-recovery-2.sh | grep "$SYSINIT"`" ];then
- echo "Your install-recovery-2.sh seems to be already modified for $INIT..."
- error_msg
- fi
- echo "install-recovery.sh is used for superuser, using install-recovery-2.sh instead..."
- if [ -f /system/etc/install-recovery-2.sh ]; then
- echo "" >> /system/etc/install-recovery-2.sh
- echo "# $INIT support" >> /system/etc/install-recovery-2.sh
- echo "/system/bin/$SYSINIT" >> /system/etc/install-recovery-2.sh
- echo "" >> /system/etc/install-recovery-2.sh
- else
- echo "#!/system/bin/sh" > /system/etc/install-recovery-2.sh
- echo "# $INIT support" >> /system/etc/install-recovery-2.sh
- echo "" >> /system/etc/install-recovery-2.sh
- echo "/system/bin/$SYSINIT" >> /system/etc/install-recovery-2.sh
- echo "" >> /system/etc/install-recovery-2.sh
- fi
- if [ -z "`cat /system/etc/install-recovery.sh | grep "install-recovery-2.sh"`" ]; then
- echo "" >> /system/etc/install-recovery.sh
- echo "# extra commands" >> /system/etc/install-recovery.sh
- echo "/system/etc/install-recovery-2.sh" >> /system/etc/install-recovery.sh
- echo "" >> /system/etc/install-recovery.sh
- fi
- else
- echo "install-recovery.sh not found, creating it..."
- echo "#!/system/bin/sh" > /system/etc/install-recovery.sh
- echo "# $INIT support" >> /system/etc/install-recovery.sh
- echo "" >> /system/etc/install-recovery.sh
- echo "/system/bin/$SYSINIT" >> /system/etc/install-recovery.sh
- echo "" >> /system/etc/install-recovery.sh
- fi
- sleep 1
- echo "Setting the correct permissions and ownership for install-recovery.sh..."
- echo "Also for install-recovery-2.sh if it exists..."
- chmod 755 /system/etc/install-recovery.sh
- chown 0.0 /system/etc/install-recovery.sh
- if [ -f /system/etc/install-recovery-2.sh ]; then
- chmod 755 /system/etc/install-recovery-2.sh
- chown 0.0 /system/etc/install-recovery-2.sh
- fi
- sleep 1
- echo ""
- echo "Checking for the presence of the $INIT folder..."
- sleep 1
- if [ -d /system/etc/$INIT ]; then
- echo "$INIT folder found..."
- else
- echo "$INIT folder not found, creating the folder..."
- mkdir /system/etc/$INIT
- fi
- sleep 1
- echo ""
- echo "Creating basic init.d scripts..."
- echo "#!/system/bin/sh" > /system/etc/$INIT/08setperm
- echo "#set correct permissions to /system/etc/$INIT folder" >> /system/etc/$INIT/08setperm
- echo "" >> /system/etc/$INIT/08setperm
- echo "mount -o remount,rw -t auto /system" >> /system/etc/$INIT/08setperm
- echo "chmod -R 777 /system/etc/$INIT" >> /system/etc/$INIT/08setperm
- echo "mount -o remount,ro -t auto /system" >> /system/etc/$INIT/08setperm
- echo "" >> /system/etc/$INIT/08setperm
- echo "#!/system/bin/sh" > /system/etc/$INIT/00test
- echo "#$INIT test" >> /system/etc/$INIT/00test
- echo "" >> /system/etc/$INIT/00test
- echo "if [ -f /data/Test.log ]; then" >> /system/etc/$INIT/00test
- echo "rm /data/Test.log" >> /system/etc/$INIT/00test
- echo "fi" >> /system/etc/$INIT/00test
- echo "" >> /system/etc/$INIT/00test
- echo 'echo "$INIT is working !!!" >> /data/Test.log' >> /system/etc/$INIT/00test
- echo 'echo "excecuted on $(date +"%d-%m-%Y %r" )" >> /data/Test.log' >> /system/etc/$INIT/00test
- echo "" >> /system/etc/$INIT/00test
- sleep 1
- echo "Setting correct permissions and ownership for $INIT folder and scipts..."
- chmod 777 /system/etc/$INIT
- chmod 777 /system/etc/$INIT/08setperm
- chmod 777 /system/etc/$INIT/00test
- chown 0.0 /system/etc/$INIT
- chown 0.0 /system/etc/$INIT/08setperm
- chown 0.0 /system/etc/$INIT/00test
- sleep 1
- echo ""
- echo "Mounting system as read-only..."
- mount -o remount,ro -t auto /system
- sleep 1
- echo ""
- echo "Done!!!"
- sleep 1
- echo "Please reboot at least twice before checking /data..."
- sleep 1
- echo "If $INIT is working, you will see a Test.log in /data..."
- sleep 1
- echo ""
- echo "Enjoy!!! =)"
- echo "Ryuinferno & Geofferey @ XDA 2013/14"
- exit;;
- 2) error_msg(){
- echo "You do not need this mod..."
- sleep 1
- echo "If you are reapplying, please delete these files if present:"
- echo "/system/bin/$SYSINIT"
- sleep 1
- echo "/system/etc/init.local.rc"
- sleep 1
- echo "/system/etc/init.local-2.rc"
- sleep 1
- echo "And run again..."
- sleep 1
- echo "If $INIT is still not working, read the FAQ part in my thread..."
- sleep 1
- echo "Aborting..."
- mount -o remount,ro -t auto /system
- echo ""
- echo "Ryuinferno & Geofferey @ XDA"
- exit 1
- }
- echo "$INIT Enabler by Ryuinferno & Geofferey @ XDA"
- echo ""
- sleep 1
- id=`id`;
- id=`echo ${id#*=}`;
- id=`echo ${id%%\(*}`;
- id=`echo ${id%% *}`
- if [ "$id" != "0" ] && [ "$id" != "root" ]; then
- echo "Script NOT running as root!"
- sleep 1
- echo "Superuser access not granted!"
- sleep 1
- echo "Please type 'su' first before running this script..."
- exit 1
- else
- echo "Hello Supaa User! :P"
- echo ""
- sleep 1
- fi
- if [ ! "'which busybox'" ]; then
- echo "busybox NOT INSTALLED!"
- sleep 1
- echo "Please install busybox first!"
- exit 1
- else
- echo "busybox found!"
- sleep 1
- fi
- bbb=0
- if [ ! "`which grep`" ]; then
- bbb=1
- echo "grep applet NOT FOUND!"
- sleep 1
- else
- echo "Awesome! grep found! :D"
- sleep 1
- fi
- if [ ! "`which run-parts`" ]; then
- bbb=1
- echo "run-parts applet NOT FOUND!"
- sleep 1
- else
- echo "Good! run-parts found! :)"
- echo ""
- sleep 1
- fi
- if [ $bbb -eq 1 ] ; then
- echo ""
- echo "Required applets are NOT FOUND!"
- echo ""
- sleep 1
- echo "Please reinstall busybox!"
- exit 1
- fi
- echo "Great! Let's proceed..."
- echo ""
- sleep 1
- echo "Press enter to continue..."
- read enterKey
- clear
- sleep 1
- echo "Mounting system as rewritable..."
- mount -o remount,rw -t auto /system
- sleep 1
- echo ""
- echo "Checking for the presence of $SYSINIT in /system/bin..."
- sleep 1
- if [ -e /system/bin/$SYSINIT ]; then
- echo "$SYSINIT found..."
- if [ -z "`cat /system/bin/$SYSINIT | grep "$INIT"`" ]; then
- echo "Adding lines to $SYSINIT..."
- echo "" >> /system/bin/$SYSINIT
- echo "# $INIT support" >> /system/bin/$SYSINIT
- echo "" >> /system/bin/$SYSINIT
- echo "export PATH=/sbin:/system/sbin:/system/bin:/system/xbin" >> /system/bin/$SYSINIT
- echo "run-parts /system/etc/$INIT" >> /system/bin/$SYSINIT
- echo "" >> /system/bin/$SYSINIT
- else
- echo ""
- echo "Your $SYSINIT should already be running the scripts in $INIT folder at boot..."
- error_msg
- fi
- else
- echo "$SYSINIT not found, creating file..."
- echo "#!/system/bin/sh" > /system/bin/$SYSINIT
- echo "# $INIT support" >> /system/bin/$SYSINIT
- echo "" >> /system/bin/$SYSINIT
- echo "export PATH=/sbin:/system/sbin:/system/bin:/system/xbin" >> /system/bin/$SYSINIT
- echo "run-parts /system/etc/$INIT" >> /system/bin/$SYSINIT
- echo "" >> /system/bin/$SYSINIT
- fi
- sleep 1
- echo "Setting correct permissions and ownership for $SYSINIT..."
- chmod 755 /system/bin/$SYSINIT
- chown 0.2000 /system/bin/$SYSINIT
- sleep 1
- echo ""
- echo "Checking for the presence of init.local.rc..."
- sleep 1
- if [ -f /system/etc/init.local.rc ] && [ -z "`cat /system/etc/init.local.rc | grep "daemon"`" ]; then
- if [ ! -z "`cat /system/etc/init.local.rc | grep "$INIT"`" ];then
- echo "Your init.local.rc seems to be already modified for $INIT..."
- error_msg
- fi
- echo "init.local.rc found, renaming it as init.local-2.rc..."
- mv /system/etc/init.local.rc /system/etc/init.local-2.rc
- echo "Recreating init.local.rc..."
- echo "# $INIT Support" >> /system/etc/init.local.rc
- echo "" >> /system/etc/init.local.rc
- echo "service $SYSINIT /system/bin/$SYSINIT" >> /system/etc/init.local.rc
- echo " user root" >> /system/etc/init.local.rc
- echo " group root" >> /system/etc/init.local.rc
- echo " oneshot" >> /system/etc/init.local.rc
- echo "" >> /system/etc/init.local.rc
- echo "# excecuting extra commands" >> /system/etc/init.local.rc
- echo " service into.local-2.rc /system/etc/init.local-2.rc" >> /system/etc/init.local.rc
- echo " user root" >> /system/etc/init.local.rc
- echo " group root" >> /system/etc/init.local.rc
- echo " oneshot" >> /system/etc/init.local.rc
- echo "" >> /system/etc/init.local.rc
- elif [ -f /system/etc/init.local.rc ] && [ ! -z "`cat /system/etc/init.local.rc | grep "daemon"`" ]; then
- if [ -f /system/etc/init.local-2.rc ] && [ ! -z "`cat /system/etc/init.local-2.rc | grep "$INIT"`" ];then
- echo "Your init.local-2.rc seems to be already modified for $INIT..."
- error_msg
- fi
- echo "init.local.rc is used for superuser, using init.local-2.rc instead..."
- if [ -f /system/etc/init.local-2.rc ]; then
- echo "" >> /system/etc/init.local-2.rc
- echo "# $INIT support" >> /system/etc/init.local-2.rc
- echo "service $SYSINIT /system/bin/$SYSINIT" >> /system/etc/init.local-2.rc
- echo " user root" >> /system/etc/init.local-2.rc
- echo " group root" >> /system/etc/init.local-2.rc
- echo " oneshot" >> /system/etc/init.local-2.rc
- echo "" >> /system/etc/init.local-2.rc
- else
- echo "# $INIT support" >> /system/etc/init.local-2.rc
- echo "service $SYSINIT /system/bin/$SYSINIT" >> /system/etc/init.local-2.rc
- echo " user root" >> /system/etc/init.local-2.rc
- echo " group root" >> /system/etc/init.local-2.rc
- echo " oneshot" >> /system/etc/init.local-2.rc
- echo "" >> /system/etc/init.local-2.rc
- fi
- if [ -z "`cat /system/etc/init.local.rc | grep "init.local-2.rc"`" ]; then
- echo "" >> /system/etc/init.local.rc
- echo "# extra commands" >> /system/etc/init.local.rc
- echo ""
- echo "service init.local.rc /system/etc/init.local.rc" >> /system/etc/init.local.rc
- echo " user root" >> /system/etc/init.local.rc
- echo " group root" >> /system/etc/init.local.rc
- echo " oneshot" >> /system/etc/init.local.rc
- echo "" >> /system/etc/init.local.rc
- fi
- else
- echo "init.local.rc not found, creating it..."
- echo "# $INIT Support" >> /system/etc/init.local.rc
- echo "" >> /system/etc/init.local.rc
- echo "service $SYSINIT /system/bin/$SYSINIT" >> /system/etc/init.local.rc
- echo " user root" >> /system/etc/init.local.rc
- echo " group root" >> /system/etc/init.local.rc
- echo " oneshot" >> /system/etc/init.local.rc
- echo "" >> /system/etc/init.local.rc
- fi
- sleep 1
- echo "Setting the correct permissions and ownership for install-recovery.sh..."
- echo "Also for install-recovery-2.sh if it exists..."
- chmod 755 /system/etc/init.local.rc
- chown 0.0 /system/etc/init.local.rc
- if [ -f /system/etc/init.local-2.rc ]; then
- chmod 755 /system/etc/init.local-2.rc
- chown 0.0 /system/etc/init.local-2.rc
- fi
- sleep 1
- echo ""
- echo "Checking for the presence of the $INIT folder..."
- sleep 1
- if [ -d /system/etc/$INIT ]; then
- echo "$INIT folder found..."
- else
- echo "$INIT folder not found, creating the folder..."
- mkdir /system/etc/$INIT
- fi
- sleep 1
- echo ""
- echo "Creating basic init.d scripts..."
- echo "#!/system/bin/sh" > /system/etc/$INIT/08setperm
- echo "#set correct permissions to /system/etc/$INIT folder" >> /system/etc/$INIT/08setperm
- echo "" >> /system/etc/$INIT/08setperm
- echo "mount -o remount,rw -t auto /system" >> /system/etc/$INIT/08setperm
- echo "chmod -R 777 /system/etc/$INIT" >> /system/etc/$INIT/08setperm
- echo "mount -o remount,ro -t auto /system" >> /system/etc/$INIT/08setperm
- echo "" >> /system/etc/$INIT/08setperm
- echo "#!/system/bin/sh" > /system/etc/$INIT/00test
- echo "#$INIT test" >> /system/etc/$INIT/00test
- echo "" >> /system/etc/$INIT/00test
- echo "if [ -f /data/Test.log ]; then" >> /system/etc/$INIT/00test
- echo "rm /data/Test.log" >> /system/etc/$INIT/00test
- echo "fi" >> /system/etc/$INIT/00test
- echo "" >> /system/etc/$INIT/00test
- echo 'echo "$INIT is working !!!" >> /data/Test.log' >> /system/etc/$INIT/00test
- echo 'echo "excecuted on $(date +"%d-%m-%Y %r" )" >> /data/Test.log' >> /system/etc/$INIT/00test
- echo "" >> /system/etc/$INIT/00test
- sleep 1
- echo "Setting correct permissions and ownership for $INIT folder and scipts..."
- chmod 777 /system/etc/$INIT
- chmod 777 /system/etc/$INIT/08setperm
- chmod 777 /system/etc/$INIT/00test
- chown 0.0 /system/etc/$INIT
- chown 0.0 /system/etc/$INIT/08setperm
- chown 0.0 /system/etc/$INIT/00test
- sleep 1
- echo ""
- echo "Mounting system as read-only..."
- mount -o remount,ro -t auto /system
- sleep 1
- echo ""
- echo "Done!!!"
- sleep 1
- echo "Please reboot at least twice before checking /data..."
- sleep 1
- echo "If $INIT is working, you will see a Test.log in /data..."
- sleep 1
- echo ""
- echo "Enjoy!!! =)"
- echo "Ryuinferno & Geofferey @ XDA 2013"
- exit;;
- 3) if [ -z "`cat /system/etc/init.qcom.post_boot.sh | grep "run-parts"`" ] ; then
- echo "" >> /system/etc/init.qcom.post_boot.sh
- echo "# $INIT support" >> /system/etc/init.qcom.post_boot.sh
- echo "run-parts /system/etc/$INIT" >> /system/etc/init.qcom.post_boot.sh
- echo "" >> /system/etc/init.qcom.post_boot.sh
- fi
- if [ ! -d /system/etc/$INIT ] ; then
- mkdir /system/etc/$INIT
- fi
- echo "#!/system/bin/sh" > /system/etc/$INIT/00test
- echo "# $INIT test" >> /system/etc/$INIT/00test
- echo "" >> /system/etc/$INIT/00test
- echo "if [ -f /data/Test.log ] ; then" >> /system/etc/$INIT/00test
- echo " rm /data/Test.log" >> /system/etc/$INIT/00test
- echo "fi" >> /system/etc/$INIT/00test
- echo "" >> /system/etc/$INIT/00test
- echo 'echo "$INIT is working !!!" >> /data/Test.log' >> /system/etc/$INIT/00test
- echo 'echo "excecuted on $(date +"%d-%m-%Y %r" )" >> /data/Test.log' >> /system/etc/$INIT/00test
- echo "" >> /system/etc/$INIT/00test
- echo "#!/system/bin/sh" > /system/etc/$INIT/08setperm
- echo "# Set correct permissions to $INIT scripts" >> /system/etc/$INIT/08setperm
- echo "" >> /system/etc/$INIT/08setperm
- echo "mount -o remount,rw /system" >> /system/etc/$INIT/08setperm
- echo "chmod 777 /system/etc/$INIT/*" >> /system/etc/$INIT/08setperm
- echo "mount -o remount,ro /system" >> /system/etc/$INIT/08setperm
- echo "" >> /system/etc/$INIT/08setperm
- chown 0:0 /system/etc/init.qcom.post_boot.sh
- chmod 644 /system/etc/init.qcom.post_boot.sh
- chcon u:object_r:system_file:s0 /system/etc/init.qcom.post_boot.sh
- chown 0:0 /system/etc/$INIT
- chmod 777 /system/etc/$INIT
- chcon u:object_r:system_file:s0 /system/etc/$INIT
- chown 0:0 /system/etc/$INIT/*
- chmod 777 /system/etc/$INIT/*
- chcon u:object_r:system_file:s0 /system/etc/$INIT/*
- sync;;
- esac
- done
Advertisement
Add Comment
Please, Sign In to add comment