|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +############################################################################ |
| 4 | +# |
| 5 | +# Copyright (c) 2013 - dsixda (dislam@rocketmail.com) |
| 6 | +# |
| 7 | +# Android Kitchen is 100% free. This script file is intended for personal |
| 8 | +# and/or educational use only. It may not be duplicated for monetary |
| 9 | +# benefit or any other purpose without the permission of the developer. |
| 10 | +# |
| 11 | +############################################################################ |
| 12 | + |
| 13 | +version=0.001 |
| 14 | + |
| 15 | + |
| 16 | +if [ ! -e menu ] |
| 17 | +then |
| 18 | + echo |
| 19 | + echo "Ensure you run this file from the SAME folder as where it was" |
| 20 | + echo "installed, otherwise the kitchen will have problems running the" |
| 21 | + echo "scripts. After you 'cd' to the correct folder, start the kitchen" |
| 22 | + echo "with the ./menu command, NOT with any other command or method!" |
| 23 | + exit 0 |
| 24 | +fi |
| 25 | + |
| 26 | +dir_list=( scripts tools ) |
| 27 | +error_found=0 |
| 28 | + |
| 29 | +for check_dir in ${dir_list[@]} |
| 30 | +do |
| 31 | + if [ ! -e $check_dir ] |
| 32 | + then |
| 33 | + echo "Error: Folder '$check_dir' not found" |
| 34 | + error_found=1 |
| 35 | + fi |
| 36 | +done |
| 37 | + |
| 38 | +if [ $error_found == 1 ] |
| 39 | +then |
| 40 | + echo |
| 41 | + echo "Ensure you have installed the folders for the kitchen correctly." |
| 42 | + exit 0 |
| 43 | +fi |
| 44 | + |
| 45 | + |
| 46 | +chmod 755 scripts/* |
| 47 | +scripts/check_install_dir |
| 48 | + |
| 49 | +if [ "$?" == "1" ] |
| 50 | +then |
| 51 | + exit 0 |
| 52 | +fi |
| 53 | + |
| 54 | +scripts/init_kitchen |
| 55 | +scripts/check_binaries |
| 56 | + |
| 57 | +if [ "$?" == "1" ] |
| 58 | +then |
| 59 | + exit 0 |
| 60 | +fi |
| 61 | + |
| 62 | +if [ ! -e WORKING_* ] |
| 63 | +then |
| 64 | + mkdir WORKING_BOOTIMG |
| 65 | + ./menu |
| 66 | +fi |
| 67 | + |
| 68 | +while : |
| 69 | +do |
| 70 | + |
| 71 | + clear |
| 72 | + |
| 73 | + echo |
| 74 | + echo |
| 75 | + echo "Lopicl's Kernel Kitchen" |
| 76 | + echo "Version $version" |
| 77 | + echo |
| 78 | + echo "----------------" |
| 79 | + echo |
| 80 | + echo "Put a boot.img in the WORKING folder for unlock hidden functions!" |
| 81 | + echo "Enter a choice:" |
| 82 | + echo |
| 83 | + |
| 84 | + if [ -d WORKING_* ] |
| 85 | + then |
| 86 | + |
| 87 | + if [ -d BOOT-EXTRACTED ] |
| 88 | + then |
| 89 | + extracted=true |
| 90 | + else |
| 91 | + extracted=false |
| 92 | + fi |
| 93 | + |
| 94 | + cd WORKING_* |
| 95 | + if [ -e boot.img ] |
| 96 | + then |
| 97 | + boot_img=true |
| 98 | + else |
| 99 | + boot_img=false |
| 100 | + fi |
| 101 | + |
| 102 | + if [ -d boot ] |
| 103 | + then |
| 104 | + boot_folder=true |
| 105 | + else |
| 106 | + boot_folder=false |
| 107 | + fi |
| 108 | + |
| 109 | + cd .. |
| 110 | + |
| 111 | + |
| 112 | + if [ "$boot_img" == "true" ] |
| 113 | + then |
| 114 | + echo " s = Show boot.img information" |
| 115 | + fi |
| 116 | + |
| 117 | + if [ "$extracted" == "true" ] |
| 118 | + then |
| 119 | + echo " b = Build boot.img from BOOT-EXTRACTED folder (for working folder)" |
| 120 | + echo " n = Build NAND's boot folder from BOOT-EXTRACTED (for working folder)" |
| 121 | + echo " r = Remove BOOT-EXTRACTED folder (don't build anything)" |
| 122 | + else |
| 123 | + |
| 124 | + if [ "$boot_img" == "true" ] |
| 125 | + then |
| 126 | + echo " w = Extract kernel+ramdisk from boot.img" |
| 127 | + echo " c = Convert boot.img into NAND boot folder" |
| 128 | + echo " p = Change 'command line' parameter in boot.img" |
| 129 | + |
| 130 | + elif [ "$boot_folder" == "true" ] |
| 131 | + then |
| 132 | + echo " y = Convert NAND boot folder into boot.img" |
| 133 | + echo " z = Extract kernel+ramdisk from NAND boot folder" |
| 134 | + fi |
| 135 | + fi |
| 136 | + fi |
| 137 | + |
| 138 | + echo " a = Extract kernel+ramdisk from boot.img/recovery.img in any folder" |
| 139 | + echo " k = Restart Kitchen for refresh functions " |
| 140 | + echo " x = Exit" |
| 141 | + echo |
| 142 | + echo " NOTE: Other options may not be shown in this menu *until* a specific" |
| 143 | + echo " action above is selected or a specific working folder is created." |
| 144 | + echo " (A working folder is created with Option 1 of the kitchen main menu!)" |
| 145 | + echo |
| 146 | + echo " e.g. You won't see the option to re-pack a boot.img unless you unpack" |
| 147 | + echo " the boot.img first! " |
| 148 | + echo |
| 149 | + echo -n "? " |
| 150 | + |
| 151 | + read enterLetter |
| 152 | + |
| 153 | + if [ "$enterLetter" == "s" ] |
| 154 | + then |
| 155 | + scripts/show_boot_img_info |
| 156 | + |
| 157 | + elif [ "$enterLetter" == "w" ] |
| 158 | + then |
| 159 | + scripts/ensure_boot_extracted |
| 160 | + |
| 161 | + elif [ "$enterLetter" == "r" ] |
| 162 | + then |
| 163 | + rm -rf BOOT-EXTRACTED; echo; echo "Deleted" |
| 164 | + |
| 165 | + elif [ "$enterLetter" == "b" ] |
| 166 | + then |
| 167 | + scripts/prompt_build_bootimg |
| 168 | + |
| 169 | + elif [ "$enterLetter" == "a" ] |
| 170 | + then |
| 171 | + scripts/extract_boot_img |
| 172 | + |
| 173 | + elif [ "$enterLetter" == "n" ] |
| 174 | + then |
| 175 | + scripts/prompt_build_boot |
| 176 | + scripts/build_nand_boot |
| 177 | + |
| 178 | + elif [ "$enterLetter" == "k" ] |
| 179 | + then |
| 180 | + ./menu |
| 181 | + |
| 182 | + elif [ "$enterLetter" == "c" ] |
| 183 | + then |
| 184 | + scripts/ensure_boot_extracted |
| 185 | + scripts/build_nand_boot |
| 186 | + |
| 187 | + elif [ "$enterLetter" == "p" ] |
| 188 | + then |
| 189 | + scripts/change_cmdline |
| 190 | + |
| 191 | + elif [ "$enterLetter" == "y" ] |
| 192 | + then |
| 193 | + scripts/ensure_nand_extracted |
| 194 | + scripts/build_boot_img |
| 195 | + |
| 196 | + elif [ "$enterLetter" == "z" ] |
| 197 | + then |
| 198 | + scripts/ensure_nand_extracted |
| 199 | + |
| 200 | + elif [ "$enterLetter" == "x" ] |
| 201 | + then |
| 202 | + exit 0 |
| 203 | + else |
| 204 | + echo "Invalid option" |
| 205 | + continue |
| 206 | + fi |
| 207 | + |
| 208 | + scripts/press_enter |
| 209 | + |
| 210 | +done |
| 211 | + |
0 commit comments