Last active
May 30, 2018 16:54
-
-
Save NullArray/1384c4aae7e73eeb51b620b1abcf6ea7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#____ ____ __ | |
#\ \ / /____ _____/ |_ ___________ | |
# \ Y // __ \_/ ___\ __\/ _ \_ __ \ | |
# \ /\ ___/\ \___| | ( <_> ) | \/ | |
# \___/ \___ >\___ >__| \____/|__| | |
# \/ \/ | |
# | |
#--Licensed under GNU GPL 3 | |
#--Creates for Android OS, an .IMG file to emulate internal storage | |
#--IMG and ISO Format will then be used to run Android as VM with QEMU | |
#--When the main operations are completed the VM will be started | |
#--Using QEMU, complete with the correct parameters. | |
# | |
#--Authored by : NullArray/Vector | |
############################################################## | |
# Coloring scheme for notfications and logo | |
ESC="\x1b[" | |
RESET=$ESC"39;49;00m" | |
CYAN=$ESC"33;36m" | |
RED=$ESC"31;01m" | |
GREEN=$ESC"32;01m" | |
# Warning | |
function warning() | |
{ echo -e "\n$RED [!] $1 $RESET\n" | |
} | |
# Green notification | |
function notification() | |
{ echo -e "\n$GREEN [+] $1 $RESET\n" | |
} | |
# Cyan notification | |
function notification_b() | |
{ echo -e "$CYAN $1 $RESET" | |
} | |
# This function has been sorted here for practical purposes | |
function check_dir() | |
{ printf "\nPlease make sure you provide the full path to your Android ISO." | |
printf "In example: ~/home/$USER/Android.iso\n" | |
read -p 'Enter a location : ' android_dir | |
printf "\nChecking location...\n" | |
sleep 1.5 | |
# If the Android.iso dir turns out to be wrong the reset var will be set to 1 | |
stat $android_dir >> /dev/null || warning "Unable to detect specified location." && reset=1 | |
} | |
# Print Logo | |
notification_b " ___ ___ __ __ __ " | |
notification_b "| | |.--| |.----.-----.|__|.--| | " | |
notification_b "| | || _ || _| _ || || _ | " | |
notification_b " \_____/ |_____||__| |_____||__||_____| " | |
notification_b "\nV-Droid. QEMU Powered Android VM " | |
# Query for storage location | |
printf "\n\nPlease choose a location where V-Droid can | |
write out a file that will serve as the emulated Android's | |
internal storage.\n\n" | |
sleep 2 | |
read -p 'Enter a location : ' target_dir | |
cd $target_dir >> /dev/null || warning "Location not found, writing dir and file..." && mkdir $target_dir && cd $target-dir | |
qemu-img create -f qcow2 android.img 1G && check_dir | |
notification "Operation completed." | |
sleep 2 | |
# If the reset var has been set to 1 we just prompt for a retry instead of exitting out | |
if [[ $reset == 1 ]]; then | |
printf "Unfortunately the path to the Android image appears to be invalid." | |
read -p 'Retry? Y/n : ' choice | |
if [[ $choice == 'y' || $choice == 'Y' ]]; then | |
check_dir | |
else | |
warning "Aborted." | |
fi | |
fi | |
notification "Operation Completed" | |
printf "Starting QEMU with the following arguments: '-soundhw es1370 -net nic -net user -cdrom'" && sleep 2 | |
qemu-kvm -soundhw es1370 -net nic -net user -cdrom ${@:-$android_dir} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment