|
24 | 24 | @click.option('--reinstall', is_flag=True, default=False) |
25 | 25 | @logs.opts_init |
26 | 26 | def main(systemd_skip: bool, systemd_force: bool, reinstall: bool): |
| 27 | + log.info('Test user prep starting...') |
| 28 | + |
27 | 29 | coppy_user = User(username) |
28 | 30 |
|
29 | 31 | if reinstall and coppy_user.exists(): |
30 | 32 | result = utils.sudo_run('pkill', '-u', username, returns=(0, 1)) |
31 | 33 | if result.returncode == 0: |
| 34 | + log.info('Waiting on all coppy-tests processes to exit') |
32 | 35 | # Wait for user's processes to exit or userdel will fail |
33 | 36 | utils.sub_run('pidwait', '-u', username) |
34 | 37 | utils.sudo_run('userdel', '-r', username) |
35 | 38 |
|
36 | 39 | # Get rid of cache |
37 | 40 | coppy_user = User(username) |
38 | 41 |
|
| 42 | + log.info('Ensuring user exists...') |
39 | 43 | coppy_user.ensure() |
40 | 44 | coppy_user_home = coppy_user.home_dir() |
41 | 45 |
|
42 | 46 | if not coppy_user.is_current: |
| 47 | + log.info('Adjustments to give current user access to coppy-tests home') |
43 | 48 | curr_user = User.current() |
44 | | - # This would clear them all (i.e. fix a mistake if you have one) |
45 | | - utils.sub_run('sudo', 'setfacl', '-R', '-b', coppy_user_home) |
46 | | - # utils.sudo_run('setfacl', '-R', '-m', f'u:{curr_user.name}:rwX', coppy_user_home) |
47 | | - # utils.sudo_run('setfacl', '-R', '-d', '-m', f'u:{curr_user.name}:rwX', coppy_user_home) |
| 49 | + |
48 | 50 | if coppy_user.name not in curr_user.groups(): |
49 | 51 | log.info(f'Adding your user to the user group: {coppy_user.name}') |
50 | 52 | utils.sudo_run('usermod', '-aG', coppy_user.name, curr_user.name) |
51 | 53 | log.warning( |
52 | 54 | f'Please logout and then back in to enable access to the {coppy_user.name} group.', |
53 | 55 | ) |
| 56 | + return |
54 | 57 | else: |
55 | 58 | log.info(f'Your user is already in the group: {coppy_user.name}') |
56 | 59 |
|
57 | 60 | # Sticky group so files created by the dev's user can be accessed by coppy-tests user. |
58 | 61 | utils.sudo_run('chmod', 'g+ws', coppy_user_home) |
59 | 62 |
|
60 | | - # Needed for systemd files |
61 | 63 | config_dpath = coppy_user_home / '.config/' |
62 | 64 | config_dpath.mkdir(exist_ok=True) |
| 65 | + utils.sudo_run('chmod', '-R', 'g+ws', config_dpath) |
| 66 | + |
| 67 | + cache_dpath = coppy_user_home / '.cache/' |
| 68 | + cache_dpath.mkdir(exist_ok=True) |
| 69 | + utils.sudo_run('chmod', '-R', 'g+ws', cache_dpath) |
63 | 70 |
|
| 71 | + log.info('Updating sudoers for passwordless access to coppy test user') |
64 | 72 | sudoers_write('coppy', sudoers.format(coppy_user=username)) |
65 | 73 |
|
66 | 74 | # Mise & uv |
|
0 commit comments