├── README └── term-init.sh /README: -------------------------------------------------------------------------------- 1 | Term-init is a script to provide init.d support to any rooted android phones. For more info, please refer to the thread in xda-developers. 2 | 3 | Original thread: 4 | http://forum.xda-developers.com/showthread.php?t=1933849 5 | -------------------------------------------------------------------------------- /term-init.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | #Script to enable init.d by Ryuinferno @ XDA 3 | 4 | error_msg(){ 5 | echo "You do not need this mod..." 6 | sleep 1 7 | echo "If you are reapplying, please delete these files if present:" 8 | echo "/system/bin/sysinit" 9 | sleep 1 10 | echo "/system/etc/install-recovery.sh" 11 | sleep 1 12 | echo "/system/etc/install-recovery-2.sh" 13 | sleep 1 14 | echo "And run again..." 15 | sleep 1 16 | echo "If init.d is still not working, read the FAQ part in my thread..." 17 | sleep 1 18 | echo "Aborting..." 19 | mount -o remount,ro -t auto /system 20 | echo "" 21 | echo "Ryuinferno @ XDA" 22 | exit 1 23 | } 24 | 25 | echo "Init.d Enabler by Ryuinferno @ XDA" 26 | echo "" 27 | sleep 1 28 | 29 | id=`id`; 30 | id=`echo ${id#*=}`; 31 | id=`echo ${id%%\(*}`; 32 | id=`echo ${id%% *}` 33 | if [ "$id" != "0" ] && [ "$id" != "root" ]; then 34 | echo "Script NOT running as root!" 35 | sleep 1 36 | echo "Superuser access not granted!" 37 | sleep 1 38 | echo "Please type 'su' first before running this script..." 39 | exit 1 40 | else 41 | echo "Hello Supaa User! :P" 42 | echo "" 43 | sleep 1 44 | fi 45 | 46 | if [ ! "'which busybox'" ]; then 47 | echo "busybox NOT INSTALLED!" 48 | sleep 1 49 | echo "Please install busybox first!" 50 | exit 1 51 | else 52 | echo "busybox found!" 53 | sleep 1 54 | fi 55 | 56 | bbb=0 57 | 58 | if [ ! "`which grep`" ]; then 59 | bbb=1 60 | echo "grep applet NOT FOUND!" 61 | sleep 1 62 | else 63 | echo "Awesome! grep found! :D" 64 | sleep 1 65 | fi 66 | 67 | if [ ! "`which run-parts`" ]; then 68 | bbb=1 69 | echo "run-parts applet NOT FOUND!" 70 | sleep 1 71 | else 72 | echo "Good! run-parts found! :)" 73 | echo "" 74 | sleep 1 75 | fi 76 | 77 | if [ $bbb -eq 1 ] ; then 78 | echo "" 79 | echo "Required applets are NOT FOUND!" 80 | echo "" 81 | sleep 1 82 | echo "Please reinstall busybox!" 83 | exit 1 84 | fi 85 | 86 | echo "Great! Let's proceed..." 87 | echo "" 88 | sleep 1 89 | echo "Press enter to continue..." 90 | read enterKey 91 | 92 | clear 93 | sleep 1 94 | echo "Mounting system as rewritable..." 95 | mount -o remount,rw -t auto /system 96 | 97 | sleep 1 98 | echo "" 99 | echo "Checking for the presence of sysinit in /system/bin..." 100 | sleep 1 101 | if [ -e /system/bin/sysinit ]; then 102 | echo "sysinit found..." 103 | if [ -z "`cat /system/bin/sysinit | grep "init.d"`" ]; then 104 | echo "Adding lines to sysinit..." 105 | echo "" >> /system/bin/sysinit 106 | echo "# init.d support" >> /system/bin/sysinit 107 | echo "" >> /system/bin/sysinit 108 | echo "export PATH=/sbin:/system/sbin:/system/bin:/system/xbin" >> /system/bin/sysinit 109 | echo "run-parts /system/etc/init.d" >> /system/bin/sysinit 110 | echo "" >> /system/bin/sysinit 111 | else 112 | echo "" 113 | echo "Your sysinit should already be running the scripts in init.d folder at boot..." 114 | error_msg 115 | fi 116 | else 117 | echo "sysinit not found, creating file..." 118 | echo "#!/system/bin/sh" > /system/bin/sysinit 119 | echo "# init.d support" >> /system/bin/sysinit 120 | echo "" >> /system/bin/sysinit 121 | echo "export PATH=/sbin:/system/sbin:/system/bin:/system/xbin" >> /system/bin/sysinit 122 | echo "run-parts /system/etc/init.d" >> /system/bin/sysinit 123 | echo "" >> /system/bin/sysinit 124 | fi 125 | 126 | sleep 1 127 | echo "Setting correct permissions and ownership for sysinit..." 128 | chmod 755 /system/bin/sysinit 129 | chown 0.2000 /system/bin/sysinit 130 | 131 | sleep 1 132 | echo "" 133 | echo "Checking for the presence of install-recovery.sh..." 134 | sleep 1 135 | if [ -f /system/etc/install-recovery.sh ] && [ -z "`cat /system/etc/install-recovery.sh | grep "daemon"`" ]; then 136 | if [ ! -z "`cat /system/etc/install-recovery.sh | grep "init.d"`" ];then 137 | echo "Your install-recovery.sh seems to be already modified for init.d..." 138 | error_msg 139 | fi 140 | echo "install-recovery.sh found, renaming it as install-recovery-2.sh..." 141 | mv /system/etc/install-recovery.sh /system/etc/install-recovery-2.sh 142 | echo "Recreating install-recovery.sh..." 143 | echo "#!/system/bin/sh" > /system/etc/install-recovery.sh 144 | echo "# init.d support" >> /system/etc/install-recovery.sh 145 | echo "" >> /system/etc/install-recovery.sh 146 | echo "/system/bin/sysinit" >> /system/etc/install-recovery.sh 147 | echo "" >> /system/etc/install-recovery.sh 148 | echo "# excecuting extra commands" >> /system/etc/install-recovery.sh 149 | echo "/system/etc/install-recovery-2.sh" >> /system/etc/install-recovery.sh 150 | echo "" >> /system/etc/install-recovery.sh 151 | elif [ -f /system/etc/install-recovery.sh ] && [ ! -z "`cat /system/etc/install-recovery.sh | grep "daemon"`" ]; then 152 | if [ -f /system/etc/install-recovery-2.sh ] && [ ! -z "`cat /system/etc/install-recovery-2.sh | grep "init.d"`" ];then 153 | echo "Your install-recovery-2.sh seems to be already modified for init.d..." 154 | error_msg 155 | fi 156 | echo "install-recovery.sh is used for superuser, using install-recovery-2.sh instead..." 157 | if [ -f /system/etc/install-recovery-2.sh ]; then 158 | echo "" >> /system/etc/install-recovery-2.sh 159 | echo "# init.d support" >> /system/etc/install-recovery-2.sh 160 | echo "/system/bin/sysinit" >> /system/etc/install-recovery-2.sh 161 | echo "" >> /system/etc/install-recovery-2.sh 162 | else 163 | echo "#!/system/bin/sh" > /system/etc/install-recovery-2.sh 164 | echo "# init.d support" >> /system/etc/install-recovery-2.sh 165 | echo "" >> /system/etc/install-recovery-2.sh 166 | echo "/system/bin/sysinit" >> /system/etc/install-recovery-2.sh 167 | echo "" >> /system/etc/install-recovery-2.sh 168 | fi 169 | if [ -z "`cat /system/etc/install-recovery.sh | grep "install-recovery-2.sh"`" ]; then 170 | echo "" >> /system/etc/install-recovery.sh 171 | echo "# extra commands" >> /system/etc/install-recovery.sh 172 | echo "/system/etc/install-recovery-2.sh" >> /system/etc/install-recovery.sh 173 | echo "" >> /system/etc/install-recovery.sh 174 | fi 175 | else 176 | echo "install-recovery.sh not found, creating it..." 177 | echo "#!/system/bin/sh" > /system/etc/install-recovery.sh 178 | echo "# init.d support" >> /system/etc/install-recovery.sh 179 | echo "" >> /system/etc/install-recovery.sh 180 | echo "/system/bin/sysinit" >> /system/etc/install-recovery.sh 181 | echo "" >> /system/etc/install-recovery.sh 182 | fi 183 | 184 | sleep 1 185 | echo "Setting the correct permissions and ownership for install-recovery.sh..." 186 | echo "Also for install-recovery-2.sh if it exists..." 187 | chmod 755 /system/etc/install-recovery.sh 188 | chown 0.0 /system/etc/install-recovery.sh 189 | if [ -f /system/etc/install-recovery-2.sh ]; then 190 | chmod 755 /system/etc/install-recovery-2.sh 191 | chown 0.0 /system/etc/install-recovery-2.sh 192 | fi 193 | 194 | sleep 1 195 | echo "" 196 | echo "Checking for the presence of the init.d folder..." 197 | sleep 1 198 | if [ -d /system/etc/init.d ]; then 199 | echo "init.d folder found..." 200 | else 201 | echo "init.d folder not found, creating the folder..." 202 | mkdir /system/etc/init.d 203 | fi 204 | 205 | sleep 1 206 | echo "" 207 | echo "Creating basic init.d scripts..." 208 | echo "#!/system/bin/sh" > /system/etc/init.d/08setperm 209 | echo "#set correct permissions to /system/etc/init.d folder" >> /system/etc/init.d/08setperm 210 | echo "" >> /system/etc/init.d/08setperm 211 | echo "mount -o remount,rw -t auto /system" >> /system/etc/init.d/08setperm 212 | echo "chmod -R 777 /system/etc/init.d" >> /system/etc/init.d/08setperm 213 | echo "mount -o remount,ro -t auto /system" >> /system/etc/init.d/08setperm 214 | echo "" >> /system/etc/init.d/08setperm 215 | 216 | echo "#!/system/bin/sh" > /system/etc/init.d/00test 217 | echo "#init.d test" >> /system/etc/init.d/00test 218 | echo "" >> /system/etc/init.d/00test 219 | echo "if [ -f /data/Test.log ]; then" >> /system/etc/init.d/00test 220 | echo "rm /data/Test.log" >> /system/etc/init.d/00test 221 | echo "fi" >> /system/etc/init.d/00test 222 | echo "" >> /system/etc/init.d/00test 223 | echo 'echo "Init.d is working !!!" >> /data/Test.log' >> /system/etc/init.d/00test 224 | echo 'echo "excecuted on $(date +"%d-%m-%Y %r" )" >> /data/Test.log' >> /system/etc/init.d/00test 225 | echo "" >> /system/etc/init.d/00test 226 | 227 | sleep 1 228 | echo "Setting correct permissions and ownership for init.d folder and scipts..." 229 | chmod 777 /system/etc/init.d 230 | chmod 777 /system/etc/init.d/08setperm 231 | chmod 777 /system/etc/init.d/00test 232 | chown 0.0 /system/etc/init.d 233 | chown 0.0 /system/etc/init.d/08setperm 234 | chown 0.0 /system/etc/init.d/00test 235 | 236 | sleep 1 237 | echo "" 238 | echo "Mounting system as read-only..." 239 | mount -o remount,ro -t auto /system 240 | sleep 1 241 | echo "" 242 | echo "Done!!!" 243 | sleep 1 244 | echo "Please reboot at least twice before checking /data..." 245 | sleep 1 246 | echo "If init.d is working, you will see a Test.log in /data..." 247 | sleep 1 248 | echo "" 249 | echo "Enjoy!!! =)" 250 | echo "Ryuinferno @ XDA 2013" 251 | exit 252 | --------------------------------------------------------------------------------