diff --git a/examples/autoinstall-system-setup-full.yaml b/examples/autoinstall-system-setup-full.yaml index 7256a515..d9a0baa0 100644 --- a/examples/autoinstall-system-setup-full.yaml +++ b/examples/autoinstall-system-setup-full.yaml @@ -25,4 +25,4 @@ wslconfadvanced: motd_wslnewsenabled: false automount_enabled: false automount_mountfstab: false -shutdown: 'reboot' \ No newline at end of file +shutdown: 'poweroff' \ No newline at end of file diff --git a/examples/autoinstall-system-setup-no-shutdown.yaml b/examples/autoinstall-system-setup-no-shutdown.yaml new file mode 100644 index 00000000..c8d9e92e --- /dev/null +++ b/examples/autoinstall-system-setup-no-shutdown.yaml @@ -0,0 +1,16 @@ +version: 1 +early-commands: + - echo a + - ["sleep", "1"] + - echo a +locale: en_US +identity: + realname: Ubuntu + username: ubuntu + # ubuntu + password: '$6$wdAcoXrU039hKYPd$508Qvbe7ObUnxoj15DRCkzC3qO7edjH0VV7BPNRDYK4QR8ofJaEEF2heacn0QgD.f8pO8SNp83XNdWG6tocBM1' +wslconfbase: + automount_root: '/custom_mnt_path' + automount_options: 'metadata' + network_generatehosts: false + network_generateresolvconf: false \ No newline at end of file diff --git a/scripts/runtests.sh b/scripts/runtests.sh index ae0c3d8b..3a25124f 100755 --- a/scripts/runtests.sh +++ b/scripts/runtests.sh @@ -29,7 +29,23 @@ validate () { elif [ "${mode}" = "system_setup" ]; then setup_mode="$2" echo "system setup validation for $setup_mode" + [ -d ".subiquity/run/subiquity/" ] || (echo "run/subiquity/ dir not created for status"; exit 1) + [ -e ".subiquity/run/subiquity/launcher-status" ] || (echo "run/subiquity/launcher-status not created"; exit 1) + expected_status="reboot" + if [ "${setup_mode}" = "autoinstall-full" ]; then + expected_status="shutdown" + elif [ "${setup_mode}" = "autoinstall-no-shutdown" ]; then + expected_status="complete" + fi + result_status="$(cat .subiquity/run/subiquity/launcher-status)" + if [ "${result_status}" != "${expected_status}" ]; then + echo "incorrect run/subiquity/launcher-status: expect ${expected_status}, got ${result_status}" + exit 1 + fi [ -d ".subiquity/etc/" ] || (echo "etc/ dir not created for config"; exit 1) + if [ "${setup_mode}" = "autoinstall-no-shutdown" ]; then + setup_mode="autoinstall" + fi [ -d "system_setup/tests/golden/${setup_mode}" ] || (echo "tests/golden not found in system_setup"; exit 1) for file in system_setup/tests/golden/${setup_mode}/*.conf; do filename=$(basename ${file}) @@ -121,13 +137,11 @@ grep -q 'finish: subiquity/Install/install/postinstall/run_unattended_upgrades: # The OOBE doesn't exist in WSL < 20.04 if [ "${RELEASE%.*}" -ge 20 ]; then - clean - timeout --foreground 60 sh -c "LANG=C.UTF-8 python3 -m system_setup.cmd.tui --autoinstall examples/autoinstall-system-setup.yaml --dry-run" - validate "system_setup" "autoinstall" - - clean - timeout --foreground 60 sh -c "LANG=C.UTF-8 python3 -m system_setup.cmd.tui --autoinstall examples/autoinstall-system-setup-full.yaml --dry-run" - validate "system_setup" "autoinstall-full" + for mode in "" "-full" "-no-shutdown"; do + clean + timeout --foreground 60 sh -c "LANG=C.UTF-8 python3 -m system_setup.cmd.tui --autoinstall examples/autoinstall-system-setup${mode}.yaml --dry-run" + validate "system_setup" "autoinstall${mode}" + done python3 -m system_setup.cmd.schema > "$testschema" scripts/schema-cmp.py "autoinstall-system-setup-schema.json" "$testschema" --ignore-tz diff --git a/system_setup/server/controllers/shutdown.py b/system_setup/server/controllers/shutdown.py index dafb7f68..a9966ef0 100644 --- a/system_setup/server/controllers/shutdown.py +++ b/system_setup/server/controllers/shutdown.py @@ -13,6 +13,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +import enum import os import logging @@ -23,6 +24,10 @@ from subiquity.server.controllers import ShutdownController log = logging.getLogger("system_setup.server.controllers.restart") +class WSLShutdownMode(enum.Enum): + COMPLETE = -1 + + class SetupShutdownController(ShutdownController): def __init__(self, app): @@ -31,6 +36,7 @@ class SetupShutdownController(ShutdownController): super().__init__(app) self.root_dir = app.base_model.root self.app.controllers.Install = self.app.controllers.Configure + self.mode = WSLShutdownMode.COMPLETE # allow the complete mode def start(self): self.app.aio_loop.create_task(self._wait_install())