-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigureGuestTerminal.py
35 lines (22 loc) · 1.05 KB
/
configureGuestTerminal.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import subprocess
import sys
import os
# configure a desktop entry file that launches a host system terminal and launches a guest
# the guest terminal will dispay a welcome message for the users
# runs script to get host
# runs scripts to prompt user for password and copy files to restricted location
# most code was implemented in shell scripts as getting sudo priviledges was easier
from sudo import run_as_sudo
def configureTerminal (guest):
hostTerminal = subprocess.Popen(['sh ShellScripts/Host-Terminal'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True).communicate()[0].decode('utf-8').strip()
# string the desktop file is built on was moved to shell scripts to avoid passing a python to sh
# (predictably painfull) especially didn't help that .desktop files requires line breaks
# line breaks require carefull consideration in shell scripts
subprocess.Popen([f'sh ShellScripts/createDesktopGuestTerminal.sh {guest} {hostTerminal}'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True)
configureTerminal(sys.argv[1])