Starting to move individual steps into functions instead, so that they can be called externally as a library instead. Useful for graphical frontends and what not
This commit is contained in:
parent
392cdbc815
commit
47fdf30fe1
|
|
@ -11,10 +11,13 @@ from time import sleep, time
|
||||||
from random import choice
|
from random import choice
|
||||||
from string import ascii_uppercase, ascii_lowercase, digits
|
from string import ascii_uppercase, ascii_lowercase, digits
|
||||||
|
|
||||||
|
if not os.path.isdir('/sys/firmware/efi'):
|
||||||
|
print('[E] This script only supports UEFI-booted machines.')
|
||||||
|
exit(1)
|
||||||
|
|
||||||
## == Profiles Path can be set via --profiles-path=/path
|
## == Profiles Path can be set via --profiles-path=/path
|
||||||
## This just sets the default path if the parameter is omitted.
|
## This just sets the default path if the parameter is omitted.
|
||||||
profiles_path = 'https://raw.githubusercontent.com/Torxed/archinstall/master/deployments'
|
profiles_path = 'https://raw.githubusercontent.com/Torxed/archinstall/master/deployments'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import psutil
|
import psutil
|
||||||
except:
|
except:
|
||||||
|
|
@ -495,14 +498,7 @@ def merge_dicts(d1, d2, before=True, overwrite=False):
|
||||||
def random_string(l):
|
def random_string(l):
|
||||||
return ''.join(choice(ascii_uppercase + ascii_lowercase + digits) for i in range(l))
|
return ''.join(choice(ascii_uppercase + ascii_lowercase + digits) for i in range(l))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
def setup_args_defaults(args):
|
||||||
update_git() # Breaks and restarts the script if an update was found.
|
|
||||||
update_drive_list()
|
|
||||||
if not os.path.isdir('/sys/firmware/efi'):
|
|
||||||
print('[E] This script only supports UEFI-booted machines.')
|
|
||||||
exit(1)
|
|
||||||
|
|
||||||
## Setup some defaults (in case no command-line parameters or netdeploy-params were given)
|
|
||||||
if not 'size' in args: args['size'] = '100%'
|
if not 'size' in args: args['size'] = '100%'
|
||||||
if not 'start' in args: args['start'] = '513MiB'
|
if not 'start' in args: args['start'] = '513MiB'
|
||||||
if not 'pwfile' in args: args['pwfile'] = '/tmp/diskpw'
|
if not 'pwfile' in args: args['pwfile'] = '/tmp/diskpw'
|
||||||
|
|
@ -542,9 +538,9 @@ if __name__ == '__main__':
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
args['drive'] = drive
|
args['drive'] = drive
|
||||||
|
return args
|
||||||
|
|
||||||
## == If we got networking,
|
def load_instruction_set():
|
||||||
# Try fetching instructions for this box and execute them.
|
|
||||||
instructions = {}
|
instructions = {}
|
||||||
if get_default_gateway_linux():
|
if get_default_gateway_linux():
|
||||||
locmac = get_local_MACs()
|
locmac = get_local_MACs()
|
||||||
|
|
@ -572,6 +568,20 @@ if __name__ == '__main__':
|
||||||
else:
|
else:
|
||||||
print('[N] No gateway - No net deploy')
|
print('[N] No gateway - No net deploy')
|
||||||
|
|
||||||
|
return instructions
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
update_git() # Breaks and restarts the script if an update was found.
|
||||||
|
update_drive_list()
|
||||||
|
|
||||||
|
## Setup some defaults
|
||||||
|
# (in case no command-line parameters or netdeploy-params were given)
|
||||||
|
args = setup_args_defaults(args)
|
||||||
|
|
||||||
|
## == If we got networking,
|
||||||
|
# Try fetching instructions for this box and execute them.
|
||||||
|
instructions = load_instruction_set()
|
||||||
|
|
||||||
if args['profile'] and not args['default']:
|
if args['profile'] and not args['default']:
|
||||||
instructions = get_instructions(args['profile'])
|
instructions = get_instructions(args['profile'])
|
||||||
if len(instructions) <= 0:
|
if len(instructions) <= 0:
|
||||||
|
|
@ -642,8 +652,6 @@ if __name__ == '__main__':
|
||||||
# with open(args['pwfile'], 'r') as pw:
|
# with open(args['pwfile'], 'r') as pw:
|
||||||
# PIN = pw.read().strip()
|
# PIN = pw.read().strip()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
print()
|
print()
|
||||||
print('[!] Disk PASSWORD is: {}'.format(args['password']))
|
print('[!] Disk PASSWORD is: {}'.format(args['password']))
|
||||||
print()
|
print()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue