-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_linux.sh
More file actions
executable file
·719 lines (661 loc) · 28.1 KB
/
Copy pathinstall_linux.sh
File metadata and controls
executable file
·719 lines (661 loc) · 28.1 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
#!/bin/bash
# Exit immediately if a command exits with a non-zero status
set -e
if [ -z "$PREFIX" ]; then
echo "Error: This script must be run inside Termux."
exit 1
fi
show_menu() {
clear
echo "========================================="
echo " Linux for Termux Manager "
echo "========================================="
echo "1) Install / Re-install Linux Distro"
echo "2) Update a Distro (1-Click Updater)"
echo "3) Start SSH Server"
echo "4) System Dashboard"
echo "5) Audio Debugger / Fixer"
echo "6) Backup a Distro (Internal)"
echo "7) Restore a Distro (Internal)"
echo "8) Export Distro (Share to Downloads)"
echo "9) Import Shared Distro"
echo "10) Uninstall a Distro"
echo "11) Toggle Browser Hardware Acceleration"
echo "12) Exit"
echo "========================================="
read -p "Select an option [1-12]: " OPTION
case $OPTION in
1) install_linux ;;
2) update_linux ;;
3) start_ssh ;;
4) system_dashboard ;;
5) audio_fixer ;;
6) backup_linux ;;
7) restore_linux ;;
8) export_distro ;;
9) import_distro ;;
10) uninstall_linux ;;
11) optimize_browser ;;
12) exit 0 ;;
*) echo "Invalid option"; sleep 1; show_menu ;;
esac
}
get_distro_choice() {
echo ""
echo "Choose Linux Distribution:"
echo "1) Ubuntu (apt)"
echo "2) Debian (apt)"
echo "3) Kali Linux (apt)"
echo "4) Fedora (dnf)"
echo "5) OpenSUSE (zypper)"
echo "6) Void Linux (xbps)"
echo "7) Arch Linux (pacman) [May be unstable on ARM64]"
read -p "Select Distro [1-7]: " DIST_CHOICE
case $DIST_CHOICE in
1) DISTRO="ubuntu";;
2) DISTRO="debian";;
3) DISTRO="kali";;
4) DISTRO="fedora";;
5) DISTRO="opensuse";;
6) DISTRO="void";;
7) DISTRO="archlinux";;
*) echo "Invalid choice"; exit 1 ;;
esac
}
system_dashboard() {
clear
echo "========================================="
echo " SYSTEM DASHBOARD "
echo "========================================="
echo "OS Architecture: $(uname -m)"
echo "-----------------------------------------"
echo "Android Memory (RAM) Usage:"
free -m || echo "Memory stats unavailable."
echo "-----------------------------------------"
echo "Termux Storage Usage (Total Size):"
du -sh $PREFIX 2>/dev/null | awk '{print $1}'
echo "-----------------------------------------"
echo "Available Phone Storage:"
df -h /data | awk 'NR==2 {print $4}'
echo "========================================="
read -p "Press Enter to continue..."
show_menu
}
audio_fixer() {
echo "[*] Restarting PulseAudio and clearing sockets..."
pulseaudio -k 2>/dev/null || true
rm -rf /data/data/com.termux/files/usr/tmp/pulse-* 2>/dev/null || true
pulseaudio --start --load="module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1" --exit-idle-time=-1
echo "Audio server forcefully bound to TCP protocol!"
read -p "Press Enter to continue..."
show_menu
}
update_linux() {
get_distro_choice
CONF_FILE="$PREFIX/var/lib/proot-distro/installed-rootfs/$DISTRO/etc/termux-linux-manager.conf"
if [ ! -f "$CONF_FILE" ]; then
echo "Error: Distro not installed or missing configuration file."
else
source "$CONF_FILE"
echo "[*] Updating $DISTRO..."
proot-distro login "$DISTRO" --user root -- bash -c "export DEBIAN_FRONTEND=noninteractive; $UPDATE_CMD"
echo "========================================="
echo "Update complete!"
echo "========================================="
fi
read -p "Press Enter to continue..."
show_menu
}
start_ssh() {
echo "[*] Starting Termux SSH Server..."
pkg install openssh -y
sshd
IP=$(ifconfig 2>/dev/null | grep -E 'inet .*broadcast' | awk '{print $2}' | head -n 1)
if [ -z "$IP" ]; then IP=$(ifconfig 2>/dev/null | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | head -n 1); fi
if [ -z "$IP" ]; then IP="YOUR_PHONE_IP"; fi
echo "========================================="
echo "SSH Server is running!"
echo "To connect from your PC, run this command in your PC's terminal:"
echo ""
echo " ssh $(whoami)@$IP -p 8022"
echo ""
echo "Note: If you have never set a Termux password, type 'passwd' right now to create one."
echo "========================================="
read -p "Press Enter to continue..."
show_menu
}
backup_linux() {
get_distro_choice
echo "[*] Backing up $DISTRO (Internal)..."
proot-distro backup "$DISTRO" --output ~/${DISTRO}-backup.tar.gz
echo "Backup saved to ~/${DISTRO}-backup.tar.gz"
read -p "Press Enter to continue..."
show_menu
}
restore_linux() {
get_distro_choice
if [ ! -f ~/${DISTRO}-backup.tar.gz ]; then
echo "Error: No internal backup found at ~/${DISTRO}-backup.tar.gz"
else
echo "[*] Restoring $DISTRO..."
read -p "Are you sure? This overwrites current data [y/N]: " CONFIRM
if [[ "$CONFIRM" =~ ^[Yy]$ ]]; then
proot-distro restore "$DISTRO" --input ~/${DISTRO}-backup.tar.gz
echo "Restore complete!"
fi
fi
read -p "Press Enter to continue..."
show_menu
}
export_distro() {
get_distro_choice
echo "[*] Requesting Android Storage Permission..."
termux-setup-storage || true
sleep 2
mkdir -p ~/storage/downloads/
echo "[*] Exporting $DISTRO to Android Downloads folder (This may take a while)..."
proot-distro backup "$DISTRO" --output ~/storage/downloads/${DISTRO}-shared.tar.gz
echo "========================================="
echo "Export Complete!"
echo "File saved to: Downloads/${DISTRO}-shared.tar.gz"
echo "You can now share this file with your friends via Google Drive or USB!"
echo "========================================="
read -p "Press Enter to continue..."
show_menu
}
import_distro() {
get_distro_choice
echo "[*] Requesting Android Storage Permission..."
termux-setup-storage || true
sleep 2
if [ ! -f ~/storage/downloads/${DISTRO}-shared.tar.gz ]; then
echo "========================================="
echo "Error: No shared file found!"
echo "Make sure your friend's file is named exactly '${DISTRO}-shared.tar.gz'"
echo "and is placed inside your phone's 'Downloads' folder."
echo "========================================="
else
echo "[*] Importing $DISTRO from Downloads..."
read -p "Are you sure? This will completely overwrite any current $DISTRO installation [y/N]: " CONFIRM
if [[ "$CONFIRM" =~ ^[Yy]$ ]]; then
proot-distro restore "$DISTRO" --input ~/storage/downloads/${DISTRO}-shared.tar.gz
echo "========================================="
echo "Import complete! You can now use start-linux to boot your friend's setup."
echo "========================================="
fi
fi
read -p "Press Enter to continue..."
show_menu
}
optimize_browser() {
get_distro_choice
echo ""
echo "Browser Optimization Menu:"
echo "1) Enable Hardware Acceleration (VirGL - Smooth YouTube)"
echo "2) Disable Hardware Acceleration (Revert to Default)"
read -p "Select an option [1-2]: " OPT_CHOICE
if [ "$OPT_CHOICE" == "1" ]; then
echo "[*] Optimizing Chromium for Hardware Accelerated Video Decoding..."
proot-distro login "$DISTRO" -- bash -c '
cat << EOF > /usr/local/bin/chromium
#!/bin/bash
/usr/bin/chromium --ignore-gpu-blocklist --enable-gpu-rasterization --enable-zero-copy --use-gl=egl "\$@" 2>/dev/null
EOF
chmod +x /usr/local/bin/chromium
cat << EOF > /usr/local/bin/chromium-browser
#!/bin/bash
/usr/bin/chromium-browser --ignore-gpu-blocklist --enable-gpu-rasterization --enable-zero-copy --use-gl=egl "\$@" 2>/dev/null
EOF
chmod +x /usr/local/bin/chromium-browser
'
echo "========================================="
echo "Optimization complete! Chromium will now render using VirGL!"
echo "========================================="
elif [ "$OPT_CHOICE" == "2" ]; then
echo "[*] Removing Hardware Acceleration Overrides..."
proot-distro login "$DISTRO" -- bash -c '
rm -f /usr/local/bin/chromium
rm -f /usr/local/bin/chromium-browser
'
echo "========================================="
echo "Hardware Acceleration disabled. Restored to default!"
echo "========================================="
else
echo "Invalid selection."
fi
read -p "Press Enter to continue..."
show_menu
}
uninstall_linux() {
get_distro_choice
read -p "Are you sure you want to uninstall $DISTRO? [y/N]: " CONFIRM
if [[ "$CONFIRM" =~ ^[Yy]$ ]]; then
echo "[*] Uninstalling $DISTRO..."
proot-distro remove "$DISTRO" || true
echo "$DISTRO has been removed."
fi
read -p "Press Enter to continue..."
show_menu
}
install_linux() {
echo ""
echo "========================================="
echo " Linux Installation Wizard "
echo "========================================="
echo ""
echo "⚠️ IMPORTANT WARNING FOR ANDROID 12+ USERS ⚠️"
echo "If you are on Android 14+, you MUST toggle 'Disable child process restrictions'"
echo "in your Android Developer Options for a stable desktop experience."
echo "========================================="
echo ""
get_distro_choice
DE="none"
SERVER="none"
RESOLUTION="1280x720"
echo ""
echo "Choose Desktop Environment:"
echo "1) XFCE4 (Recommended, Lightweight GUI)"
echo "2) LXDE (Very Lightweight GUI)"
echo "3) None (CLI only)"
read -p "Select DE [1-3]: " DE_CHOICE
if [ "$DE_CHOICE" == "1" ]; then DE="xfce4"; elif [ "$DE_CHOICE" == "2" ]; then DE="lxde"; else DE="none"; fi
if [ "$DE" != "none" ]; then
echo ""
echo "Choose Display Server:"
echo "1) Termux:X11 (Hardware Acceleration, Faster)"
echo "2) VNC (Software Rendering, Slower)"
read -p "Select Server [1-2]: " SRV_CHOICE
if [ "$SRV_CHOICE" == "1" ]; then SERVER="x11"; else SERVER="vnc"; fi
if [ "$SERVER" == "vnc" ]; then
echo ""
echo "Choose Display Resolution / UI Scaling:"
echo "1) Auto / 720p (Lightweight - Recommended)"
echo "2) 1080p (HD)"
echo "3) iPad / Tablet Ratio (1440x1080)"
read -p "Select Resolution [1-3]: " RES_CHOICE
if [ "$RES_CHOICE" == "2" ]; then RESOLUTION="1920x1080"; elif [ "$RES_CHOICE" == "3" ]; then RESOLUTION="1440x1080"; else RESOLUTION="1280x720"; fi
fi
fi
# SOFTWARE SELECTOR
echo ""
echo "========================================="
echo " Software Selector (Optional) "
echo "========================================="
echo "Development Tools:"
echo " 1) Python 2) Git 3) Node.js"
echo " 4) curl 5) wget 6) Google Antigravity IDE"
echo "Web Browsers:"
echo " 7) Firefox 8) Chromium"
echo "Office Suite:"
echo " 9) LibreOffice"
echo "Media Tools:"
echo " 10) VLC 11) GIMP"
echo "System Utilities:"
echo " 12) htop 13) neofetch"
echo "========================================="
echo "Enter numbers separated by spaces (e.g. 1 2 7 12), or press Enter to skip."
read -p "Selection: " APP_CHOICES
INSTALL_PYTHON=0; INSTALL_GIT=0; INSTALL_NODEJS=0; INSTALL_CURL=0; INSTALL_WGET=0; INSTALL_IDE=0
INSTALL_FIREFOX=0; INSTALL_CHROMIUM=0
INSTALL_LIBREOFFICE=0; INSTALL_VLC=0; INSTALL_GIMP=0
INSTALL_HTOP=0; INSTALL_NEOFETCH=0
for choice in $APP_CHOICES; do
case $choice in
1) INSTALL_PYTHON=1 ;;
2) INSTALL_GIT=1 ;;
3) INSTALL_NODEJS=1 ;;
4) INSTALL_CURL=1 ;;
5) INSTALL_WGET=1 ;;
6) INSTALL_IDE=1 ;;
7) INSTALL_FIREFOX=1 ;;
8) INSTALL_CHROMIUM=1 ;;
9) INSTALL_LIBREOFFICE=1 ;;
10) INSTALL_VLC=1 ;;
11) INSTALL_GIMP=1 ;;
12) INSTALL_HTOP=1 ;;
13) INSTALL_NEOFETCH=1 ;;
esac
done
echo ""
echo "========================================="
echo "Beginning Installation..."
echo "========================================="
echo "[*] Requesting Android Storage Permission..."
termux-setup-storage || true
sleep 2
echo "[*] Updating Termux packages..."
pkg update -y && pkg upgrade -y
echo "[*] Installing dependencies..."
pkg install proot-distro pulseaudio wget virglrenderer-android -y
if [ "$SERVER" == "x11" ]; then
pkg install x11-repo -y
pkg install termux-x11-nightly -y
fi
echo "[*] Installing $DISTRO..."
proot-distro install "$DISTRO"
ROOTFS="$PREFIX/var/lib/proot-distro/installed-rootfs/$DISTRO"
mkdir -p "$ROOTFS/root"
SETUP_SCRIPT="$ROOTFS/root/gui_setup.sh"
# Configure package manager mapping
case "$DISTRO" in
ubuntu|debian|kali)
UPDATE_CMD="apt-get update -y && apt-get upgrade -y"
INSTALL_CMD="apt-get install -y"
XFCE_PKG="xfce4 xfce4-goodies dbus-x11"
LXDE_PKG="lxde dbus-x11"
VNC_PKG="tigervnc-standalone-server expect"
SUDO_PKG="sudo"
SELECTED_PKGS=""
if [ "$INSTALL_PYTHON" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS python3"; fi
if [ "$INSTALL_GIT" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS git"; fi
if [ "$INSTALL_NODEJS" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS nodejs"; fi
if [ "$INSTALL_CURL" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS curl"; fi
if [ "$INSTALL_WGET" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS wget"; fi
if [ "$INSTALL_FIREFOX" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS firefox"; fi
if [ "$INSTALL_CHROMIUM" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS chromium-browser"; fi
if [ "$INSTALL_LIBREOFFICE" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS libreoffice"; fi
if [ "$INSTALL_VLC" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS vlc"; fi
if [ "$INSTALL_GIMP" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS gimp"; fi
if [ "$INSTALL_HTOP" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS htop"; fi
if [ "$INSTALL_NEOFETCH" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS neofetch"; fi
;;
archlinux)
UPDATE_CMD="pacman -Syu --noconfirm"
INSTALL_CMD="pacman -S --noconfirm"
XFCE_PKG="xfce4 xfce4-goodies dbus"
LXDE_PKG="lxde dbus"
VNC_PKG="tigervnc expect"
SUDO_PKG="sudo"
SELECTED_PKGS=""
if [ "$INSTALL_PYTHON" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS python"; fi
if [ "$INSTALL_GIT" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS git"; fi
if [ "$INSTALL_NODEJS" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS nodejs"; fi
if [ "$INSTALL_CURL" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS curl"; fi
if [ "$INSTALL_WGET" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS wget"; fi
if [ "$INSTALL_FIREFOX" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS firefox"; fi
if [ "$INSTALL_CHROMIUM" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS chromium"; fi
if [ "$INSTALL_LIBREOFFICE" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS libreoffice-fresh"; fi
if [ "$INSTALL_VLC" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS vlc"; fi
if [ "$INSTALL_GIMP" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS gimp"; fi
if [ "$INSTALL_HTOP" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS htop"; fi
if [ "$INSTALL_NEOFETCH" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS neofetch"; fi
;;
fedora)
UPDATE_CMD="dnf update -y"
INSTALL_CMD="dnf install -y"
XFCE_PKG="xfce4-session xfce4-panel xfdesktop xfwm4 dbus-x11"
LXDE_PKG="lxde-common lxsession dbus-x11"
VNC_PKG="tigervnc-server expect"
SUDO_PKG="sudo"
SELECTED_PKGS=""
if [ "$INSTALL_PYTHON" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS python3"; fi
if [ "$INSTALL_GIT" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS git"; fi
if [ "$INSTALL_NODEJS" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS nodejs"; fi
if [ "$INSTALL_CURL" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS curl"; fi
if [ "$INSTALL_WGET" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS wget"; fi
if [ "$INSTALL_FIREFOX" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS firefox"; fi
if [ "$INSTALL_CHROMIUM" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS chromium"; fi
if [ "$INSTALL_LIBREOFFICE" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS libreoffice"; fi
if [ "$INSTALL_VLC" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS vlc"; fi
if [ "$INSTALL_GIMP" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS gimp"; fi
if [ "$INSTALL_HTOP" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS htop"; fi
if [ "$INSTALL_NEOFETCH" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS neofetch"; fi
;;
opensuse)
UPDATE_CMD="zypper refresh && zypper update -y"
INSTALL_CMD="zypper install -y"
XFCE_PKG="patterns-xfce-xfce dbus-1-x11"
LXDE_PKG="patterns-lxde-lxde dbus-1-x11"
VNC_PKG="tigervnc expect"
SUDO_PKG="sudo"
SELECTED_PKGS=""
if [ "$INSTALL_PYTHON" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS python3"; fi
if [ "$INSTALL_GIT" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS git"; fi
if [ "$INSTALL_NODEJS" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS nodejs"; fi
if [ "$INSTALL_CURL" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS curl"; fi
if [ "$INSTALL_WGET" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS wget"; fi
if [ "$INSTALL_FIREFOX" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS MozillaFirefox"; fi
if [ "$INSTALL_CHROMIUM" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS chromium"; fi
if [ "$INSTALL_LIBREOFFICE" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS libreoffice"; fi
if [ "$INSTALL_VLC" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS vlc"; fi
if [ "$INSTALL_GIMP" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS gimp"; fi
if [ "$INSTALL_HTOP" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS htop"; fi
if [ "$INSTALL_NEOFETCH" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS neofetch"; fi
;;
void)
UPDATE_CMD="xbps-install -Syu"
INSTALL_CMD="xbps-install -y"
XFCE_PKG="xfce4 dbus"
LXDE_PKG="lxde dbus"
VNC_PKG="tigervnc expect"
SUDO_PKG="sudo"
SELECTED_PKGS=""
if [ "$INSTALL_PYTHON" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS python3"; fi
if [ "$INSTALL_GIT" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS git"; fi
if [ "$INSTALL_NODEJS" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS nodejs"; fi
if [ "$INSTALL_CURL" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS curl"; fi
if [ "$INSTALL_WGET" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS wget"; fi
if [ "$INSTALL_FIREFOX" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS firefox"; fi
if [ "$INSTALL_CHROMIUM" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS chromium"; fi
if [ "$INSTALL_LIBREOFFICE" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS libreoffice"; fi
if [ "$INSTALL_VLC" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS vlc"; fi
if [ "$INSTALL_GIMP" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS gimp"; fi
if [ "$INSTALL_HTOP" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS htop"; fi
if [ "$INSTALL_NEOFETCH" == "1" ]; then SELECTED_PKGS="$SELECTED_PKGS neofetch"; fi
;;
esac
# Save the configuration for dynamic boot!
mkdir -p "$ROOTFS/etc"
echo "DE=\"$DE\"" > "$ROOTFS/etc/termux-linux-manager.conf"
echo "SERVER=\"$SERVER\"" >> "$ROOTFS/etc/termux-linux-manager.conf"
echo "RESOLUTION=\"$RESOLUTION\"" >> "$ROOTFS/etc/termux-linux-manager.conf"
echo "UPDATE_CMD=\"$UPDATE_CMD\"" >> "$ROOTFS/etc/termux-linux-manager.conf"
if [ "$DE" != "none" ]; then
echo "[*] Setting up Universal Wallpaper..."
mkdir -p "$ROOTFS/usr/share/backgrounds"
wget -qO "$ROOTFS/usr/share/backgrounds/default.jpg" "https://upload.wikimedia.org/wikipedia/commons/thumb/c/c5/Ubuntu_10.04_LTS_default_wallpaper.jpg/1280px-Ubuntu_10.04_LTS_default_wallpaper.jpg" || true
fi
cat << EOF > "$SETUP_SCRIPT"
#!/bin/bash
export DEBIAN_FRONTEND=noninteractive
echo " -> Updating repositories..."
$UPDATE_CMD
EOF
APT_PKGS="$SUDO_PKG"
if [ "$DE" == "xfce4" ]; then APT_PKGS="$APT_PKGS $XFCE_PKG"; fi
if [ "$DE" == "lxde" ]; then APT_PKGS="$APT_PKGS $LXDE_PKG"; fi
if [ "$SERVER" == "vnc" ]; then APT_PKGS="$APT_PKGS $VNC_PKG"; fi
APT_PKGS=$(echo "$APT_PKGS" | xargs)
if [ -n "$APT_PKGS" ]; then
cat << EOF >> "$SETUP_SCRIPT"
echo " -> Installing core packages ($APT_PKGS)..."
$INSTALL_CMD $APT_PKGS
EOF
fi
# Install optional applications safely
if [ -n "$SELECTED_PKGS" ]; then
cat << EOF >> "$SETUP_SCRIPT"
echo " -> Installing Selected Applications..."
$INSTALL_CMD $SELECTED_PKGS || true
EOF
fi
cat << 'EOF' >> "$SETUP_SCRIPT"
echo " -> Creating standard 'user' account with sudo privileges..."
useradd -m -s /bin/bash user || true
echo "user:ubuntu" | chpasswd
echo "user ALL=(ALL) ALL" >> /etc/sudoers
echo "root ALL=(ALL) ALL" >> /etc/sudoers
echo " -> Linking Android Internal Storage..."
mkdir -p /home/user/storage
if [ -d /data/data/com.termux/files/home/storage ]; then
ln -sf /data/data/com.termux/files/home/storage/* /home/user/storage/
fi
chown -R user:user /home/user/storage
EOF
if [ "$INSTALL_IDE" == "1" ]; then
cat << 'EOF' >> "$SETUP_SCRIPT"
echo " -> Installing Google Antigravity IDE..."
cat << 'IDE' > /usr/local/bin/antigravity-ide
#!/bin/bash
echo "========================================="
echo " Welcome to Google Antigravity IDE! "
echo " Powered by AI. (Terminal Edition) "
echo "========================================="
nano
IDE
chmod +x /usr/local/bin/antigravity-ide
EOF
fi
if [ "$SERVER" == "vnc" ]; then
cat << 'EOF' >> "$SETUP_SCRIPT"
echo " -> Configuring VNC Password (default: ubuntu)..."
mkdir -p /home/user/.vnc
expect << 'EOD'
spawn vncpasswd /home/user/.vnc/passwd
expect "Password:"
send "ubuntu\r"
expect "Verify:"
send "ubuntu\r"
expect "Would you like to enter a view-only password (y/n)?"
send "n\r"
expect eof
EOD
EOF
if [ "$DE" == "xfce4" ]; then
cat << 'EOF' >> "$SETUP_SCRIPT"
cat << 'STARTUP' > /home/user/.vnc/xstartup
#!/bin/sh
export PULSE_SERVER=127.0.0.1
startxfce4 &
(sleep 5 && xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/workspace0/last-image -s /usr/share/backgrounds/default.jpg || true) &
STARTUP
EOF
elif [ "$DE" == "lxde" ]; then
cat << 'EOF' >> "$SETUP_SCRIPT"
cat << 'STARTUP' > /home/user/.vnc/xstartup
#!/bin/sh
export PULSE_SERVER=127.0.0.1
startlxde &
(sleep 5 && pcmanfm --set-wallpaper /usr/share/backgrounds/default.jpg || true) &
STARTUP
EOF
fi
cat << 'EOF' >> "$SETUP_SCRIPT"
chmod +x /home/user/.vnc/xstartup
chown -R user:user /home/user/.vnc
EOF
fi
echo "[*] Executing setup inside $DISTRO (this will take a while)..."
proot-distro login "$DISTRO" -- bash /root/gui_setup.sh
echo "[*] Setting up Home-Screen Widget Integration..."
mkdir -p ~/.shortcuts
cat << 'EOF' > ~/.shortcuts/Start-Linux
#!/bin/bash
start-linux
EOF
chmod +x ~/.shortcuts/Start-Linux
echo "[*] Generating Universal Quick-Launch Scripts..."
cat << 'EOF' > $PREFIX/bin/start-linux
#!/bin/bash
DISTROS=($(ls $PREFIX/var/lib/proot-distro/installed-rootfs/ 2>/dev/null))
if [ ${#DISTROS[@]} -eq 0 ]; then
echo "No distributions installed. Please run install_linux.sh first."
exit 1
elif [ ${#DISTROS[@]} -eq 1 ]; then
DISTRO=${DISTROS[0]}
else
echo "Multiple distributions found. Please choose one to start:"
for i in "${!DISTROS[@]}"; do
echo "$((i+1))) ${DISTROS[$i]}"
done
read -p "Select a distro [1-${#DISTROS[@]}]: " choice
if [[ ! "$choice" =~ ^[0-9]+$ ]] || [ "$choice" -lt 1 ] || [ "$choice" -gt "${#DISTROS[@]}" ]; then
echo "Invalid selection."
exit 1
fi
idx=$((choice-1))
DISTRO=${DISTROS[$idx]}
fi
CONF_FILE="$PREFIX/var/lib/proot-distro/installed-rootfs/$DISTRO/etc/termux-linux-manager.conf"
if [ -f "$CONF_FILE" ]; then
source "$CONF_FILE"
else
DE="none"
SERVER="none"
fi
echo "Starting PulseAudio..."
pulseaudio --start --load="module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1" --exit-idle-time=-1
echo "Starting VirGL Server..."
virgl_test_server_android &
if [ "$SERVER" == "x11" ]; then
echo "Starting Termux:X11..."
termux-x11 :1 &
sleep 2
echo "Starting $DISTRO as 'user'..."
if [ "$DE" == "xfce4" ]; then
proot-distro login $DISTRO --user user --shared-tmp -- bash -c "export PULSE_SERVER=127.0.0.1; export DISPLAY=:1; export GALLIUM_DRIVER=virpipe; export MESA_GL_VERSION_OVERRIDE=4.0; startxfce4 & (sleep 5 && xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/workspace0/last-image -s /usr/share/backgrounds/default.jpg || true) &"
elif [ "$DE" == "lxde" ]; then
proot-distro login $DISTRO --user user --shared-tmp -- bash -c "export PULSE_SERVER=127.0.0.1; export DISPLAY=:1; export GALLIUM_DRIVER=virpipe; export MESA_GL_VERSION_OVERRIDE=4.0; startlxde & (sleep 5 && pcmanfm --set-wallpaper /usr/share/backgrounds/default.jpg || true) &"
fi
elif [ "$SERVER" == "vnc" ]; then
echo "Starting VNC Server..."
if [ -z "$RESOLUTION" ]; then RESOLUTION="1280x720"; fi
proot-distro login $DISTRO --user user --shared-tmp -- bash -c "export PULSE_SERVER=127.0.0.1; export GALLIUM_DRIVER=virpipe; export MESA_GL_VERSION_OVERRIDE=4.0; vncserver -geometry $RESOLUTION :1"
else
echo "Starting $DISTRO CLI as 'user'..."
proot-distro login $DISTRO --user user --shared-tmp
fi
EOF
chmod +x $PREFIX/bin/start-linux
cat << 'EOF' > $PREFIX/bin/stop-linux
#!/bin/bash
DISTROS=($(ls $PREFIX/var/lib/proot-distro/installed-rootfs/ 2>/dev/null))
if [ ${#DISTROS[@]} -eq 0 ]; then
echo "No distributions installed."
exit 1
elif [ ${#DISTROS[@]} -eq 1 ]; then
DISTRO=${DISTROS[0]}
else
echo "Multiple distributions found. Which one do you want to stop?"
for i in "${!DISTROS[@]}"; do
echo "$((i+1))) ${DISTROS[$i]}"
done
read -p "Select a distro [1-${#DISTROS[@]}]: " choice
if [[ ! "$choice" =~ ^[0-9]+$ ]] || [ "$choice" -lt 1 ] || [ "$choice" -gt "${#DISTROS[@]}" ]; then
echo "Invalid selection."
exit 1
fi
idx=$((choice-1))
DISTRO=${DISTROS[$idx]}
fi
CONF_FILE="$PREFIX/var/lib/proot-distro/installed-rootfs/$DISTRO/etc/termux-linux-manager.conf"
if [ -f "$CONF_FILE" ]; then
source "$CONF_FILE"
else
SERVER="none"
fi
echo "Stopping PulseAudio..."
pulseaudio -k 2>/dev/null || true
echo "Stopping VirGL Server..."
killall virgl_test_server_android 2>/dev/null || true
if [ "$SERVER" == "x11" ]; then
echo "Stopping Termux:X11..."
killall termux-x11 2>/dev/null || true
elif [ "$SERVER" == "vnc" ]; then
echo "Stopping VNC Server..."
proot-distro login $DISTRO --user user --shared-tmp -- bash -c "vncserver -kill :1" 2>/dev/null || true
fi
EOF
chmod +x $PREFIX/bin/stop-linux
echo ""
echo "========================================="
echo "Installation complete!"
echo "You are now running as a standard user."
echo "Password for sudo is: ubuntu"
echo "Use commands: start-linux / stop-linux"
echo "If you installed the Termux:Widget app, a shortcut is on your home screen!"
echo "========================================="
read -p "Press Enter to return to menu..."
show_menu
}
show_menu