Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDaniel Girtler <blackrabbit256@gmail.com>2022-05-27 05:48:29 +1000
committerGitHub <noreply@github.com>2022-05-26 21:48:29 +0200
commit870da403e79ab50350803b45f200e0b272334989 (patch)
tree9b203a054bd10cbc73a81b4fd5fe24ef8e6f141a /examples
parent353c05318ce80b8eec32031c9e14b8471b458548 (diff)
Rework user management (#1220)
* Rework users * Update user installation * Fix config serialization * Update * Update schemas and documentation * Update * Fix flake8 * Make users mypy compatible * Fix minor copy Co-authored-by: Daniel Girtler <girtler.daniel@gmail.com> Co-authored-by: Anton Hvornum <anton@hvornum.se>
Diffstat (limited to 'examples')
-rw-r--r--examples/creds-sample.json20
-rw-r--r--examples/guided.py10
-rw-r--r--examples/minimal.py6
-rw-r--r--examples/swiss.py19
4 files changed, 28 insertions, 27 deletions
diff --git a/examples/creds-sample.json b/examples/creds-sample.json
index 16aeb8cc..0681e16f 100644
--- a/examples/creds-sample.json
+++ b/examples/creds-sample.json
@@ -1,9 +1,15 @@
{
"!root-password": "<root password>",
- "!users": {
- "username": {"!password": "<user password>"}
- },
- "!superusers": {
- "admin": {"!password": "<admin password>"}
- }
-} \ No newline at end of file
+ "!users": [
+ {
+ "username": "<USERNAME>",
+ "!password": "<PASSWORD>",
+ "sudo": false
+ },
+ {
+ "username": "<SUDO_USERNAME>",
+ "!password": "<PASSWORD>",
+ "sudo": true
+ }
+ ]
+}
diff --git a/examples/guided.py b/examples/guided.py
index 3b762a8b..19b0d638 100644
--- a/examples/guided.py
+++ b/examples/guided.py
@@ -72,7 +72,6 @@ def ask_user_questions():
# Ask for a root password (optional, but triggers requirement for super-user if skipped)
global_menu.enable('!root-password')
- global_menu.enable('!superusers')
global_menu.enable('!users')
# Ask for archinstall-specific profiles (such as desktop environments etc)
@@ -220,13 +219,8 @@ def perform_installation(mountpoint):
if archinstall.arguments.get('profile', None):
installation.install_profile(archinstall.arguments.get('profile', None))
- if archinstall.arguments.get('!users',{}):
- for user, user_info in archinstall.arguments.get('!users', {}).items():
- installation.user_create(user, user_info["!password"], sudo=False)
-
- if archinstall.arguments.get('!superusers',{}):
- for superuser, user_info in archinstall.arguments.get('!superusers', {}).items():
- installation.user_create(superuser, user_info["!password"], sudo=True)
+ if users := archinstall.arguments.get('!users', None):
+ installation.create_users(users)
if timezone := archinstall.arguments.get('timezone', None):
installation.set_timezone(timezone)
diff --git a/examples/minimal.py b/examples/minimal.py
index d80c4045..8b4c847f 100644
--- a/examples/minimal.py
+++ b/examples/minimal.py
@@ -1,6 +1,8 @@
import archinstall
# Select a harddrive and a disk password
+from archinstall import User
+
archinstall.log("Minimal only supports:")
archinstall.log(" * Being installed to a single disk")
@@ -28,8 +30,8 @@ def install_on(mountpoint):
installation.add_additional_packages(['nano', 'wget', 'git'])
installation.install_profile('minimal')
- installation.user_create('devel', 'devel')
- installation.user_set_pw('root', 'airoot')
+ user = User('devel', 'devel', False)
+ installation.create_users(user)
# Once this is done, we output some useful information to the user
# And the installation is complete.
diff --git a/examples/swiss.py b/examples/swiss.py
index 2f7d90c4..d0f02dc1 100644
--- a/examples/swiss.py
+++ b/examples/swiss.py
@@ -219,7 +219,7 @@ class MyMenu(archinstall.GlobalMenu):
if self._execution_mode in ('full','lineal'):
options_list = ['keyboard-layout', 'mirror-region', 'harddrives', 'disk_layouts',
'!encryption-password','swap', 'bootloader', 'hostname', '!root-password',
- '!superusers', '!users', 'profile', 'audio', 'kernels', 'packages','additional-repositories','nic',
+ '!users', 'profile', 'audio', 'kernels', 'packages','additional-repositories','nic',
'timezone', 'ntp']
if archinstall.arguments.get('advanced',False):
options_list.extend(['sys-language','sys-encoding'])
@@ -229,7 +229,7 @@ class MyMenu(archinstall.GlobalMenu):
mandatory_list = ['harddrives']
elif self._execution_mode == 'only_os':
options_list = ['keyboard-layout', 'mirror-region','bootloader', 'hostname',
- '!root-password', '!superusers', '!users', 'profile', 'audio', 'kernels',
+ '!root-password', '!users', 'profile', 'audio', 'kernels',
'packages', 'additional-repositories', 'nic', 'timezone', 'ntp']
mandatory_list = ['hostname']
if archinstall.arguments.get('advanced',False):
@@ -262,8 +262,12 @@ class MyMenu(archinstall.GlobalMenu):
def check(s):
return self.option(s).has_selection()
+ def has_superuser() -> bool:
+ users = self._menu_options['!users'].current_selection
+ return any([u.sudo for u in users])
+
_, missing = self.mandatory_overview()
- if mode in ('full','only_os') and (not check('!root-password') and not check('!superusers')):
+ if mode in ('full','only_os') and (not check('!root-password') and not has_superuser()):
missing += 1
if mode in ('full', 'only_hd') and check('harddrives'):
if not self.option('harddrives').is_empty() and not check('disk_layouts'):
@@ -420,13 +424,8 @@ def os_setup(installation):
if archinstall.arguments.get('profile', None):
installation.install_profile(archinstall.arguments.get('profile', None))
- if archinstall.arguments.get('!users',{}):
- for user, user_info in archinstall.arguments.get('!users', {}).items():
- installation.user_create(user, user_info["!password"], sudo=False)
-
- if archinstall.arguments.get('!superusers',{}):
- for superuser, user_info in archinstall.arguments.get('!superusers', {}).items():
- installation.user_create(superuser, user_info["!password"], sudo=True)
+ if users := archinstall.arguments.get('!users', None):
+ installation.create_users(users)
if timezone := archinstall.arguments.get('timezone', None):
installation.set_timezone(timezone)