Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/user_interaction.py
diff options
context:
space:
mode:
Diffstat (limited to 'archinstall/lib/user_interaction.py')
-rw-r--r--archinstall/lib/user_interaction.py71
1 files changed, 71 insertions, 0 deletions
diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py
index f92cd008..440e41a1 100644
--- a/archinstall/lib/user_interaction.py
+++ b/archinstall/lib/user_interaction.py
@@ -14,6 +14,77 @@ def get_password(prompt="Enter a password: "):
log(' * Passwords did not match * ', bg='black', fg='red')
continue
return passwd
+ return None
+
+def ask_for_superuser_account(prompt='Create a required super-user with sudo privileges: ', forced=False):
+ while 1:
+ new_user = input(prompt).strip(' ')
+
+ if not new_user and forced:
+ # TODO: make this text more generic?
+ # It's only used to create the first sudo user when root is disabled in guided.py
+ log(' * Since root is disabled, you need to create a least one (super) user!', bg='black', fg='red')
+ continue
+ elif not new_user and not forced:
+ raise UserError("No superuser was created.")
+
+ password = get_password(prompt=f'Password for user {new_user}: ')
+ return {new_user: password}
+
+def ask_for_additional_users(prompt='Any additional users to install (leave blank for no users): '):
+ users = {}
+ super_users = {}
+
+ while 1:
+ new_user = input(prompt).strip(' ')
+ if not new_user:
+ break
+ password = get_password(prompt=f'Password for user {new_user}: ')
+
+ if input("Should this user be a sudo (super) user (y/N): ").strip(' ').lower() in ('y', 'yes'):
+ super_users[new_user] = password
+ else:
+ users[new_user] = password
+
+ return users, super_users
+
+def ask_to_configure_network():
+ # Optionally configure one network interface.
+ #while 1:
+ # {MAC: Ifname}
+ interfaces = {'ISO-CONFIG' : 'Copy ISO network configuration to installation', **archinstall.list_interfaces()}
+ archinstall.storage['_guided']['network'] = None
+
+ nic = archinstall.generic_select(interfaces.values(), "Select one network interface to configure (leave blank to skip): ")
+ if nic and nic != 'Copy ISO network configuration to installation':
+ mode = archinstall.generic_select(['DHCP (auto detect)', 'IP (static)'], f"Select which mode to configure for {nic}: ")
+ if mode == 'IP (static)':
+ while 1:
+ ip = input(f"Enter the IP and subnet for {nic} (example: 192.168.0.5/24): ").strip()
+ if ip:
+ break
+ else:
+ ArchInstall.log(
+ "You need to enter a valid IP in IP-config mode.",
+ level=archinstall.LOG_LEVELS.Warning,
+ bg='black',
+ fg='red'
+ )
+
+ if not len(gateway := input('Enter your gateway (router) IP address or leave blank for none: ').strip()):
+ gateway = None
+
+ dns = None
+ if len(dns_input := input('Enter your DNS servers (space separated, blank for none): ').strip()):
+ dns = dns_input.split(' ')
+
+ return {'nic': nic, 'dhcp': False, 'ip': ip, 'gateway' : gateway, 'dns' : dns}
+ else:
+ return {'nic': nic}
+ elif nic:
+ return nic
+
+ return None
def generic_select(options, input_text="Select one of the above by index or absolute value: ", sort=True):
"""