Last active
August 29, 2015 14:21
-
-
Save thenewvu/86b6c1d110d6124608de to your computer and use it in GitHub Desktop.
An ultility python script helps me enter my chroot environment easier
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import argparse | |
def log(msg): | |
print('# {msg}'.format(msg=msg)) | |
def loghr(msg): | |
print(72 * '#') | |
log(msg) | |
def disable_display_access_control(): | |
loghr('disable display access control') | |
cmd = 'xhost +' | |
log(cmd) | |
subprocess.check_call(cmd, shell=True) | |
def enter_chroot_env(): | |
loghr('enter chroot environment') | |
cmd = 'sudo uck-remaster-chroot-rootfs /home/vu/work/devenv/doanything' | |
log(cmd) | |
subprocess.call(cmd, shell=True) | |
def mount(dirs): | |
if dirs is None: | |
return | |
dirs = dirs.split(',') | |
for dir in dirs: | |
loghr('mount {dir}'.format(dir=dir)) | |
cmd = 'sudo mkdir /home/vu/work/devenv/doanything/remaster-root/media/{dir}'.format(dir=dir) | |
log(cmd) | |
subprocess.call(cmd, shell=True) | |
cmd = 'sudo mount --bind /home/vu/work/{dir} /home/vu/work/devenv/doanything/remaster-root/media/{dir}'.format(dir=dir) | |
log(cmd) | |
subprocess.check_call(cmd, shell=True) | |
if __name__ == '__main__': | |
argparser = argparse.ArgumentParser() | |
argparser.add_argument('--mount', type=str, default=None, help='directories that will be mounted to chroot environment. ex: --mount=docs,tools') | |
args = argparser.parse_args() | |
mount(args.mount) | |
disable_display_access_control() | |
enter_chroot_env() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment