Compare commits
	
		
			15 Commits
		
	
	
		
			master
			...
			python-cor
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 858ca5d3ab | ||
|  | d40c5deb44 | ||
|  | 3c8664b1f5 | ||
|  | 54530ac202 | ||
|  | d872a99180 | ||
|  | 408f2aa873 | ||
|  | 28dab7b58b | ||
|  | 226ad45325 | ||
|  | 5a3b4914a0 | ||
|  | 8d27e18464 | ||
|  | 9cd968b4bd | ||
|  | 6f3bdc8008 | ||
|  | b0f3d0de65 | ||
|  | b0c9ab111c | ||
|  | b72d05f329 | 
							
								
								
									
										90
									
								
								install.sh
									
									
									
									
									
								
							
							
						
						
									
										90
									
								
								install.sh
									
									
									
									
									
								
							| @ -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 |  | ||||||
							
								
								
									
										132
									
								
								run.py
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										132
									
								
								run.py
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,132 @@ | |||||||
|  | #!/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, settings): | ||||||
|  | 	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" ]) | ||||||
|  | 	_separator(termsize) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 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["blockdevice"] = _ask("Install where?", os.listdir("/sys/block/"), enforce=False) | ||||||
|  | 	_separator(termsize) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | def cryptroot(termsize, settings): | ||||||
|  | 	print("Do you want to encrypt your root partition?") | ||||||
|  | 	print("Please note that there is no way to recover your data if you forget your password.") | ||||||
|  | 	settings["cryptroot"] = _ask("Encrypt root?", [ "yes", "no" ]) | ||||||
|  | 	_separator(termsize) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | def rundir(termsize, settings, directory, validation_suffix, subfile="", ask=False): | ||||||
|  | 	for filename in sorted(os.listdir(directory)): | ||||||
|  | 		if filename[-len(validation_suffix):] == validation_suffix: | ||||||
|  | 			# Run loop | ||||||
|  | 			run = True | ||||||
|  | 			while run: | ||||||
|  | 				if ask and _ask("Do you want to run %s?" % (filename), [ "yes", "no" ]) == "no": | ||||||
|  | 					run = False | ||||||
|  | 					continue | ||||||
|  | 
 | ||||||
|  | 				_separator(termsize) | ||||||
|  | 				print("Running '%s'" % (filename)) | ||||||
|  | 
 | ||||||
|  | 				if subfile: | ||||||
|  | 					executable = os.path.join(directory, filename, subfile) | ||||||
|  | 				else: | ||||||
|  | 					executable = os.path.join(directory, filename) | ||||||
|  | 
 | ||||||
|  | 				with subprocess.Popen([executable], env=settings) as process: | ||||||
|  | 					# Wait for process termination | ||||||
|  | 					process.wait() | ||||||
|  | 					if process.returncode > 0: | ||||||
|  | 						# Woops, check failed somehow | ||||||
|  | 						print("Executable %s returned non-null error code %i." % (executable, process.returncode)) | ||||||
|  | 						answer = _ask("Do you want to re-run the executable, 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 executable: '%s' (Not executing)" % (filename)) | ||||||
|  | 
 | ||||||
|  | 	_separator(termsize) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 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, enforce=True): | ||||||
|  | 	while True: | ||||||
|  | 		print("=> %s (%s) " % (question, ", ".join(choices))) | ||||||
|  | 		answer = sys.stdin.readline()[:-1] | ||||||
|  | 		if answer in choices or not enforce: | ||||||
|  | 			return answer | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | def main(): | ||||||
|  | 	rows, columns = os.popen('stty size', 'r').read().split() | ||||||
|  | 	termsize = { | ||||||
|  | 		"rows": int(rows), | ||||||
|  | 		"cols": int(columns) | ||||||
|  | 	} | ||||||
|  | 	settings = {} | ||||||
|  | 
 | ||||||
|  | 	motd(termsize, settings) | ||||||
|  | 	efibios(termsize, settings) | ||||||
|  | 	blockdevice(termsize, settings) | ||||||
|  | 	cryptroot(termsize, settings) | ||||||
|  | 	rundir(termsize, settings, "checks", ".check") | ||||||
|  | 	rundir(termsize, settings, "steps", ".step") | ||||||
|  | 	rundir(termsize, settings, "flavours", ".flavour", "install.sh", ask=True) | ||||||
|  | 	finish(termsize, settings) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | if __name__ == '__main__': | ||||||
|  | 	main() | ||||||
|  | 
 | ||||||
