system setup: auto reconf mode general completion
Mostly complete the second task except the API for GUI: Implement an API in the server to know if we are in reconfigure or setup mode based on existing UID user >= 1000. Fetch that API from the client and set the variant to wsl_setup or wsl_configuration.
This commit is contained in:
parent
ac8052b97c
commit
78221ebf25
5
Makefile
5
Makefile
|
@ -8,7 +8,6 @@ PROBERTDIR=./probert
|
|||
PROBERT_REPO=https://github.com/canonical/probert
|
||||
DRYRUN?=--dry-run --bootloader uefi --machine-config examples/simple.json
|
||||
SYSTEM_SETUP_DRYRUN?=--dry-run
|
||||
RECONFIG?=--reconfigure
|
||||
export PYTHONPATH
|
||||
CWD := $(shell pwd)
|
||||
|
||||
|
@ -57,10 +56,10 @@ dryrun-system-setup-server:
|
|||
$(PYTHON) -m system_setup.cmd.server $(SYSTEM_SETUP_DRYRUN)
|
||||
|
||||
dryrun-system-setup-recon:
|
||||
$(PYTHON) -m system_setup.cmd.tui $(SYSTEM_SETUP_DRYRUN) $(RECONFIG)
|
||||
DRYRUN_RECONFIG=true $(PYTHON) -m system_setup.cmd.tui $(SYSTEM_SETUP_DRYRUN)
|
||||
|
||||
dryrun-system-setup-server-recon:
|
||||
$(PYTHON) -m system_setup.cmd.server $(SYSTEM_SETUP_DRYRUN) $(RECONFIG)
|
||||
DRYRUN_RECONFIG=true $(PYTHON) -m system_setup.cmd.server $(SYSTEM_SETUP_DRYRUN)
|
||||
|
||||
lint: flake8
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
import logging
|
||||
import sys
|
||||
from system_setup.common.helpers import is_reconfigure
|
||||
|
||||
from subiquity.client.client import SubiquityClient
|
||||
|
||||
|
@ -40,15 +41,12 @@ class SystemSetupClient(SubiquityClient):
|
|||
|
||||
def __init__(self, opts):
|
||||
# TODO WSL:
|
||||
# 1. remove reconfigure flag
|
||||
# 2. decide on which UI to show up based on existing user UID >=1000
|
||||
# (or default user set in wsl.conf?)
|
||||
# 3. provide an API for this for the flutter UI to know about it
|
||||
# 4. Add Configuration Base page before Advanced
|
||||
# 5. Add language page
|
||||
# self.variant = "wsl_configuration"
|
||||
if opts.reconfigure:
|
||||
|
||||
if is_reconfigure(opts.dry_run):
|
||||
self.variant = "wsl_configuration"
|
||||
self.controllers = [
|
||||
"Welcome",
|
||||
"WSLConfigurationBase",
|
||||
"WSLConfigurationAdvanced",
|
||||
"Summary",
|
||||
|
|
|
@ -72,10 +72,6 @@ def make_client_args_parser():
|
|||
help='Synthesize a click on a button matching PAT')
|
||||
parser.add_argument('--answers')
|
||||
parser.add_argument('--server-pid')
|
||||
# TODO WSL: remove reconfigure flag and use dynamic decision (see below)
|
||||
# Expose that as an endpoint on the server and decide in the client what
|
||||
# to show
|
||||
parser.add_argument('--reconfigure', action='store_true')
|
||||
return parser
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
#!/usr/bin/env python3
|
||||
# Copyright 2015-2021 Canonical, Ltd.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
|
||||
|
||||
def is_reconfigure(is_dryrun):
|
||||
is_dryrun_reconfigure = is_dryrun and \
|
||||
os.getenv("DRYRUN_RECONFIG") == "true"
|
||||
count = 0
|
||||
with open('/etc/passwd', 'r') as f:
|
||||
for line in f:
|
||||
# check every normal user except nobody (65534)
|
||||
if int(line.split(':')[2]) >= 1000 and \
|
||||
int(line.split(':')[2]) != 65534:
|
||||
count += 1
|
||||
is_none_dryrun_normaluser = not is_dryrun and count != 0
|
||||
return is_dryrun_reconfigure or is_none_dryrun_normaluser
|
Loading…
Reference in New Issue