Commit 24481786 authored by Alban Bruder's avatar Alban Bruder

Update reset-ws cmd

parent ba30c1a6
......@@ -16,7 +16,7 @@ UBUNTU_ISO = "https://releases.ubuntu.com/20.04/ubuntu-20.04.1-live-server-amd64
NOCLOUD_SOURCE = "https://git.webis.de/code-generic/code-kickstart-config/-/raw/master/ubuntu-20.04/"
GRUB_TEMPLATE = """#!/bin/sh
menuentry "Install Ubuntu 20.04" {{
menuentry "Install Ubuntu" {{
search --no-floppy --fs-uuid --set=root {uuid}
set isofile="/root/ubuntu.iso"
loopback loop $isofile
......@@ -120,9 +120,9 @@ def local(force, report, username, password, hostname, address, gateway, interfa
global UBUNTU_ISO
# ensure script has root permissions
""" if os.getuid() != 0:
if os.getuid() != 0:
logger.error("Command must run as root.")
return """
return
# try to extract the password
if not password:
......@@ -174,6 +174,7 @@ def local(force, report, username, password, hostname, address, gateway, interfa
logger.info("Downloading Ubuntu image. Please wait...")
subprocess.Popen(
"wget --output-document /root/ubuntu.iso {}".format(UBUNTU_ISO), shell=True).wait()
# TODO verify checksum
logger.info("Updating bootloader...")
uuid = get_uuid("/root")
......@@ -187,8 +188,12 @@ def local(force, report, username, password, hostname, address, gateway, interfa
"mac": mac
}
click.echo(GRUB_TEMPLATE.format(
nocloud=NOCLOUD_SOURCE, uuid=uuid, parameters=stringify_parameters(parameters)))
with open("/etc/grub.d/99_reset", "w") as file:
file.write(GRUB_TEMPLATE.format(
nocloud=NOCLOUD_SOURCE, uuid=uuid, parameters=stringify_parameters(parameters)))
subprocess.Popen(
"chmod +x /etc/grub.d/99_reset && update-grub && grub-reboot 'Install Ubuntu'", shell=True).wait()
@reset_ws.command(short_help='Reset a workstation remotly')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment