MohammedAlakhras commited on
Commit
70c3898
·
verified ·
1 Parent(s): 8fe91d1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -17
app.py CHANGED
@@ -1,31 +1,31 @@
1
  import os
2
  import subprocess
3
- import threading
4
  import logging
 
5
 
 
6
  logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s', handlers=[logging.StreamHandler()])
7
 
8
  def setup_chrome_remote_desktop():
9
  logging.info("Starting Chrome Remote Desktop setup...")
10
-
11
- # Ensure correct permissions for the config folder
12
- os.makedirs("/home/rdpuser/.config/chrome-remote-desktop", exist_ok=True)
13
- os.chown("/home/rdpuser/.config/chrome-remote-desktop", 1000, 1000) # Adjust UID and GID if necessary
14
-
15
- # Start Chrome Remote Desktop
16
- subprocess.run([
17
- "/opt/google/chrome-remote-desktop/start-host",
18
- "--code=4/0AQlEd8xVNwYHYLwfMRO4H1o2wI9GNKKtg6zhrrW4cYJlBty0yXgGGGp__Ljm9CMpihnvtg", # Replace with fresh auth code
19
- "--redirect-url=https://remotedesktop.google.com/_/oauthredirect",
20
- "--name=MyRemoteDesktop",
21
- "--pin=123456" # PIN for accessing remote desktop
22
- ])
23
-
24
  logging.info("Chrome Remote Desktop setup complete.")
25
 
 
26
  crd_thread = threading.Thread(target=setup_chrome_remote_desktop)
27
  crd_thread.start()
28
 
 
29
  subprocess.run(["tail", "-f", "/dev/null"])
30
-
31
-
 
1
  import os
2
  import subprocess
 
3
  import logging
4
+ import threading
5
 
6
+ # Set up logging
7
  logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s', handlers=[logging.StreamHandler()])
8
 
9
  def setup_chrome_remote_desktop():
10
  logging.info("Starting Chrome Remote Desktop setup...")
11
+
12
+ # Execute the command with the DISPLAY environment variable set
13
+ command = [
14
+ "bash", "-c",
15
+ 'DISPLAY= /opt/google/chrome-remote-desktop/start-host --code="4/0AQlEd8zDHL-M_KotFr2ZooKjDqxs274Zl39q3Ht4J-OSBslWOukrjmKPfXixk99q4Tg9Xw" '
16
+ '--redirect-url="https://remotedesktop.google.com/_/oauthredirect" '
17
+ '--name=$(hostname) '
18
+ '--pin=123456'
19
+ ]
20
+
21
+ # Run the command
22
+ subprocess.run(command, shell=False)
23
+
 
24
  logging.info("Chrome Remote Desktop setup complete.")
25
 
26
+ # Run the Chrome Remote Desktop setup in a separate thread
27
  crd_thread = threading.Thread(target=setup_chrome_remote_desktop)
28
  crd_thread.start()
29
 
30
+ # Keep the container running
31
  subprocess.run(["tail", "-f", "/dev/null"])