-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget_root_username
55 lines (38 loc) · 1.73 KB
/
get_root_username
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# This module avoid problems detecting mounted partitions or new user at target system
import libcalamares
import subprocess
from libcalamares.utils import check_target_env_call, target_env_call
from libcalamares.utils import *
def run():
""" Get root and username directly from calamares.
:return:
"""
##### WORKS
try:
with open('/tmp/chrootpath.txt', 'w') as file:
root_mount_point = libcalamares.globalstorage.value("rootMountPoint")
file.write(root_mount_point)
file.close()
except:
pass # doing nothing on exception
try:
with open('/tmp/new_username.txt', 'w') as file:
_username = libcalamares.globalstorage.value("username")
file.write(_username)
file.close()
except:
pass # doing nothing on exception
# Simpler to copy to new root?
RSYNC_CMD = "rsync -vaRI"
subprocess.call(RSYNC_CMD.split(' ') + ["/tmp/chrootpath.txt"] + [root_mount_point])
subprocess.call(RSYNC_CMD.split(' ') + ["/tmp/new_username.txt"] + [root_mount_point])
# Needs testing
#_ROOT_PATH_CHROOT_CLEANER_SCRIPT = "sed -i "2i $(cat /tmp/chrootpath.txt)" /usr/bin/chrooted_cleaner_script.sh"
#_ROOT_PATH_CLEANER_SCRIPT = "sed -i "2i $(cat /tmp/chrootpath.txt)" /usr/bin/cleaner_script.sh"
#_USER_CHROOT_CLEANER_SCRIPT = "sed -i "3i $(cat /tmp/new_username.txt)" /usr/bin/chrooted_cleaner_script.sh"
#_USER_CLEANER_SCRIPT = "sed -i "3i $(cat /tmp/new_username.txt)" /usr/bin/cleaner_script.sh"
#subprocess.call([_ROOT_PATH_CHROOT_CLEANER_SCRIPT, '&&', _ROOT_PATH_CLEANER_SCRIPT], shell=True)
#subprocess.call([_USER_CHROOT_CLEANER_SCRIPT, '&&', _USER_CLEANER_SCRIPT], shell=True)
return None