├── README.md ├── get-sdk ├── install ├── install-deps └── test /README.md: -------------------------------------------------------------------------------- 1 | ``bash`` script to install [theos](https://github.com/theos/theos). 2 | 3 | ## What does this do? 4 | 5 | * Installs [theos](https://github.com/theos/theos), its dependencies and [headers](https://github.com/theos/headers). 6 | * Downloads SDKs (iOS 9.2 only by default) 7 | * (Optional) Downloads [fallback headers](https://github.com/supermamon/iOS-fallback-headers). 8 | * (Optional) Creates [~/.nicrc](https://github.com/theos/theos/wiki/nicrc%285%29) 9 | * (Optional) Delete existing installation and re-install 10 | 11 | ## Download & Run 12 | 13 | If you want to get to work quickly open your bash terminal and run: 14 | ````bash 15 | curl -JOLks https://git.io/install-theos && bash install-theos 16 | ```` 17 | 18 | Or if you want to download it first: 19 | ````bash 20 | git clone https://github.com/supermamon/install-theos 21 | cd install-theos 22 | chmod +x install 23 | ./install [args] 24 | ```` 25 | 26 | ## Arguments 27 | 28 | |Argument |Description |Examples| 29 | |----------------|-------------|--------| 30 | |--installdir, -d|Specify the directory where to install. Default is ~/|--installdir /opt/| 31 | |--sdks, -s |List of SDKS to download. Enclose in quotes if multiple. Default is 9.2. |--sdks "8.1 9.2"| 32 | |--createnic, -n |Create ~/.nicrc file. Pass *Y* to create. Default is *N*.|--createnic Y| 33 | |--nicusername, -u|Default username when creating a tweak.|--nicusername tweakmaker
OR
--u "tweakmaker <tweakmaker@mycompany.com>"| 34 | |--nicprefix, -p|Default bundle id prefix.|--nicprefix com.mycompany| 35 | |--fallback, -f|Include [fallback headers](https://github.com/supermamon/iOS-fallback-headers). Default is *N*.|--fallback Y| 36 | |--reinstall, -r|Delete and re-install theos. Default is *N*.|--reinstall Y| 37 | |--install-dependencies, -e|Include dependencies when installing. Default is *Y*.|--install-dependencies N| 38 | |--no-platformcheck, -c|Skip checking OS/platform when installing. Useful when trying to install on unsupported platforms. Default is *N*.|--no-platformcheck Y| 39 | 40 | 41 | 42 | 43 | 44 | ## Examples 45 | 46 | *Default Installation* 47 | 48 | This will install theos and its dependencies on the home directory with iOS9.2 SDK 49 | ````bash 50 | ./install 51 | ```` 52 | 53 | *Custom install directory* 54 | ````bash 55 | ./install --installdir /var/ # don't forget the ending slash 56 | ```` 57 | 58 | *Custom SDKS* 59 | Available SDKs can be found at https://sdks.website/. 60 | 61 | ````bash 62 | ./install --sdks "8.1 9.1" # enclose in quotes if multiple 63 | ```` 64 | 65 | *Delete and re-install theos with 9.3 SDK* 66 | 67 | ````bash 68 | ./install --reinstall Y --sdks 9.3 69 | ```` 70 | 71 | *Create a NIC profile* 72 | 73 | ````bash 74 | ./install --createnic y --nicusername tweakmaker --nicprefix com.tweakmaker 75 | # OR 76 | ./install --createnic y --nicusername "tweakmaker " --nicprefix net.tweakmaker 77 | ```` 78 | 79 | *Skip dependency download* 80 | 81 | If you think you already have all the dependcies or you already ran the `install-deps` script. 82 | 83 | ````bash 84 | ./install --install-dependencies N 85 | ```` 86 | 87 | 88 | *All parameters* 89 | ````bash 90 | ./install --installdir /var/ --sdks "8.1 9.3" --createnic y --nicusername "tweakmaker " --nicprefix net.tweakmaker --fallback Y 91 | --reinstall Y --install-dependencies Y --no-platformcheck N 92 | #OR 93 | 94 | ./install -d /var/ -s "8.1 9.3" -n y -u "tweakmaker " -p net.tweakmaker -f Y -r y -e Y -c N 95 | 96 | ```` 97 | 98 | ## Next Step 99 | 100 | Add the following lines to your ~/.bash_profile or ~/.bashrc 101 | 102 | ````bash 103 | export THEOS=~/theos 104 | 105 | #Optional 106 | export THEOS_DEVICE_IP= 107 | export THEOS_DEVICE_PORT=22 108 | ```` 109 | ## Tested Platforms 110 | * Windows 7 (Cygwin) 111 | * Windows 10 (Cygwin) 112 | * Linux Mint 17+ 113 | * Ubuntu 14.04+ 114 | 115 | ## Additional Scripts 116 | There are 2 more scripts on the repo 117 | 118 | * `install-deps` : Install theos dependencies before installing theos. This is already built-in on the main `install` script though. 119 | * `get-sdk`: Download additional sdks if you already have theos installed. 120 | 121 | 122 | ## Todo 123 | 124 | * Test on Windows 10 Subsystem for Linux 125 | * iOS & macOS support 126 | * option to create $THEOS variable into ~/.bash_profile or ~/.bashrc 127 | 128 | ## Changelog 129 | 130 | * v2.0.1 : 131 | - Added error handing on removing previous install 132 | * v2.0.0 : 133 | - Made `curl` a hard requirement for the script 134 | - Add `--install-dependencies` option. Default Y. 135 | - Add `--no-platformcheck` option. Default N. 136 | * v1.2.1 : 137 | - Updated iPhoneOS9.3 SDK source 138 | * v1.2.0 : 139 | - Custom iPhoneOS9.3 SDK source 140 | - More error handling 141 | - UI changes 142 | * v1.1.0 143 | - Added Reinstall parameter 144 | - Additional dependecy checks 145 | - Check if install folder is writeable. 146 | - Add ownership change 147 | - Add wget error handling 148 | - Progress message formatting 149 | * v1.0.1 150 | - Updated sdks website 151 | * v1.0.0 152 | - Merged indivual scripts 153 | * v0.2.0 154 | - Script for Linux 155 | * v0.1.0 156 | - Script for Cygwin 157 | -------------------------------------------------------------------------------- /get-sdk: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SDK_WEBSITE="https://sdks.website/dl" 4 | 5 | #------------------------------------------------------------------------------- 6 | # UI Functions 7 | HL_NORMAL="\e[39;49m" 8 | HL_YELLOW="\e[30;103m" 9 | HL_RED="\e[97;41m" 10 | FG_GREEN="\e[92m" 11 | FG_ORANGE="\e[91m" 12 | 13 | echo_title () { 14 | local COLS=`expr $(tput cols) - 2`; 15 | printf "${HL_YELLOW}%-${COLS}s${HL_NORMAL}\n" "$*" 16 | } 17 | echo_info () { 18 | echo -e "${FG_GREEN}$*${HL_NORMAL}" 19 | } 20 | echo_warning () { 21 | echo -e "${FG_ORANGE}$*${HL_NORMAL}" 22 | } 23 | echo_n_info () { 24 | echo -n -e "${FG_GREEN}$*${HL_NORMAL}" 25 | } 26 | echo_error () { 27 | echo; 28 | echo -e "${HL_RED}$*${HL_NORMAL}" 29 | echo; 30 | } 31 | 32 | #------------------------------------------------------------------------------- 33 | # Check if a paramter is passed. 34 | if [ "$*" == "" ]; then 35 | echo; 36 | echo " get-sdk: Downloads iOS SDK into your THEOS installation." 37 | echo " Usage: ./get-sdk [version]" 38 | echo " Example: ./get-sdk 9.3" 39 | echo " > will download iPhoneOS9.3.sdk into $THEOS/sdks/" 40 | echo 41 | echo; 42 | exit 0 43 | fi 44 | #------------------------------------------------------------------------------- 45 | if [ ! -w "$THEOS/sdks" ] 46 | then 47 | echo -e "$HL_RED $THEOS/sdks folder is not writeable. Run with sudo or switch to root.$HL_NORMAL" 48 | echo; 49 | exit 1 50 | fi 51 | #------------------------------------------------------------------------------- 52 | pushd $THEOS/sdks > /dev/null 53 | 54 | sdk="iPhoneOS$*.sdk" 55 | 56 | if [ -d "$THEOS/sdks/$sdk" ]; then 57 | echo; 58 | echo -e "$HL_RED $sdk already exists.$HL_NORMAL" 59 | echo; 60 | popd > /dev/null 61 | exit 1; 62 | fi 63 | 64 | echo_title " [DOWNLOADING ${sdk}...]"; 65 | 66 | if [ "$*" == "9.3" ]; then 67 | #git clone https://github.com/mstg/iOS-full-sdk.git .93tmp 68 | git clone https://github.com/theos/sdks .93tmp 69 | GIT_RESPONSE=$? 70 | if [ "$GIT_RESPONSE" == "0" ]; then 71 | mv .93tmp/iPhoneOS9.3.sdk . 72 | else 73 | echo_warning ">> Warning: Failed to download ${sdk}." 74 | echo; 75 | fi 76 | rm -rf .93tmp 77 | else 78 | wget "$SDK_WEBSITE/${sdk}.tbz2" --output-document=${sdk}.tbz2 79 | WGET_RESPONSE=$? 80 | 81 | if [ "$WGET_RESPONSE" == "0" ]; then 82 | echo_info " Extracting ${sdk}..."; 83 | tar xf ${sdk}.tbz2 84 | rm ${sdk}.tbz2* 85 | else 86 | echo_error "Failed to download ${sdk}." 87 | rm ${sdk}.tbz2 88 | popd > /dev/null 89 | exit 1 90 | fi 91 | fi 92 | 93 | echo_title " [DOWNLOADING ${sdk}...DONE.]"; 94 | 95 | popd > /dev/null 96 | -------------------------------------------------------------------------------- /install: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #------------------------------------------------------------------------------- 3 | # Universal Theos Install script 4 | # v2.0.0 5 | # 6 | # Changelog 7 | # v2.0.1 : Added error handling on removing previous install 8 | # v2.0.0 : Made curl a hard requirement for the script 9 | # : Add --install-dependencies option. Default Y. 10 | # : Add --no-platformcheck option. Default N. 11 | # 12 | # v1.2.1 : Updated iPhoneOS9.3 SDK source 13 | # v1.2.0 : Custom iPhoneOS9.3 SDK source 14 | # More error handling 15 | # UI changes 16 | # v1.1.0 : Added Reinstall parameter 17 | # Additional dependecy checks 18 | # Check if install folder is writeable. 19 | # Add ownership change 20 | # Add wget error handling 21 | # Progress message formatting 22 | # v1.0.1 : Updated sdks website 23 | # v1.0.0 : Merged indivual scripts 24 | # v0.2.0 : Script for Linux 25 | # v0.1.0 : Script for Cygwin 26 | #------------------------------------------------------------------------------- 27 | THEOS_FOLDER_NAME="theos" 28 | #------------------------------------------------------------------------------- 29 | # Variables for parameters 30 | THEOS_INSTALL_FOLDER=~/ # -d | --installdir 31 | CREATE_NIC="N" # -n | --createnic 32 | NIC_USERNAME="My Name " # -u | --nicusername 33 | NIC_PREFIX="com.mycompany" # -p | --nicprefix 34 | INCLUDE_FALLBACK_HEADERS="N" # -f | --fallback 35 | REINSTALL="N" # -r | --reinstall 36 | SKIP_PLATFORMCHECK="N" # -c | --no-platformcheck 37 | INSTALL_DEPENDENCIES="Y" # -e | --install-dependencies 38 | declare -a SDKS=(9.2); # -s | --sdks 39 | 40 | #------------------------------------------------------------------------------- 41 | # Other Variables 42 | 43 | # SDK_WEBSITE: The website where to download SDKS 44 | SDK_WEBSITE="https://sdks.website/dl" 45 | 46 | # Dependencies: 47 | # DEPS_HARD : Hard dependecies. Required to execute this script 48 | # DEPS_ALL : Dependencies common to all platforms 49 | # DEPS_CYGWIN : Cygwin dependecies 50 | # DEPS_LINUX : Linux dependecies 51 | # DEPS_IOS : iOS dependencies 52 | declare -a DEPS_HARD=(curl) 53 | declare -a DEPS_ALL=(wget git make perl python) 54 | declare -a DEPS_CYGWIN=(ca-certificates openssh) 55 | declare -a DEPS_LINUX=(ssh plistutil) 56 | declare -a DEPS_DARWIN=(ca-certificates) 57 | 58 | # CURL Options: This is use to download apt-cyg on Cygwin systems 59 | # -O : Write output to a file named as the remote file 60 | # -L : Follow redirects 61 | # -k : Allow connections to SSL sites without certs 62 | # -s : Silent mode. Don't output anything 63 | CURLCMD="curl -O -J -L -k -s" 64 | 65 | #------------------------------------------------------------------------------- 66 | # UI Functions: Just some fancy coloring to easily view installation progress 67 | HL_NORMAL="\e[39;49m" 68 | HL_YELLOW="\e[30;103m" 69 | HL_RED="\e[97;41m" 70 | FG_GREEN="\e[92m" 71 | FG_YELLOW="\e[93m" 72 | 73 | echo_title () { 74 | local COLS=`expr $(tput cols) - 2`; 75 | printf "${HL_YELLOW}%-${COLS}s${HL_NORMAL}\n" "$*" 76 | } 77 | echo_info () { 78 | echo -e "${FG_GREEN}$*${HL_NORMAL}" 79 | } 80 | echo_warning () { 81 | echo -e "${FG_YELLOW}$*${HL_NORMAL}" 82 | } 83 | echo_n_info () { 84 | echo -n -e "${FG_GREEN}$*${HL_NORMAL}" 85 | } 86 | echo_error () { 87 | echo; 88 | echo -e "${HL_RED}$*${HL_NORMAL}" 89 | echo; 90 | } 91 | #------------------------------------------------------------------------------- 92 | tput clear # this one works accross platforms 93 | 94 | #------------------------------------------------------------------------------- 95 | # start name parameters parser 96 | # https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash 97 | # Use > 1 to consume two arguments per pass in the loop (e.g. each 98 | # argument has a corresponding value to go with it). 99 | # Use > 0 to consume one or more arguments per pass in the loop (e.g. 100 | # some arguments don't have a corresponding value to go with it such 101 | # as in the --default example). 102 | # note: if this is set to > 0 the /etc/hosts part is not recognized ( may be a bug ) 103 | while [[ $# > 1 ]] 104 | do 105 | key="$1" 106 | 107 | case $key in 108 | -d|--installdir) 109 | THEOS_INSTALL_FOLDER="$2" 110 | shift # past argument 111 | ;; 112 | -n|--createnic) 113 | CREATE_NIC="$2" 114 | CREATE_NIC=${CREATE_NIC^^} 115 | shift # past argument 116 | ;; 117 | -u|--nicusername) 118 | NIC_USERNAME="$2" 119 | shift # past argument 120 | ;; 121 | -p|--nicprefix) 122 | NIC_PREFIX="$2" 123 | shift # past argument 124 | ;; 125 | -s|--sdks) 126 | ARG_SDKS="$2" 127 | declare -a SDKS=($ARG_SDKS); 128 | shift # past argument 129 | ;; 130 | -f|--fallback) 131 | INCLUDE_FALLBACK_HEADERS="$2" 132 | INCLUDE_FALLBACK_HEADERS=${INCLUDE_FALLBACK_HEADERS^^} 133 | shift # past argument 134 | ;; 135 | -r|--reinstall) 136 | REINSTALL="$2" 137 | REINSTALL=${REINSTALL^^} 138 | shift # past argument 139 | ;; 140 | -c|--no-platformcheck) 141 | SKIP_PLATFORMCHECK="$2" 142 | SKIP_PLATFORMCHECK=${SKIP_PLATFORMCHECK^^} 143 | shift # past argument 144 | ;; 145 | -e|--install-dependencies) 146 | INSTALL_DEPENDENCIES="$2" 147 | INSTALL_DEPENDENCIES=${INSTALL_DEPENDENCIES^^} 148 | shift # past argument 149 | ;; 150 | --default) 151 | DEFAULT=YES 152 | ;; 153 | *) 154 | # unknown option 155 | ;; 156 | esac 157 | shift # past argument or value 158 | done 159 | # end name parameters parser 160 | 161 | #------------------------------------------------------------------------------- 162 | # Check supported platforms 163 | PLATFORM=`uname -o` 164 | PLATFORMS=(Cygwin GNU/Linux) # still needs more iOS, macOS 165 | 166 | if [ "$SKIP_PLATFORMCHECK" == "N" ]; then 167 | if [[ ! ${PLATFORMS[*]} =~ "$PLATFORM" ]] 168 | then 169 | echo_error "This script is not tested on your platform -- $PLATFORM." 170 | echo_warning "Run with '--no-platformcheck Y' to skip this message." 171 | echo; 172 | exit 1 173 | fi 174 | fi 175 | 176 | #------------------------------------------------------------------------------- 177 | # Display pre-installation summary to and prompt to confirm 178 | echo 179 | echo_info "THEOS will be installed with the following configuration." 180 | echo 181 | echo -e " THEOS_INSTALL_FOLDER = ${THEOS_INSTALL_FOLDER}${THEOS_FOLDER_NAME}" 182 | echo -e " INCLUDE_FALLBACK_HEADERS = ${INCLUDE_FALLBACK_HEADERS}" 183 | echo -e " REINSTALL = ${REINSTALL}" 184 | for i in ${SDKS[@]}; do 185 | SDKSTR="$SDKSTR${i} " 186 | done 187 | echo -e " SDKS = ${SDKSTR}" 188 | 189 | echo -e " CREATE_NIC = ${CREATE_NIC}" 190 | if [ "$CREATE_NIC" == "Y" ] 191 | then 192 | echo -e " NIC_USERNAME = ${NIC_USERNAME}" 193 | echo -e " NIC_PREFIX = ${NIC_PREFIX}" 194 | fi 195 | echo -e " INSTALL_DEPENDENCIES = ${INSTALL_DEPENDENCIES}" 196 | echo -e " SKIP_PLATFORMCHECK = ${SKIP_PLATFORMCHECK}" 197 | 198 | echo; 199 | if [ "$REINSTALL" == "Y" ]; then 200 | if [ -d "$THEOS_INSTALL_FOLDER$THEOS_FOLDER_NAME" ]; then 201 | echo_warning " WARNING: This will delete the theos instance installed at $THEOS_INSTALL_FOLDER$THEOS_FOLDER_NAME." 202 | echo; 203 | fi 204 | fi 205 | echo_n_info "Proceed (Y/N)? "; 206 | read -n 1 -r; 207 | echo; 208 | if [[ ! $REPLY =~ ^[Yy]$ ]] 209 | then 210 | echo_error "theos install aborted." 211 | exit 1 212 | fi 213 | #------------------------------------------------------------------------------- 214 | # Display pre-installation check 215 | echo; 216 | echo_title " [PRE-SETUP CHECK...]" 217 | echo ""; 218 | 219 | echo_info ">> Checking parameters..." 220 | 221 | # Check if the install folder is writable 222 | if [ ! -w "$THEOS_INSTALL_FOLDER" ] 223 | then 224 | echo_error "$THEOS_INSTALL_FOLDER is not writeable. Run with sudo or choose another path." 225 | exit 1 226 | fi 227 | 228 | # Check if theos already exists when not reinstalling 229 | if [ "$REINSTALL" == "N" ]; then 230 | if [ -d "$THEOS_INSTALL_FOLDER$THEOS_FOLDER_NAME" ]; then 231 | echo_error "THEOS is already installed in $THEOS_INSTALL_FOLDER$THEOS_FOLDER_NAME." 232 | exit 1; 233 | fi 234 | fi 235 | 236 | # Check nic parameters 237 | if [ "$CREATE_NIC" == "Y" ]; then 238 | 239 | if [ -e ~/.nicrc ]; then 240 | echo_error ".nicrc already exists. Back it up and remove." 241 | exit 1; 242 | fi 243 | # if CREATE_NIC=Y, require username and prefix 244 | if [ "$NIC_USERNAME" == "My Name " ]; then 245 | echo_error "You need to provide a new username using the --nicusername (-u) parameter." 246 | exit 1 247 | fi 248 | 249 | if [ "$NIC_PREFIX" == "com.mycompany" ]; then 250 | echo_error "You need to provide a new prefix using the --nicprefix (-p) parameter." 251 | exit 1 252 | fi 253 | 254 | fi 255 | echo_info ">> Done." 256 | 257 | #------------------------------------------------------------------------------- 258 | echo_info ">> Checking hard dependencies..." 259 | 260 | for i in ${DEPS_HARD[@]}; do 261 | echo -n " ${i} "; 262 | if [ "$PLATFORM" == "Cygwin" ] && ([[ $(cygcheck -c ${i} | grep OK) == *"OK"* ]]) 263 | then 264 | echo_info "OK." 265 | elif [ "$PLATFORM" != "Cygwin" ] && ([[ $(dpkg-query -W -f='${Status}\n' ${i} 2>/dev/null | grep ok) == *"ok"* ]]) 266 | then 267 | echo_info "OK." 268 | else 269 | echo_warning "not installed." 270 | echo_error "${i} is required to use this script." 271 | exit 1; 272 | fi 273 | done 274 | 275 | #------------------------------------------------------------------------------- 276 | echo_info ">> Checking dependencies..." 277 | DEP_MISSING=0 278 | 279 | if [ "$PLATFORM" == "Cygwin" ]; 280 | then 281 | declare -a extdeps=${DEPS_CYGWIN[@]} 282 | else 283 | declare -a extdeps=${DEPS_LINUX[@]} 284 | fi 285 | combined=("${DEPS_ALL[@]}" "${extdeps[@]}" ) 286 | for i in ${combined[@]}; do 287 | echo -n " ${i} "; 288 | if [ "$PLATFORM" == "Cygwin" ] && ([[ $(cygcheck -c ${i} | grep OK) == *"OK"* ]]) 289 | then 290 | echo_info "OK." 291 | elif [ "$PLATFORM" != "Cygwin" ] && ([[ $(dpkg-query -W -f='${Status}\n' ${i} 2>/dev/null | grep ok) == *"ok"* ]]) 292 | then 293 | echo_info "OK." 294 | else 295 | echo_warning "not installed." 296 | DEP_MISSING=1 297 | fi 298 | done 299 | 300 | if [ "$DEP_MISSING" == "1" ]; then 301 | # Show warning if INSTALL_DEPENDENCIES is provided 302 | if [ "$INSTALL_DEPENDENCIES" == "Y" ];then 303 | echo; 304 | echo_warning " Warning, there are missing dependecies." 305 | echo_warning " This script will to install the missing items." 306 | echo; 307 | # Otherwise, show error and exit 308 | else 309 | echo_error ">> You need to install the missing packages first." 310 | exit 1; 311 | fi 312 | 313 | fi 314 | echo_info ">> Done." 315 | #------------------------------------------------------------------------------- 316 | echo 317 | echo_info ">> Ready to install." 318 | echo 319 | echo_title " [PRE-SETUP CHECK...DONE]"; 320 | 321 | echo; 322 | echo_n_info "Proceed to install (Y/N)? "; 323 | read -n 1 -r; 324 | echo; 325 | if [[ ! $REPLY =~ ^[Yy]$ ]]; then 326 | echo_error "theos install aborted." 327 | exit 1 328 | fi 329 | echo; 330 | #------------------------------------------------------------------------------- 331 | # Install dependencies first 332 | if [ "$INSTALL_DEPENDENCIES" == "Y" ];then 333 | 334 | echo_title " [INSTALLING DEPENDENCIES...]"; 335 | 336 | if [ "$PLATFORM" == "Cygwin" ]; then 337 | echo_info ">> apt-cyg" 338 | if [ ! -e /bin/apt-cyg ]; then 339 | echo_info " Downloading..." 340 | ${CURLCMD} https://raw.githubusercontent.com/transcode-open/apt-cyg/master/apt-cyg 341 | if [[ $? != 0 ]]; then 342 | echo_error "Failed." 343 | exit 1; 344 | else 345 | echo_info " Installing..." 346 | install ./apt-cyg /bin 347 | echo_info " Linking to apt-get..." 348 | ln -s /bin/apt-cyg /bin/apt-get 349 | rm ./apt-cyg 350 | fi 351 | else 352 | echo_info " apt-cyg is already installed." 353 | fi 354 | fi 355 | 356 | for i in ${combined[@]}; do 357 | echo_info ">> ${i}" 358 | if [ "$PLATFORM" == "Cygwin" ] && ([[ $(cygcheck -c ${i} | grep OK) == *"OK"* ]]); then 359 | echo_info " ${i} is already installed." 360 | elif [ "$PLATFORM" != "Cygwin" ] && ([[ $(dpkg-query -W -f='${Status}\n' ${i} 2>/dev/null | grep ok) == *"ok"* ]]); then 361 | echo_info " ${i} is already installed." 362 | else 363 | echo_warning " ${i} is not installed. Initiating install..." 364 | echo; 365 | apt-get install ${i} 366 | if [[ $? != 0 ]]; then 367 | echo_error " ${i} installation failed. " 368 | echo_warning "You may need to run apt-get update to update your package listing." 369 | if [ "$PLATFORM" == "Cygwin" ]; then 370 | echo_warning "Or run apt-cyg update to add another Cygwin mirror." 371 | echo; 372 | fi 373 | exit 1; 374 | fi 375 | fi 376 | done #for 377 | 378 | echo_title " [INSTALLING DEPENDENCIES...DONE.]"; 379 | fi 380 | 381 | #------------------------------------------------------------------------------- 382 | echo_title " [PREPARE INSTALL FOLDER...]"; 383 | 384 | # If the install folder is missing, create it 385 | if [ ! -d "$THEOS_INSTALL_FOLDER" ]; then 386 | mkdir -p $THEOS_INSTALL_FOLDER 387 | fi 388 | 389 | if [ "$REINSTALL" == "Y" ]; then 390 | echo_info ">> Removing previous installation..."; 391 | rm -rf $THEOS_INSTALL_FOLDER$THEOS_FOLDER_NAME 392 | if [[ $? != 0 ]]; then 393 | echo_error "Failed to remove previous installation." 394 | echo_warning "Try running script with sudo."; 395 | exit 1; 396 | fi 397 | echo_info ">> Done."; 398 | fi 399 | 400 | echo_title " [PREPARE INSTALL FOLDER...DONE]"; 401 | 402 | #------------------------------------------------------------------------------- 403 | 404 | # go to the install folder 405 | pushd $THEOS_INSTALL_FOLDER > /dev/null 406 | 407 | #------------------------------------------------------------------------------- 408 | echo; 409 | echo_title " [DOWNLOADING THEOS...]"; 410 | 411 | echo_info ">> Cloning git repo..."; 412 | git clone --progress --recursive https://github.com/theos/theos.git $THEOS_FOLDER_NAME 413 | GIT_RESPONSE=$? 414 | if [ "$GIT_RESPONSE" == "0" ]; then 415 | echo_info ">> Done."; 416 | else 417 | echo_error "Failed to download theos." 418 | popd > /dev/null 419 | exit 1 420 | fi 421 | 422 | # Change the owner of the install folder so that you won't have problems 423 | # when updating theos. 424 | if [[ "$SUDO_UID" != "" ]] # assume sudo was used to force install 425 | then 426 | echo_info ">> Owning theos folder..."; 427 | chown $SUDO_UID:$SUDO_GID $THEOS_FOLDER_NAME 428 | echo_info ">> Done."; 429 | fi 430 | 431 | echo_title " [DOWNLOADING THEOS...DONE]"; 432 | #------------------------------------------------------------------------------- 433 | echo; 434 | echo_title " [DOWNLOADING SDKS...]"; 435 | 436 | pushd $THEOS_FOLDER_NAME/sdks/ > /dev/null 437 | for i in ${SDKS[@]}; do 438 | echo; 439 | sdk="iPhoneOS${i}.sdk" 440 | 441 | echo_info "Downloading ${sdk}..."; 442 | 443 | if [ "${i}" == "9.3" ]; then 444 | git clone https://github.com/theos/sdks .93tmp 445 | 446 | GIT_RESPONSE=$? 447 | if [ "$GIT_RESPONSE" == "0" ]; then 448 | mv .93tmp/iPhoneOS9.3.sdk ./ 449 | else 450 | echo_warning ">> Warning: Failed to download ${sdk}." 451 | echo; 452 | fi 453 | rm -rf .93tmp 454 | else 455 | wget "$SDK_WEBSITE/${sdk}.tbz2" --output-document=${sdk}.tbz2 456 | WGET_RESPONSE=$? 457 | 458 | if [ "$WGET_RESPONSE" == "0" ]; then 459 | echo_info "Extracting ${sdk}..."; 460 | tar xf ${sdk}.tbz2 461 | else 462 | echo_warning ">> Warning: Failed to download ${sdk}." 463 | echo; 464 | fi 465 | rm ${sdk}.tbz2 466 | fi 467 | 468 | done 469 | popd > /dev/null 470 | echo 471 | echo_title " [DOWNLOADING SDKS...DONE.]"; 472 | 473 | #------------------------------------------------------------------------------- 474 | echo; 475 | echo_title " [DOWNLOADING TOOLCHAIN....]"; 476 | 477 | if [ "$PLATFORM" == "Cygwin" ]; 478 | then 479 | mkdir -p $THEOS_FOLDER_NAME/toolchain/windows 480 | echo_info ">> Dowloading Windows toolchain..."; 481 | git clone --branch x86_64 https://github.com/coolstar/iOSToolchain4Win.git $THEOS_FOLDER_NAME/toolchain/windows/iphone 482 | GIT_RESPONSE=$? 483 | if [ "$GIT_RESPONSE" == "0" ]; then 484 | echo_info ">> Done."; 485 | else 486 | echo_warning ">> Warning: Failed to download toolchain."; 487 | echo; 488 | fi 489 | 490 | else 491 | echo_info ">> Dowloading Linux toolchain..."; 492 | wget https://developer.angelxwind.net/Linux/ios-toolchain_clang%2bllvm%2bld64_latest_linux_x86_64.zip 493 | WGET_RESPONSE=$? 494 | 495 | if [ "$WGET_RESPONSE" == "0" ]; then 496 | echo_info ">> Extracting..."; 497 | unzip -q ios-toolchain_clang+llvm+ld64_latest_linux_x86_64.zip -d $THEOS_FOLDER_NAME/toolchain/ 498 | rm ios-toolchain_clang+llvm+ld64_latest_linux_x86_64.zip 499 | echo_info ">> Done."; 500 | else 501 | echo_warning ">> Warning: Failed to download toolchain."; 502 | echo; 503 | fi 504 | 505 | 506 | fi 507 | echo_title " [DOWNLOADING TOOLCHAIN....DONE.]"; 508 | #------------------------------------------------------------------------------- 509 | if [ "$INCLUDE_FALLBACK_HEADERS" == "Y" ] 510 | then 511 | echo; 512 | echo_title " [DOWNLOADING FALLBACK HEADERS....]"; 513 | echo_info ">> Downloading supermamon's fallback headers...${HL_NORMAL}"; 514 | git clone https://github.com/supermamon/iOS-fallback-headers.git $THEOS_FOLDER_NAME/include/_fallback 515 | GIT_RESPONSE=$? 516 | if [ "$GIT_RESPONSE" != "0" ]; then 517 | echo_warning "WARNING: Fallback headers failed to download." 518 | fi 519 | echo_title " [DOWNLOADING FALLBACK HEADERS....DONE.]"; 520 | fi 521 | 522 | #------------------------------------------------------------------------------- 523 | 524 | popd > /dev/null 525 | 526 | #------------------------------------------------------------------------------- 527 | if [ "$CREATE_NIC" == "Y" ] 528 | then 529 | 530 | echo_title " [CREATING .nicrc...]"; 531 | echo "username = \"$NIC_USERNAME\"" > .nicrc 532 | echo "package_prefix = \"$NIC_PREFIX\"" >> .nicrc 533 | mv -f .nicrc ~/ 534 | echo_title " [CREATING .nicrc...DONE.]"; 535 | 536 | fi 537 | echo; 538 | echo_info "THEOS install completed."; 539 | echo; 540 | -------------------------------------------------------------------------------- /install-deps: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # install-deps v1.0.2 4 | # This script is used to install dependencies required by theos. 5 | # Changelog 6 | # v1.0.2 : Add suggestions for package install errors 7 | # v1.0.1 : Fix curl options 8 | # v1.0.0 : First version 9 | 10 | #------------------------------------------------------------------------------- 11 | PLATFORM=`uname -o` 12 | APTGET="apt-get" 13 | declare -a DEPS_ALL=(wget git make perl python) 14 | declare -a DEPS_CYGWIN=(ca-certificates openssh) 15 | declare -a DEPS_LINUX=(ssh) 16 | #declare -a DEPS_DARWIN=(ca-certificates) 17 | #------------------------------------------------------------------------------- 18 | # CURL Options 19 | # -O : Write output to a file named as the remote file 20 | # -J : Use the header-provided filename 21 | # -L : Follow redirects 22 | # -k : Allow connections to SSL sites without certs 23 | # -s : Silent mode. Don't output anything 24 | CURLCMD="curl -O -J -L -k -s" 25 | #------------------------------------------------------------------------------- 26 | # UI Functions 27 | HL_NORMAL="\e[39;49m" 28 | HL_YELLOW="\e[30;103m" 29 | HL_RED="\e[97;41m" 30 | FG_GREEN="\e[92m" 31 | FG_YELLOW="\e[93m" 32 | 33 | echo_title () { 34 | local COLS=`expr $(tput cols) - 2`; 35 | printf "${HL_YELLOW}%-${COLS}s${HL_NORMAL}\n" "$*" 36 | } 37 | echo_info () { 38 | echo -e "${FG_GREEN}$*${HL_NORMAL}" 39 | } 40 | echo_warning () { 41 | echo -e "${FG_YELLOW}$*${HL_NORMAL}" 42 | } 43 | echo_n_info () { 44 | echo -n -e "${FG_GREEN}$*${HL_NORMAL}" 45 | } 46 | echo_error () { 47 | echo; 48 | echo -e "${HL_RED}$*${HL_NORMAL}" 49 | echo; 50 | } 51 | #------------------------------------------------------------------------------- 52 | echo_title " [PRE-CHECK: curl installation]"; 53 | if [ "$PLATFORM" == "Cygwin" ] && ([[ $(cygcheck -c curl | grep OK) != *"OK"* ]]); then 54 | echo_error "curl is not installed. Please run Cygwin setup again to install curl." 55 | exit 1; 56 | elif [ "$PLATFORM" != "Cygwin" ] && ([[ $(dpkg-query -W -f='${Status}\n' curl 2>/dev/null | grep ok) != *"ok"* ]]); then 57 | echo_info "Installing curl..." 58 | ${APTGET} install curl 59 | if [[ $? != 0 ]]; then 60 | echo_error "curl installation failed. Please install manually." 61 | exit 1; 62 | else 63 | echo_info " Done." 64 | fi 65 | else 66 | echo_info "curl is installed and ready." 67 | fi 68 | #------------------------------------------------------------------------------- 69 | echo_title " [PRE-CHECK: apt-get installation]"; 70 | # Assumes apt-get is installed on non-Cygwin platforms 71 | # Tries to download apt-cyg and symlink as apt-get 72 | if [ "$PLATFORM" == "Cygwin" ]; then 73 | if [ ! -e /bin/apt-cyg ]; then 74 | echo_info "Downloading apt-cyg..." 75 | ${CURLCMD} https://raw.githubusercontent.com/transcode-open/apt-cyg/master/apt-cyg 76 | if [[ $? != 0 ]]; then 77 | echo_error "Failed." 78 | exit 1; 79 | else 80 | echo_info "Installing apt-cyg..." 81 | install ./apt-cyg /bin 82 | echo_info "Linking apt-cyg to apt-get..." 83 | ln -s /bin/apt-cyg /bin/apt-get 84 | rm ./apt-cyg 85 | fi 86 | fi 87 | #APTGET="apt-cyg" 88 | fi 89 | echo_info "apt-get is ready." 90 | 91 | #------------------------------------------------------------------------------- 92 | echo_title " [Installing Dependencies...]"; 93 | if [ "$PLATFORM" == "Cygwin" ]; 94 | then 95 | declare -a extdeps=${DEPS_CYGWIN[@]} 96 | else 97 | declare -a extdeps=${DEPS_LINUX[@]} 98 | fi 99 | combined=("${DEPS_ALL[@]}" "${extdeps[@]}" ) 100 | for i in ${combined[@]}; do 101 | echo_info "Checking ${i} installation..." 102 | if [ "$PLATFORM" == "Cygwin" ] && ([[ $(cygcheck -c ${i} | grep OK) == *"OK"* ]]); then 103 | echo_info " ${i} is already installed." 104 | elif [ "$PLATFORM" != "Cygwin" ] && ([[ $(dpkg-query -W -f='${Status}\n' ${i} 2>/dev/null | grep ok) == *"ok"* ]]); then 105 | echo_info " ${i} is already installed." 106 | else 107 | echo_warning " ${i} is not installed. Initiating install..." 108 | ${APTGET} install ${i} 109 | if [[ $? != 0 ]]; then 110 | echo_error " ${i} installation failed. " 111 | echo_warning " You may need to run apt-get update to update your package listing." 112 | if [ "$PLATFORM" == "Cygwin" ]; then 113 | echo_warning " Or run apt-cyg update to add another Cygwin mirror." 114 | echo; 115 | fi 116 | exit 1; 117 | fi 118 | fi 119 | done #for 120 | echo_title " [Installing Dependencies...Done.]"; 121 | #------------------------------------------------------------------------------- 122 | -------------------------------------------------------------------------------- /test: -------------------------------------------------------------------------------- 1 | 2 | THEOS_INSTALL_FOLDER=~/ # -d | --installdir 3 | CREATE_NIC="N" # -n | --createnic 4 | NIC_USERNAME="My Name " # -u | --nicusername 5 | NIC_PREFIX="com.mycompany" # -p | --nicprefix 6 | INCLUDE_FALLBACK_HEADERS="N" # -f | --fallback 7 | REINSTALL="N" # -r | --reinstall 8 | SKIP_PLATFORMCHECK="N" # -c | --no-platformcheck 9 | INSTALL_DEPENDENCIES="N" # -e | --install-dependencies 10 | declare -a SDKS=(9.2); # -s | --sdks 11 | 12 | 13 | while getopts "dnu:p:frces:" flag; do 14 | case "$flag" in 15 | d) THEOS_INSTALL_FOLDER=$OPTARG;; 16 | n) CREATE_NIC="Y";; 17 | u) NIC_USERNAME=$OPTARG;; 18 | p) NIC_PREFIX="$OPTARG";; 19 | f) INCLUDE_FALLBACK_HEADERS="Y";; 20 | r) REINSTALL="Y";; 21 | c) SKIP_PLATFORMCHECK="Y";; 22 | e) INSTALL_DEPENDENCIES="Y";; 23 | s) SDKS=$OPTARG;; 24 | esac 25 | done 26 | 27 | echo "THEOS_INSTALL_FOLDER : $THEOS_INSTALL_FOLDER"; 28 | echo "CREATE_NIC : $CREATE_NIC"; 29 | echo "NIC_USERNAME : $NIC_USERNAME"; 30 | echo "NIC_PREFIX : $NIC_PREFIX"; 31 | echo "INCLUDE_FALLBACK_HEADERS : $INCLUDE_FALLBACK_HEADERS"; 32 | echo "REINSTALL : $REINSTALL"; 33 | echo "SKIP_PLATFORMCHECK : $SKIP_PLATFORMCHECK"; 34 | echo "INSTALL_DEPENDENCIES : $INSTALL_DEPENDENCIES"; 35 | echo "SDKS : $SDKS"; 36 | --------------------------------------------------------------------------------