|
|
|
|
|
|
|
|
|
|
|
Pin = 123456 |
|
|
|
|
|
|
|
|
Autostart = False |
|
|
|
|
|
|
|
|
class CRD: |
|
|
def __init__(self, user): |
|
|
os.system("apt update") |
|
|
self.installCRD() |
|
|
self.installDesktopEnvironment() |
|
|
self.installGoogleChorme() |
|
|
self.finish(user) |
|
|
print("\nRDP created succesfully move to https://remotedesktop.google.com/access") |
|
|
|
|
|
@staticmethod |
|
|
def installCRD(): |
|
|
print("Installing Chrome Remote Desktop") |
|
|
subprocess.run(['wget', 'https://dl.google.com/linux/direct/chrome-remote-desktop_current_amd64.deb'], stdout=subprocess.PIPE) |
|
|
subprocess.run(['dpkg', '--install', 'chrome-remote-desktop_current_amd64.deb'], stdout=subprocess.PIPE) |
|
|
subprocess.run(['apt', 'install', '--assume-yes', '--fix-broken'], stdout=subprocess.PIPE) |
|
|
|
|
|
@staticmethod |
|
|
def installDesktopEnvironment(): |
|
|
print("Installing Desktop Environment") |
|
|
os.system("export DEBIAN_FRONTEND=noninteractive") |
|
|
os.system("apt install --assume-yes xfce4 desktop-base xfce4-terminal") |
|
|
os.system("bash -c 'echo \"exec /etc/X11/Xsession /usr/bin/xfce4-session\" > /etc/chrome-remote-desktop-session'") |
|
|
os.system("apt remove --assume-yes gnome-terminal") |
|
|
os.system("apt install --assume-yes xscreensaver") |
|
|
os.system("systemctl disable lightdm.service") |
|
|
|
|
|
@staticmethod |
|
|
def installGoogleChorme(): |
|
|
print("Installing Google Chrome") |
|
|
subprocess.run(["wget", "https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb"], stdout=subprocess.PIPE) |
|
|
subprocess.run(["dpkg", "--install", "google-chrome-stable_current_amd64.deb"], stdout=subprocess.PIPE) |
|
|
subprocess.run(['apt', 'install', '--assume-yes', '--fix-broken'], stdout=subprocess.PIPE) |
|
|
|
|
|
@staticmethod |
|
|
def finish(user): |
|
|
print("Finalizing") |
|
|
if Autostart: |
|
|
os.makedirs(f"/home/{user}/.config/autostart", exist_ok=True) |
|
|
link = "https://colab.research.google.com/github/PradyumnaKrishna/Colab-Hacks/blob/master/Colab%20RDP/Colab%20RDP.ipynb" |
|
|
colab_autostart = """[Desktop Entry] |
|
|
Type=Application |
|
|
Name=Colab |
|
|
Exec=sh -c "sensible-browser {}" |
|
|
Icon= |
|
|
Comment=Open a predefined notebook at session signin. |
|
|
X-GNOME-Autostart-enabled=true""".format(link) |
|
|
with open(f"/home/{user}/.config/autostart/colab.desktop", "w") as f: |
|
|
f.write(colab_autostart) |
|
|
os.system(f"chmod +x /home/{user}/.config/autostart/colab.desktop") |
|
|
os.system(f"chown {user}:{user} /home/{user}/.config") |
|
|
|
|
|
os.system(f"adduser {user} chrome-remote-desktop") |
|
|
command = f"{TRP} --pin={Pin}" |
|
|
os.system(f"su - {user} -c '{command}'") |
|
|
os.system("service chrome-remote-desktop start") |
|
|
|
|
|
|
|
|
print("Finished Succesfully") |
|
|
|
|
|
|
|
|
try: |
|
|
if TRP == "": |
|
|
print("Please enter authcode from the given link") |
|
|
elif len(str(Pin)) < 6: |
|
|
print("Enter a pin more or equal to 6 digits") |
|
|
else: |
|
|
CRD(username) |
|
|
except NameError as e: |
|
|
print("'username' variable not found, Create a user first") |