Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
code-generic
code-webis-cmd
Commits
24481786
Commit
24481786
authored
Nov 02, 2020
by
Alban Bruder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update reset-ws cmd
parent
ba30c1a6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
5 deletions
+10
-5
tools/util/reset_ws.py
tools/util/reset_ws.py
+10
-5
No files found.
tools/util/reset_ws.py
View file @
24481786
...
...
@@ -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'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment