linux-desktop-manager 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- linux_desktop_manager-1.0.0/LICENSE +21 -0
- linux_desktop_manager-1.0.0/PKG-INFO +182 -0
- linux_desktop_manager-1.0.0/README.md +150 -0
- linux_desktop_manager-1.0.0/pyproject.toml +61 -0
- linux_desktop_manager-1.0.0/setup.cfg +4 -0
- linux_desktop_manager-1.0.0/src/linux_desktop_manager/__init__.py +29 -0
- linux_desktop_manager-1.0.0/src/linux_desktop_manager/__main__.py +7 -0
- linux_desktop_manager-1.0.0/src/linux_desktop_manager/cli.py +216 -0
- linux_desktop_manager-1.0.0/src/linux_desktop_manager/desktop_env.py +420 -0
- linux_desktop_manager-1.0.0/src/linux_desktop_manager/firewall.py +78 -0
- linux_desktop_manager-1.0.0/src/linux_desktop_manager/formatting.py +184 -0
- linux_desktop_manager-1.0.0/src/linux_desktop_manager/interactive.py +693 -0
- linux_desktop_manager-1.0.0/src/linux_desktop_manager/remote_services.py +650 -0
- linux_desktop_manager-1.0.0/src/linux_desktop_manager/server_env.py +441 -0
- linux_desktop_manager-1.0.0/src/linux_desktop_manager/tunnels.py +266 -0
- linux_desktop_manager-1.0.0/src/linux_desktop_manager/users.py +105 -0
- linux_desktop_manager-1.0.0/src/linux_desktop_manager.egg-info/PKG-INFO +182 -0
- linux_desktop_manager-1.0.0/src/linux_desktop_manager.egg-info/SOURCES.txt +20 -0
- linux_desktop_manager-1.0.0/src/linux_desktop_manager.egg-info/dependency_links.txt +1 -0
- linux_desktop_manager-1.0.0/src/linux_desktop_manager.egg-info/entry_points.txt +3 -0
- linux_desktop_manager-1.0.0/src/linux_desktop_manager.egg-info/requires.txt +3 -0
- linux_desktop_manager-1.0.0/src/linux_desktop_manager.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Shashan Lumbhani
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: linux-desktop-manager
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: All-In-One Linux Desktop Environment & Remote Access Manager (XRDP, VNC, noVNC, X2Go, Tunnels) with Interactive Arrow-Key TUI & CLI
|
|
5
|
+
Author-email: Shashan Lumbhani <lumbhanishashan1510@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/soni-shashan/linux-desktop-manager
|
|
8
|
+
Project-URL: Repository, https://github.com/soni-shashan/linux-desktop-manager
|
|
9
|
+
Project-URL: Issues, https://github.com/soni-shashan/linux-desktop-manager/issues
|
|
10
|
+
Keywords: linux,desktop-environment,remote-desktop,xrdp,vnc,novnc,x2go,cloudflared,tunnelmate,tui,cli
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: System Administrators
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
23
|
+
Classifier: Topic :: System :: Systems Administration
|
|
24
|
+
Classifier: Topic :: Terminals
|
|
25
|
+
Requires-Python: >=3.9
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Requires-Dist: tunnelmate-cli>=1.1.8
|
|
29
|
+
Requires-Dist: rich>=13.0.0
|
|
30
|
+
Requires-Dist: questionary>=2.0.0
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
|
|
33
|
+
# โก Linux Desktop Manager (`linux-desktop-manager`)
|
|
34
|
+
|
|
35
|
+
> **All-In-One Linux Desktop Environment & Remote Access Orchestrator**
|
|
36
|
+
> *Interactive Arrow-Key TUI Menu, Full CLI Automation, 14 Desktops, 6 Remote Protocols, and Built-In TunnelMate Cloudflare Ingress.*
|
|
37
|
+
|
|
38
|
+
**Author:** [Shashan Lumbhani](mailto:lumbhanishashan1510@gmail.com)
|
|
39
|
+
**License:** [MIT](LICENSE)
|
|
40
|
+
**Supported Distros:** Ubuntu, Debian, RHEL, Fedora, Rocky Linux, AlmaLinux, Arch Linux, CachyOS, openSUSE, Alpine Linux
|
|
41
|
+
**Environments:** Bare-Metal & Cloud VMs (Systemd) + Docker/LXC/Colab Containers (Non-Systemd)
|
|
42
|
+
**Ingress Engine:** Powered by [TunnelMate (`tunnelmate-cli`)](https://pypi.org/project/tunnelmate-cli/)
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## ๐ Features
|
|
47
|
+
|
|
48
|
+
- **๐ฏ Interactive Arrow-Key TUI Menu:** Built with `questionary` and `rich` for seamless keyboard navigation over SSH.
|
|
49
|
+
- **๐ฅ๏ธ 14 Desktop Environments & Window Managers:**
|
|
50
|
+
- *Full Desktops:* XFCE4 (Recommended), KDE Plasma, GNOME Shell, MATE, Cinnamon, LXQt, LXDE, Budgie, Deepin (DDE), Enlightenment.
|
|
51
|
+
- *Lightweight & Tiling WMs:* i3wm, Openbox, IceWM, Fluxbox.
|
|
52
|
+
- **๐ 6 Remote Access Protocols & Web Consoles:**
|
|
53
|
+
- **XRDP Server (Port 3389):** Microsoft Remote Desktop (`mstsc.exe`, Remmina, macOS RDP).
|
|
54
|
+
- **OpenSSH Server + X11 Forwarding (Port 22):** Secure terminal with remote GUI application forwarding.
|
|
55
|
+
- **TigerVNC Server (Port 5901):** Display `:1` RFB protocol for standard VNC viewers.
|
|
56
|
+
- **noVNC HTML5 Web Desktop (Port 6080):** Zero-install browser desktop over WebSocket.
|
|
57
|
+
- **X2Go Server (Port 22):** Low-bandwidth high-speed remote session over SSH.
|
|
58
|
+
- **Cockpit Web Console (Port 9090):** Modern web administration console.
|
|
59
|
+
- **โก Built-In Public Cloud Ingress (Powered by TunnelMate):**
|
|
60
|
+
- **TunnelMate Cloudflare TCP Tunnel (Windows RDP Port 3389):** Exposes Microsoft Remote Desktop over Cloudflare TCP protocol. Connect with `cloudflared access rdp --hostname <host> --url localhost:3389` and `mstsc.exe`.
|
|
61
|
+
- **TunnelMate Cloudflare HTTP Tunnel (Browser noVNC Port 6080):** Instantly generates public HTTPS links (`https://*.trycloudflare.com/vnc.html`) for noVNC browser desktop.
|
|
62
|
+
- **๐ก๏ธ Integrated Security & Firewall:** 1-click port inspection and opening for UFW & Firewalld.
|
|
63
|
+
- **๐ค Multi-User & Session Manager:** Automatic setup of `~/.xsession`, `~/.xsessionrc`, Polkit colord popup suppression, and DBus daemon handling.
|
|
64
|
+
- **๐งน Complete Clean Wipe:** Option to safely purge remote desktop services and restore server to clean state.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## ๐ฆ Installation & Setup
|
|
69
|
+
|
|
70
|
+
### Option 1: Install from PyPI
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
pip install linux-desktop-manager
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Option 2: Install from Source
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
git clone https://github.com/shashansoni/linux-desktop-manager.git
|
|
80
|
+
cd linux-desktop-manager
|
|
81
|
+
pip install -e .
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## ๐ฎ Usage
|
|
87
|
+
|
|
88
|
+
### 1. Interactive Arrow-Key TUI Menu (Default)
|
|
89
|
+
|
|
90
|
+
Launch the full interactive terminal menu with:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
sudo linux-desktop-manager
|
|
94
|
+
# or short alias:
|
|
95
|
+
sudo ldm
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Use your **Up/Down arrow keys**, **Space** to toggle checklist items, and **Enter** to select.
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
### 2. Command-Line (CLI) Automation
|
|
103
|
+
|
|
104
|
+
You can also use `linux-desktop-manager` in headless scripts, cloud deployment pipelines, and Docker containers:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
# View real-time status of services, active DE, and listening ports:
|
|
108
|
+
sudo linux-desktop-manager --status
|
|
109
|
+
|
|
110
|
+
# Install a desktop environment:
|
|
111
|
+
sudo linux-desktop-manager --install-de xfce4
|
|
112
|
+
|
|
113
|
+
# Switch default active session for user:
|
|
114
|
+
sudo linux-desktop-manager --set-de xfce4 --user myuser
|
|
115
|
+
|
|
116
|
+
# Manage individual services:
|
|
117
|
+
sudo linux-desktop-manager --start xrdp
|
|
118
|
+
sudo linux-desktop-manager --stop xrdp
|
|
119
|
+
sudo linux-desktop-manager --restart tigervnc
|
|
120
|
+
sudo linux-desktop-manager --install-service novnc
|
|
121
|
+
|
|
122
|
+
# Control public cloud tunnels:
|
|
123
|
+
sudo linux-desktop-manager --tunnel rdp # Start TunnelMate Cloudflare TCP tunnel for Windows RDP (Port 3389)
|
|
124
|
+
sudo linux-desktop-manager --tunnel cf # Start TunnelMate Cloudflare HTTPS browser tunnel (Port 6080)
|
|
125
|
+
sudo linux-desktop-manager --tunnel stop # Stop all public tunnels
|
|
126
|
+
|
|
127
|
+
# Open all remote desktop ports in firewall:
|
|
128
|
+
sudo linux-desktop-manager --allow-ports
|
|
129
|
+
|
|
130
|
+
# Clean wipe all remote desktop components:
|
|
131
|
+
sudo linux-desktop-manager --purge-all
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## ๐ Python Library API
|
|
137
|
+
|
|
138
|
+
You can import `linux_desktop_manager` directly in your Python projects and orchestration scripts:
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
from linux_desktop_manager import (
|
|
142
|
+
ServerEnv,
|
|
143
|
+
DesktopEnvManager,
|
|
144
|
+
RemoteServiceManager,
|
|
145
|
+
TunnelManager,
|
|
146
|
+
FirewallManager,
|
|
147
|
+
UserManager
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
# 1. Inspect Server Environment
|
|
151
|
+
env = ServerEnv()
|
|
152
|
+
print("OS:", env.os_info["pretty_name"])
|
|
153
|
+
print("Package Manager:", env.pkg_mgr)
|
|
154
|
+
print("Runtime Mode:", env.env_type)
|
|
155
|
+
print("Listening Ports:", env.get_listening_ports())
|
|
156
|
+
|
|
157
|
+
# 2. Manage Desktop Environments
|
|
158
|
+
de_mgr = DesktopEnvManager(env)
|
|
159
|
+
de_mgr.install_desktop("xfce4", target_user="ubuntu", set_as_default=True)
|
|
160
|
+
|
|
161
|
+
# 3. Manage Remote Services
|
|
162
|
+
svc_mgr = RemoteServiceManager(env)
|
|
163
|
+
svc_mgr.install_service("xrdp", target_user="ubuntu")
|
|
164
|
+
svc_mgr.start_service("xrdp")
|
|
165
|
+
|
|
166
|
+
# 4. Manage Cloudflare Tunnels (Powered by TunnelMate)
|
|
167
|
+
tunnel_mgr = TunnelManager()
|
|
168
|
+
|
|
169
|
+
# Browser noVNC HTTP Ingress
|
|
170
|
+
url = tunnel_mgr.start_cloudflare_tunnel(port=6080)
|
|
171
|
+
print(f"Web Browser Desktop URL: {url}/vnc.html")
|
|
172
|
+
|
|
173
|
+
# Windows RDP TCP Ingress
|
|
174
|
+
rdp_url = tunnel_mgr.start_rdp_tcp_tunnel(port=3389)
|
|
175
|
+
print(f"Windows RDP Cloudflare TCP Address: {rdp_url}")
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## ๐ License
|
|
181
|
+
|
|
182
|
+
This project is licensed under the **MIT License**. Created by [Shashan Lumbhani](https://pypi.org/project/tunnelmate-cli/).
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# โก Linux Desktop Manager (`linux-desktop-manager`)
|
|
2
|
+
|
|
3
|
+
> **All-In-One Linux Desktop Environment & Remote Access Orchestrator**
|
|
4
|
+
> *Interactive Arrow-Key TUI Menu, Full CLI Automation, 14 Desktops, 6 Remote Protocols, and Built-In TunnelMate Cloudflare Ingress.*
|
|
5
|
+
|
|
6
|
+
**Author:** [Shashan Lumbhani](mailto:lumbhanishashan1510@gmail.com)
|
|
7
|
+
**License:** [MIT](LICENSE)
|
|
8
|
+
**Supported Distros:** Ubuntu, Debian, RHEL, Fedora, Rocky Linux, AlmaLinux, Arch Linux, CachyOS, openSUSE, Alpine Linux
|
|
9
|
+
**Environments:** Bare-Metal & Cloud VMs (Systemd) + Docker/LXC/Colab Containers (Non-Systemd)
|
|
10
|
+
**Ingress Engine:** Powered by [TunnelMate (`tunnelmate-cli`)](https://pypi.org/project/tunnelmate-cli/)
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## ๐ Features
|
|
15
|
+
|
|
16
|
+
- **๐ฏ Interactive Arrow-Key TUI Menu:** Built with `questionary` and `rich` for seamless keyboard navigation over SSH.
|
|
17
|
+
- **๐ฅ๏ธ 14 Desktop Environments & Window Managers:**
|
|
18
|
+
- *Full Desktops:* XFCE4 (Recommended), KDE Plasma, GNOME Shell, MATE, Cinnamon, LXQt, LXDE, Budgie, Deepin (DDE), Enlightenment.
|
|
19
|
+
- *Lightweight & Tiling WMs:* i3wm, Openbox, IceWM, Fluxbox.
|
|
20
|
+
- **๐ 6 Remote Access Protocols & Web Consoles:**
|
|
21
|
+
- **XRDP Server (Port 3389):** Microsoft Remote Desktop (`mstsc.exe`, Remmina, macOS RDP).
|
|
22
|
+
- **OpenSSH Server + X11 Forwarding (Port 22):** Secure terminal with remote GUI application forwarding.
|
|
23
|
+
- **TigerVNC Server (Port 5901):** Display `:1` RFB protocol for standard VNC viewers.
|
|
24
|
+
- **noVNC HTML5 Web Desktop (Port 6080):** Zero-install browser desktop over WebSocket.
|
|
25
|
+
- **X2Go Server (Port 22):** Low-bandwidth high-speed remote session over SSH.
|
|
26
|
+
- **Cockpit Web Console (Port 9090):** Modern web administration console.
|
|
27
|
+
- **โก Built-In Public Cloud Ingress (Powered by TunnelMate):**
|
|
28
|
+
- **TunnelMate Cloudflare TCP Tunnel (Windows RDP Port 3389):** Exposes Microsoft Remote Desktop over Cloudflare TCP protocol. Connect with `cloudflared access rdp --hostname <host> --url localhost:3389` and `mstsc.exe`.
|
|
29
|
+
- **TunnelMate Cloudflare HTTP Tunnel (Browser noVNC Port 6080):** Instantly generates public HTTPS links (`https://*.trycloudflare.com/vnc.html`) for noVNC browser desktop.
|
|
30
|
+
- **๐ก๏ธ Integrated Security & Firewall:** 1-click port inspection and opening for UFW & Firewalld.
|
|
31
|
+
- **๐ค Multi-User & Session Manager:** Automatic setup of `~/.xsession`, `~/.xsessionrc`, Polkit colord popup suppression, and DBus daemon handling.
|
|
32
|
+
- **๐งน Complete Clean Wipe:** Option to safely purge remote desktop services and restore server to clean state.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## ๐ฆ Installation & Setup
|
|
37
|
+
|
|
38
|
+
### Option 1: Install from PyPI
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install linux-desktop-manager
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Option 2: Install from Source
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
git clone https://github.com/shashansoni/linux-desktop-manager.git
|
|
48
|
+
cd linux-desktop-manager
|
|
49
|
+
pip install -e .
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## ๐ฎ Usage
|
|
55
|
+
|
|
56
|
+
### 1. Interactive Arrow-Key TUI Menu (Default)
|
|
57
|
+
|
|
58
|
+
Launch the full interactive terminal menu with:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
sudo linux-desktop-manager
|
|
62
|
+
# or short alias:
|
|
63
|
+
sudo ldm
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Use your **Up/Down arrow keys**, **Space** to toggle checklist items, and **Enter** to select.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
### 2. Command-Line (CLI) Automation
|
|
71
|
+
|
|
72
|
+
You can also use `linux-desktop-manager` in headless scripts, cloud deployment pipelines, and Docker containers:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
# View real-time status of services, active DE, and listening ports:
|
|
76
|
+
sudo linux-desktop-manager --status
|
|
77
|
+
|
|
78
|
+
# Install a desktop environment:
|
|
79
|
+
sudo linux-desktop-manager --install-de xfce4
|
|
80
|
+
|
|
81
|
+
# Switch default active session for user:
|
|
82
|
+
sudo linux-desktop-manager --set-de xfce4 --user myuser
|
|
83
|
+
|
|
84
|
+
# Manage individual services:
|
|
85
|
+
sudo linux-desktop-manager --start xrdp
|
|
86
|
+
sudo linux-desktop-manager --stop xrdp
|
|
87
|
+
sudo linux-desktop-manager --restart tigervnc
|
|
88
|
+
sudo linux-desktop-manager --install-service novnc
|
|
89
|
+
|
|
90
|
+
# Control public cloud tunnels:
|
|
91
|
+
sudo linux-desktop-manager --tunnel rdp # Start TunnelMate Cloudflare TCP tunnel for Windows RDP (Port 3389)
|
|
92
|
+
sudo linux-desktop-manager --tunnel cf # Start TunnelMate Cloudflare HTTPS browser tunnel (Port 6080)
|
|
93
|
+
sudo linux-desktop-manager --tunnel stop # Stop all public tunnels
|
|
94
|
+
|
|
95
|
+
# Open all remote desktop ports in firewall:
|
|
96
|
+
sudo linux-desktop-manager --allow-ports
|
|
97
|
+
|
|
98
|
+
# Clean wipe all remote desktop components:
|
|
99
|
+
sudo linux-desktop-manager --purge-all
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## ๐ Python Library API
|
|
105
|
+
|
|
106
|
+
You can import `linux_desktop_manager` directly in your Python projects and orchestration scripts:
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
from linux_desktop_manager import (
|
|
110
|
+
ServerEnv,
|
|
111
|
+
DesktopEnvManager,
|
|
112
|
+
RemoteServiceManager,
|
|
113
|
+
TunnelManager,
|
|
114
|
+
FirewallManager,
|
|
115
|
+
UserManager
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
# 1. Inspect Server Environment
|
|
119
|
+
env = ServerEnv()
|
|
120
|
+
print("OS:", env.os_info["pretty_name"])
|
|
121
|
+
print("Package Manager:", env.pkg_mgr)
|
|
122
|
+
print("Runtime Mode:", env.env_type)
|
|
123
|
+
print("Listening Ports:", env.get_listening_ports())
|
|
124
|
+
|
|
125
|
+
# 2. Manage Desktop Environments
|
|
126
|
+
de_mgr = DesktopEnvManager(env)
|
|
127
|
+
de_mgr.install_desktop("xfce4", target_user="ubuntu", set_as_default=True)
|
|
128
|
+
|
|
129
|
+
# 3. Manage Remote Services
|
|
130
|
+
svc_mgr = RemoteServiceManager(env)
|
|
131
|
+
svc_mgr.install_service("xrdp", target_user="ubuntu")
|
|
132
|
+
svc_mgr.start_service("xrdp")
|
|
133
|
+
|
|
134
|
+
# 4. Manage Cloudflare Tunnels (Powered by TunnelMate)
|
|
135
|
+
tunnel_mgr = TunnelManager()
|
|
136
|
+
|
|
137
|
+
# Browser noVNC HTTP Ingress
|
|
138
|
+
url = tunnel_mgr.start_cloudflare_tunnel(port=6080)
|
|
139
|
+
print(f"Web Browser Desktop URL: {url}/vnc.html")
|
|
140
|
+
|
|
141
|
+
# Windows RDP TCP Ingress
|
|
142
|
+
rdp_url = tunnel_mgr.start_rdp_tcp_tunnel(port=3389)
|
|
143
|
+
print(f"Windows RDP Cloudflare TCP Address: {rdp_url}")
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## ๐ License
|
|
149
|
+
|
|
150
|
+
This project is licensed under the **MIT License**. Created by [Shashan Lumbhani](https://pypi.org/project/tunnelmate-cli/).
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "linux-desktop-manager"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "All-In-One Linux Desktop Environment & Remote Access Manager (XRDP, VNC, noVNC, X2Go, Tunnels) with Interactive Arrow-Key TUI & CLI"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Shashan Lumbhani", email = "lumbhanishashan1510@gmail.com" }
|
|
14
|
+
]
|
|
15
|
+
keywords = [
|
|
16
|
+
"linux",
|
|
17
|
+
"desktop-environment",
|
|
18
|
+
"remote-desktop",
|
|
19
|
+
"xrdp",
|
|
20
|
+
"vnc",
|
|
21
|
+
"novnc",
|
|
22
|
+
"x2go",
|
|
23
|
+
"cloudflared",
|
|
24
|
+
"tunnelmate",
|
|
25
|
+
"tui",
|
|
26
|
+
"cli"
|
|
27
|
+
]
|
|
28
|
+
classifiers = [
|
|
29
|
+
"Development Status :: 5 - Production/Stable",
|
|
30
|
+
"Environment :: Console",
|
|
31
|
+
"Intended Audience :: System Administrators",
|
|
32
|
+
"Intended Audience :: Developers",
|
|
33
|
+
"Operating System :: POSIX :: Linux",
|
|
34
|
+
"Programming Language :: Python :: 3",
|
|
35
|
+
"Programming Language :: Python :: 3.9",
|
|
36
|
+
"Programming Language :: Python :: 3.10",
|
|
37
|
+
"Programming Language :: Python :: 3.11",
|
|
38
|
+
"Programming Language :: Python :: 3.12",
|
|
39
|
+
"Programming Language :: Python :: 3.13",
|
|
40
|
+
"Programming Language :: Python :: 3.14",
|
|
41
|
+
"Topic :: System :: Systems Administration",
|
|
42
|
+
"Topic :: Terminals",
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
dependencies = [
|
|
46
|
+
"tunnelmate-cli>=1.1.8",
|
|
47
|
+
"rich>=13.0.0",
|
|
48
|
+
"questionary>=2.0.0",
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
[project.scripts]
|
|
52
|
+
linux-desktop-manager = "linux_desktop_manager.cli:main"
|
|
53
|
+
ldm = "linux_desktop_manager.cli:main"
|
|
54
|
+
|
|
55
|
+
[project.urls]
|
|
56
|
+
Homepage = "https://github.com/soni-shashan/linux-desktop-manager"
|
|
57
|
+
Repository = "https://github.com/soni-shashan/linux-desktop-manager"
|
|
58
|
+
Issues = "https://github.com/soni-shashan/linux-desktop-manager/issues"
|
|
59
|
+
|
|
60
|
+
[tool.setuptools.packages.find]
|
|
61
|
+
where = ["src"]
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Linux Desktop Manager by Shashan Lumbhani.
|
|
3
|
+
All-In-One Linux Desktop Environment & Remote Ingress Orchestrator.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from .server_env import ServerEnv
|
|
7
|
+
from .desktop_env import DesktopEnvManager
|
|
8
|
+
from .remote_services import RemoteServiceManager
|
|
9
|
+
from .tunnels import TunnelManager
|
|
10
|
+
from .users import UserManager
|
|
11
|
+
from .firewall import FirewallManager
|
|
12
|
+
from .interactive import run_interactive_menu
|
|
13
|
+
from .cli import main
|
|
14
|
+
|
|
15
|
+
__version__ = "1.0.0"
|
|
16
|
+
__author__ = "Shashan Lumbhani"
|
|
17
|
+
__license__ = "MIT"
|
|
18
|
+
|
|
19
|
+
__all__ = [
|
|
20
|
+
"ServerEnv",
|
|
21
|
+
"DesktopEnvManager",
|
|
22
|
+
"RemoteServiceManager",
|
|
23
|
+
"TunnelManager",
|
|
24
|
+
"UserManager",
|
|
25
|
+
"FirewallManager",
|
|
26
|
+
"run_interactive_menu",
|
|
27
|
+
"main",
|
|
28
|
+
"__version__"
|
|
29
|
+
]
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Command-Line Interface (CLI) entry point for linux-desktop-manager.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import os
|
|
8
|
+
import shutil
|
|
9
|
+
import argparse
|
|
10
|
+
import sys
|
|
11
|
+
from .formatting import console, print_banner, print_services_table, print_desktops_table, print_connection_card
|
|
12
|
+
from .server_env import ServerEnv
|
|
13
|
+
from .desktop_env import DesktopEnvManager
|
|
14
|
+
from .remote_services import RemoteServiceManager
|
|
15
|
+
from .tunnels import TunnelManager
|
|
16
|
+
from .firewall import FirewallManager
|
|
17
|
+
from .users import UserManager
|
|
18
|
+
from .interactive import run_interactive_menu
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def ensure_system_symlinks() -> None:
|
|
22
|
+
"""Ensure /usr/local/bin/ldm and /usr/local/bin/linux-desktop-manager wrappers exist so 'sudo ldm' works directly."""
|
|
23
|
+
if os.geteuid() != 0:
|
|
24
|
+
return
|
|
25
|
+
|
|
26
|
+
wrapper_content = f"""#!/usr/bin/env bash
|
|
27
|
+
# Auto-generated by Linux Desktop Manager Orchestrator
|
|
28
|
+
# Preserves user site-packages and editable installs when running under sudo.
|
|
29
|
+
if [ -n "$SUDO_USER" ] && [ "$SUDO_USER" != "root" ]; then
|
|
30
|
+
USER_HOME=$(getent passwd "$SUDO_USER" 2>/dev/null | cut -d: -f6)
|
|
31
|
+
[ -z "$USER_HOME" ] && USER_HOME="/home/$SUDO_USER"
|
|
32
|
+
for pdir in "$USER_HOME"/.local/lib/python*/site-packages; do
|
|
33
|
+
if [ -d "$pdir" ]; then
|
|
34
|
+
export PYTHONPATH="$pdir:$PYTHONPATH"
|
|
35
|
+
for pth in "$pdir"/*.pth; do
|
|
36
|
+
if [ -f "$pth" ]; then
|
|
37
|
+
while IFS= read -r line || [ -n "$line" ]; do
|
|
38
|
+
[[ "$line" =~ ^[#] ]] && continue
|
|
39
|
+
[ -d "$line" ] && export PYTHONPATH="$line:$PYTHONPATH"
|
|
40
|
+
done < "$pth"
|
|
41
|
+
fi
|
|
42
|
+
done
|
|
43
|
+
fi
|
|
44
|
+
done
|
|
45
|
+
fi
|
|
46
|
+
|
|
47
|
+
exec {sys.executable} -m linux_desktop_manager "$@"
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
for name in ["ldm", "linux-desktop-manager"]:
|
|
51
|
+
usr_bin_target = f"/usr/local/bin/{name}"
|
|
52
|
+
try:
|
|
53
|
+
needs_write = True
|
|
54
|
+
if os.path.exists(usr_bin_target) and not os.path.islink(usr_bin_target):
|
|
55
|
+
try:
|
|
56
|
+
with open(usr_bin_target, "r") as f:
|
|
57
|
+
content = f.read()
|
|
58
|
+
if "linux_desktop_manager" in content and "pth" in content:
|
|
59
|
+
needs_write = False
|
|
60
|
+
except Exception:
|
|
61
|
+
pass
|
|
62
|
+
|
|
63
|
+
if needs_write:
|
|
64
|
+
if os.path.islink(usr_bin_target) or os.path.exists(usr_bin_target):
|
|
65
|
+
os.remove(usr_bin_target)
|
|
66
|
+
with open(usr_bin_target, "w") as f:
|
|
67
|
+
f.write(wrapper_content)
|
|
68
|
+
os.chmod(usr_bin_target, 0o755)
|
|
69
|
+
except Exception:
|
|
70
|
+
pass
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def check_elevation() -> None:
|
|
74
|
+
"""Auto-elevates with sudo preserving user site-packages and editable paths if not root."""
|
|
75
|
+
if any(arg in sys.argv for arg in ["-h", "--help"]):
|
|
76
|
+
return
|
|
77
|
+
|
|
78
|
+
# If already root, ensure system wrappers exist in /usr/local/bin
|
|
79
|
+
if os.geteuid() == 0:
|
|
80
|
+
ensure_system_symlinks()
|
|
81
|
+
return
|
|
82
|
+
|
|
83
|
+
# Non-root user: Auto-elevate via sudo preserving all non-system sys.path entries
|
|
84
|
+
if shutil.which("sudo"):
|
|
85
|
+
console.print("[dim cyan]โก Elevated privileges required. Elevating with sudo...[/dim cyan]")
|
|
86
|
+
try:
|
|
87
|
+
user_paths = [p for p in sys.path if p and not p.startswith("/usr/lib") and os.path.isdir(p)]
|
|
88
|
+
pythonpath = ":".join(user_paths) if user_paths else ""
|
|
89
|
+
|
|
90
|
+
cmd = ["sudo", "env"]
|
|
91
|
+
if pythonpath:
|
|
92
|
+
cmd.append(f"PYTHONPATH={pythonpath}")
|
|
93
|
+
cmd.extend([sys.executable, "-m", "linux_desktop_manager"] + sys.argv[1:])
|
|
94
|
+
|
|
95
|
+
os.execvp("sudo", cmd)
|
|
96
|
+
except Exception as e:
|
|
97
|
+
console.print(f"[bold red]Elevation failed: {e}. Please run with sudo.[/bold red]")
|
|
98
|
+
sys.exit(1)
|
|
99
|
+
else:
|
|
100
|
+
console.print("[bold red]Root privileges are required to manage desktop environments and services.[/bold red]")
|
|
101
|
+
sys.exit(1)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def main() -> None:
|
|
105
|
+
check_elevation()
|
|
106
|
+
parser = argparse.ArgumentParser(
|
|
107
|
+
prog="linux-desktop-manager",
|
|
108
|
+
description="โก Linux Desktop Environment & Remote Access Manager (CLI & Interactive TUI)",
|
|
109
|
+
epilog="""
|
|
110
|
+
Examples:
|
|
111
|
+
sudo linux-desktop-manager # Launch full interactive Arrow-Key TUI menu
|
|
112
|
+
sudo linux-desktop-manager --status # View current status of services and ports
|
|
113
|
+
sudo linux-desktop-manager --install-de xfce4
|
|
114
|
+
sudo linux-desktop-manager --start xrdp
|
|
115
|
+
sudo linux-desktop-manager --tunnel cf # Expose Browser Desktop via TunnelMate
|
|
116
|
+
"""
|
|
117
|
+
)
|
|
118
|
+
parser.add_argument("--tui", action="store_true", help="Launch interactive Arrow-Key TUI menu (default if no flags)")
|
|
119
|
+
parser.add_argument("--status", action="store_true", help="Print live service, desktop, and port status table")
|
|
120
|
+
parser.add_argument("--install-wizard", action="store_true", help="Launch step-by-step installation wizard")
|
|
121
|
+
parser.add_argument("--install-de", metavar="NAME", help="Install a desktop environment (e.g. xfce4, plasma, i3, gnome)")
|
|
122
|
+
parser.add_argument("--uninstall-de", metavar="NAME", help="Uninstall a desktop environment")
|
|
123
|
+
parser.add_argument("--set-de", metavar="NAME", help="Set default desktop session for target user")
|
|
124
|
+
parser.add_argument("--start", metavar="SERVICE", help="Start service (xrdp, openssh, tigervnc, novnc, x2go, cockpit)")
|
|
125
|
+
parser.add_argument("--stop", metavar="SERVICE", help="Stop service")
|
|
126
|
+
parser.add_argument("--restart", metavar="SERVICE", help="Restart service")
|
|
127
|
+
parser.add_argument("--install-service", metavar="SERVICE", help="Install and configure service")
|
|
128
|
+
parser.add_argument("--uninstall-service", metavar="SERVICE", help="Uninstall service")
|
|
129
|
+
parser.add_argument("--tunnel", choices=["cf", "rdp", "stop"], help="Manage public tunnels: cf (browser), rdp (TunnelMate TCP RDP), stop")
|
|
130
|
+
parser.add_argument("--allow-ports", action="store_true", help="Allow all remote desktop ports in firewall")
|
|
131
|
+
parser.add_argument("--purge-all", action="store_true", help="Purge all remote desktop services and configs")
|
|
132
|
+
parser.add_argument("--user", metavar="USERNAME", help="Specify target user (default: current/sudo user)")
|
|
133
|
+
|
|
134
|
+
args = parser.parse_args()
|
|
135
|
+
|
|
136
|
+
# If no flags passed or --tui, run the interactive arrow-key TUI menu
|
|
137
|
+
if len(sys.argv) == 1 or args.tui or args.install_wizard:
|
|
138
|
+
run_interactive_menu()
|
|
139
|
+
return
|
|
140
|
+
|
|
141
|
+
# CLI automated actions
|
|
142
|
+
server_env = ServerEnv()
|
|
143
|
+
desktop_mgr = DesktopEnvManager(server_env)
|
|
144
|
+
service_mgr = RemoteServiceManager(server_env)
|
|
145
|
+
tunnel_mgr = TunnelManager()
|
|
146
|
+
firewall_mgr = FirewallManager()
|
|
147
|
+
target_user = args.user or server_env.get_invoking_user()
|
|
148
|
+
|
|
149
|
+
if args.status:
|
|
150
|
+
print_banner()
|
|
151
|
+
print_services_table(service_mgr.get_all_services_status())
|
|
152
|
+
cf_url = tunnel_mgr.get_cloudflare_url()
|
|
153
|
+
rdp_tcp_url = tunnel_mgr.get_rdp_tcp_url()
|
|
154
|
+
local_ips = server_env.get_local_ips()
|
|
155
|
+
pub_ip = server_env.get_public_ip()
|
|
156
|
+
active_de = desktop_mgr.get_active_session(target_user) or "None"
|
|
157
|
+
print_connection_card(
|
|
158
|
+
user=target_user,
|
|
159
|
+
de_name=active_de,
|
|
160
|
+
local_ip=local_ips[0] if local_ips else "127.0.0.1",
|
|
161
|
+
public_ip=pub_ip,
|
|
162
|
+
cf_url=cf_url,
|
|
163
|
+
rdp_tcp_url=rdp_tcp_url
|
|
164
|
+
)
|
|
165
|
+
elif args.install_de:
|
|
166
|
+
console.print(f"[bold cyan]Installing desktop environment: {args.install_de}...[/bold cyan]")
|
|
167
|
+
desktop_mgr.install_desktop(args.install_de, target_user, set_as_default=True, live_callback=console.print)
|
|
168
|
+
elif args.uninstall_de:
|
|
169
|
+
console.print(f"[bold red]Uninstalling desktop environment: {args.uninstall_de}...[/bold red]")
|
|
170
|
+
desktop_mgr.uninstall_desktop(args.uninstall_de, live_callback=console.print)
|
|
171
|
+
elif args.set_de:
|
|
172
|
+
if desktop_mgr.set_default_session(args.set_de, target_user):
|
|
173
|
+
console.print(f"[bold green]โ Default session for '{target_user}' set to {args.set_de}.[/bold green]")
|
|
174
|
+
else:
|
|
175
|
+
console.print("[bold red]Failed to set session.[/bold red]")
|
|
176
|
+
elif args.start:
|
|
177
|
+
service_mgr.start_service(args.start, target_user=target_user)
|
|
178
|
+
console.print(f"[bold green]โ Started {args.start}.[/bold green]")
|
|
179
|
+
elif args.stop:
|
|
180
|
+
service_mgr.stop_service(args.stop)
|
|
181
|
+
console.print(f"[bold yellow]Stopped {args.stop}.[/bold yellow]")
|
|
182
|
+
elif args.restart:
|
|
183
|
+
service_mgr.restart_service(args.restart, target_user=target_user)
|
|
184
|
+
console.print(f"[bold green]โ Restarted {args.restart}.[/bold green]")
|
|
185
|
+
elif args.install_service:
|
|
186
|
+
console.print(f"[bold cyan]Installing remote service: {args.install_service}...[/bold cyan]")
|
|
187
|
+
service_mgr.install_service(args.install_service, target_user=target_user, live_callback=console.print)
|
|
188
|
+
elif args.uninstall_service:
|
|
189
|
+
service_mgr.uninstall_service(args.uninstall_service, purge_configs=True, live_callback=console.print)
|
|
190
|
+
elif args.tunnel:
|
|
191
|
+
if args.tunnel == "cf":
|
|
192
|
+
url = tunnel_mgr.start_cloudflare_tunnel(port=6080, live_callback=console.print)
|
|
193
|
+
if url:
|
|
194
|
+
console.print(f"[bold green]โ Cloudflare Browser URL: {url}/vnc.html[/bold green]")
|
|
195
|
+
elif args.tunnel == "rdp":
|
|
196
|
+
url = tunnel_mgr.start_rdp_tcp_tunnel(port=3389, live_callback=console.print)
|
|
197
|
+
if url:
|
|
198
|
+
clean_host = url.replace("https://", "").replace("http://", "").strip("/")
|
|
199
|
+
console.print(f"[bold green]โ TunnelMate Cloudflare TCP RDP Assigned: {url}[/bold green]")
|
|
200
|
+
console.print(f"[dim cyan]Client Command: cloudflared access rdp --hostname {clean_host} --url localhost:3389[/dim cyan]")
|
|
201
|
+
console.print(f"[dim]Then open Windows mstsc to: localhost:3389[/dim]")
|
|
202
|
+
elif args.tunnel == "stop":
|
|
203
|
+
tunnel_mgr.stop_all_tunnels()
|
|
204
|
+
console.print("[yellow]All tunnels stopped.[/yellow]")
|
|
205
|
+
elif args.allow_ports:
|
|
206
|
+
firewall_mgr.allow_all_remote_ports()
|
|
207
|
+
console.print("[bold green]โ All remote desktop ports allowed in firewall.[/bold green]")
|
|
208
|
+
elif args.purge_all:
|
|
209
|
+
for sid in ["novnc", "tigervnc", "xrdp", "x2go", "cockpit"]:
|
|
210
|
+
service_mgr.uninstall_service(sid, purge_configs=True, live_callback=console.print)
|
|
211
|
+
tunnel_mgr.stop_all_tunnels()
|
|
212
|
+
console.print("[bold green]โ Clean wipe completed.[/bold green]")
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
if __name__ == "__main__":
|
|
216
|
+
main()
|