| @ -18,3 +18,4 @@ else | |||||||
| 		amf_return=1 | 		amf_return=1 | ||||||
| 	fi | 	fi | ||||||
| fi | fi | ||||||
|  | return $amf_return | ||||||
|  | |||||||
| @ -13,3 +13,4 @@ else | |||||||
| 	echo "~> Failed. :(" | 	echo "~> Failed. :(" | ||||||
| 	amf_return=1 | 	amf_return=1 | ||||||
| fi | fi | ||||||
|  | return $amf_return | ||||||
|  | |||||||
| @ -6,11 +6,7 @@ mkfs.fat -F32 ${blockdevice}1 | |||||||
| echo -n "~> Do you want to encrypt root? (Y/n) " | echo -n "~> Do you want to encrypt root? (Y/n) " | ||||||
| read answer | read answer | ||||||
| 
 | 
 | ||||||
| if [ "$answer" == "n" ] || [ "$answer" == "N" ]; then | if [ "$cryptroot" == "yes" ]; then | ||||||
| 	echo "~> There are close to no reasons to not do this, but hey, you're an adult." |  | ||||||
| 	rootformat=${blockdevice}2 |  | ||||||
| 	didCrypt=0 |  | ||||||
| else |  | ||||||
| 	echo "~> Formatting root (/) for crypto" | 	echo "~> Formatting root (/) for crypto" | ||||||
| 	cryptsetup -v luksFormat ${blockdevice}2 | 	cryptsetup -v luksFormat ${blockdevice}2 | ||||||
| 	echo "~> Here's the header crypto:" | 	echo "~> Here's the header crypto:" | ||||||
| @ -18,7 +14,9 @@ else | |||||||
| 	echo "~> Open the crypt container" | 	echo "~> Open the crypt container" | ||||||
| 	cryptsetup luksOpen ${blockdevice}2 cryptroot | 	cryptsetup luksOpen ${blockdevice}2 cryptroot | ||||||
| 	rootformat=/dev/mapper/cryptroot | 	rootformat=/dev/mapper/cryptroot | ||||||
| 	didCrypt=1 | else | ||||||
|  | 	echo "~> There are close to no reasons to not do this, but hey, you're an adult." | ||||||
|  | 	rootformat=${blockdevice}2 | ||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
| echo "~> Formatting $rootformat EXT4" | echo "~> Formatting $rootformat EXT4" | ||||||
| @ -30,3 +28,4 @@ mkdir -p /mnt/boot | |||||||
| mount ${blockdevice}1 /mnt/boot | mount ${blockdevice}1 /mnt/boot | ||||||
| 
 | 
 | ||||||
| amf_return=0 | amf_return=0 | ||||||
|  | return $amf_return | ||||||
|  | |||||||
| @ -4,3 +4,4 @@ echo "~> Installing 'base' group and 'grub', 'efibootmgr'" | |||||||
| pacstrap /mnt base grub efibootmgr | pacstrap /mnt base grub efibootmgr | ||||||
| 
 | 
 | ||||||
| amf_return=0 | amf_return=0 | ||||||
|  | return $amf_return | ||||||
|  | |||||||
| @ -18,7 +18,7 @@ read hostname | |||||||
| echo $hostname > /mnt/etc/hostname | echo $hostname > /mnt/etc/hostname | ||||||
| 
 | 
 | ||||||
| echo "~> Configuring 'grub' for $bootloader" | echo "~> Configuring 'grub' for $bootloader" | ||||||
| if [ "$bootloader" == "EFI" ]; then | if [ "$bootmethod" == "EFI" ]; then | ||||||
| 	arch-chroot /mnt grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=BOOT | 	arch-chroot /mnt grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=BOOT | ||||||
|     # thanks to Virtualbox, this step is necessary |     # thanks to Virtualbox, this step is necessary | ||||||
|     cp /mnt/boot/EFI/BOOT/{grubx64.efi,BOOTX64.EFI} |     cp /mnt/boot/EFI/BOOT/{grubx64.efi,BOOTX64.EFI} | ||||||
| @ -26,7 +26,7 @@ else | |||||||
| 	arch-chroot /mnt grub-install --target=i386-pc /dev/*da | 	arch-chroot /mnt grub-install --target=i386-pc /dev/*da | ||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
| if [ "$didCrypt" -eq 1 ]; then | if [ "$cryptroot" == "yes" ]; then | ||||||
| 	echo "GRUB_CMDLINE_LINUX='cryptdevice=UUID=`blkid -o value ${blockdevice}2 | head -n 1`:cryptroot'" > /mnt/etc/default/grub | 	echo "GRUB_CMDLINE_LINUX='cryptdevice=UUID=`blkid -o value ${blockdevice}2 | head -n 1`:cryptroot'" > /mnt/etc/default/grub | ||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
| @ -43,3 +43,4 @@ echo "~> Patching pacman.conf for some pacman magic." | |||||||
| arch-chroot /mnt sed -i "s/\[options\]/\[options\]\nILoveCandy/g" /etc/pacman.conf | arch-chroot /mnt sed -i "s/\[options\]/\[options\]\nILoveCandy/g" /etc/pacman.conf | ||||||
| 
 | 
 | ||||||
| amf_return=0 | amf_return=0 | ||||||
|  | return $amf_return | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user