diff --git a/install.sh b/install.sh deleted file mode 100755 index b951803..0000000 --- a/install.sh +++ /dev/null @@ -1,90 +0,0 @@ -#!/bin/sh - -echo "HOI, this is the 'Arch w/ maride flavour' install script (chainloader)" -echo "Hope you used TLS..." -echo -e "=-=-=-=-=-=-=-=-=-=-=\n" - -echo "=> Things you should've set up already:" -echo " * Your keyboard layout (consider passwords!)" -echo " * Any RAID setup that you are planning to set up" -echo " * An internet connection (DHCP or static, idc...)" -echo -n "=> Did you set that up? (y/N) " -read answer - -if [ "$answer" != "y" ] && [ "$answer" != "Y" ]; then - echo "OK, then do necessary steps and see you soon." - exit 1 -fi - -echo -n "=> Do you want to install on EFI or BIOS? BIOS is required for VirtalBox hosts (E/b) " -read answer - -if [ "$answer" != "e" ] && [ "$answer" != "E" ]; then - export bootloader="BIOS"; -else - export bootloader="EFI"; -fi - -echo "=> Please enter the full path to the block device the installation should take place on: (e.g. /dev/sda)" -echo " Make sure to choose a drive, not a partition." -echo " Hint: here's a list of devices that may be the right:" -ls /dev/sd* /dev/mmc* 2>/dev/null -echo -n "Install to: " -read blockdevice -export blockdevice - -for check in checks/*.check -do - echo "=> Running check '$check'..." - source $check - if [ "$amf_return" -ne 0 ]; then - echo "=> Check failed. Fix it, maybe." - exit - fi -done - -for step in steps/*.step -do - echo "=> Running step '$step'..." - source $step - if [ "$amf_return" -ne 0 ]; then - echo "=> Step failed. That is weird. Sorry. Check logs maybe." - exit - fi -done - -for flavour in flavours/*.flavour -do - # in any case, run it once - rerun=1 - - while [ $rerun -eq 1 ]; do - echo -n "=> Do you want to run flavour '$flavour'? (y/N) " - read answer - - rerun=0; - - if [ "$answer" == "y" ] || [ "$answer" == "Y" ]; then - echo "=> Running flavour '$flavour'..." - pushd $flavour - source ./install.sh - if [ "$amf_return" -ne 0 ]; then - echo "=> Flavour failed. :( Rerun? (Y/n) " - read answer - if [ "$answer" == "y" ] || [ "$answer" == "Y" ]; then - rerun=1; - fi - fi - popd - fi - done -done - -echo -n "=> Finished \o/ reboot now? (Y/n) " -read answer - -if [ "$answer" == "n" ] || [ "$answer" == "N" ]; then - exit -fi - -reboot diff --git a/run.py b/run.py new file mode 100755 index 0000000..29d5795 --- /dev/null +++ b/run.py @@ -0,0 +1,138 @@ +#!/usr/bin/env python + +import os +import subprocess +import sys + + +def quit(): + print("OK, then do necessary steps and see you soon.") + sys.exit(1) + + +def motd(termsize): + print("HOI, this is the 'Arch w/ maride flavour' install script (chainloader)") + print("Hope you used TLS...") + _separator(termsize) + + print("Things you should've set up already:") + print(" * Your keyboard layout (consider passwords!)") + print(" * Any RAID setup that you are planning to set up") + print(" * An internet connection (DHCP or static, idc...)") + + answer = _ask("Did you set that up?", [ "yes", "no" ]) + + if answer == "no": + quit() + + _separator(termsize) + + +def efibios(termsize, settings): + print("Please choose the installation/startup method.") + print("Note that BIOS is required for VirtalBox hosts due a long-time unfixed bug.") + print("It's possible that you need to change Mainboard settings for EFI. (But it's recommended!)") + settings["bootmethod"] = _ask("Do you want to install on EFI or BIOS?", [ "EFI", "BIOS" ]) + + +def blockdevice(termsize, settings): + print("Please enter the full path to the block device the installation should take place on: (e.g. /dev/sda)") + print("Make sure to choose a drive, not a partition.") + print("Here's a list of devices that may be the right:") + settings["targetdevice"] = _ask("Install where?", os.listdir("/sys/block/")) + + +def checks(termsize, settings): + for check in os.listdir("checks/"): + if check[-6:] == ".check": + # Run loop + run = True + while run: + _separator(termsize) + print("Running '%s'" % (check)) + with subprocess.Popen(["checks/%s" % check]) as process: + # Wait for process termination + process.wait() + if process.returncode > 0: + # Woops, check failed somehow + print("Check %s returned non-null error code %i." % (check, process.returncode)) + answer = _ask("Do you want to re-run the check, skip the check or abort the installation?", [ "run", "skip", "abort"]) + if answer == "run": + # doesn't matter, run is already 'True' + continue + elif answer == "skip": + run = False + elif answer == "abort": + quit() + else: + run = False + else: + print("Uh. Found this non-check script in the 'checks' folder: '%s' (Not executing)" % (check)) + + +def flavours(termsize, settings): + for flavour in os.listdir("flavours/"): + if flavour[-8:] == ".flavour": + # Run loop + if _ask("Do you want to run flavour %s?" % (flavour), [ "yes", "no" ]) == "no": + continue + + run = True + while run: + _separator(termsize) + with subprocess.Popen(["flavours/%s/install.sh" % flavour]) as process: + # Wait for process termination + process.wait() + if process.returncode > 0: + # Woops, flavour failed somehow + print("Flavour %s returned non-null error code %i." % (flavour, process.returncode)) + answer = _ask("Do you want to re-run the flavour, skip the flavour or abort the installation?", [ "run", "skip", "abort"]) + if answer == "run": + # doesn't matter, run is already 'True' + continue + elif answer == "skip": + run = False + elif answer == "abort": + quit() + else: + run = False + else: + print("Uh. Found this non-flavour script in the 'flavours' folder: '%s' (Not executing)" % (flavour)) + + +def finish(termsize, settings): + _separator(termsize) + if _ask("Finished! \\o/ reboot now?", [ "yes", "no" ]) == "yes": + os.system("reboot") + + +def _separator(termsize): + print("~" * termsize["cols"]) + + +def _ask(question, choices): + while True: + print("=> %s (%s) " % (question, ", ".join(choices))) + answer = sys.stdin.readline()[:-1] + if answer in choices: + return answer + + +def main(): + rows, columns = os.popen('stty size', 'r').read().split() + termsize = { + "rows": int(rows), + "cols": int(columns) + } + settings = {} + + motd(termsize) + efibios(termsize, settings) + blockdevice(termsize, settings) + checks(termsize, settings) + flavours(termsize, settings) + finish(termsize, settings) + + +if __name__ == '__main__': + main() \ No newline at end of file