This commit is contained in:
2026-03-02 17:27:55 +01:00
commit ede4855516

198
p.md Normal file
View File

@@ -0,0 +1,198 @@
#!/data/data/com.termux/files/usr/bin/bash
# Termux Ultimate Remote Dev Environment Setup
# Run: bash setup-termux.sh
set -e
echo "=== Termux Remote Dev Environment Setup ==="
# Update & upgrade
pkg update -y && pkg upgrade -y
# Grant storage access
termux-setup-storage
# ── Core Utilities ──
pkg install -y \
coreutils findutils grep sed gawk \
curl wget openssl-tool \
git git-lfs \
tar zip unzip p7zip \
man less tree ncurses-utils \
termux-api termux-tools
# ── SSH Server & Client ──
pkg install -y openssh mosh autossh sshpass
# Generate host keys
ssh-keygen -A 2>/dev/null || true
# Generate user key pair (no passphrase for convenience)
[ ! -f ~/.ssh/id_ed25519 ] && ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -N ""
echo "→ Start SSH server with: sshd -p 8022"
echo "→ Connect from PC with: ssh -p 8022 $(whoami)@<tablet-ip>"
# ── Remote Desktop (VNC + X11) ──
pkg install -y x11-repo
pkg install -y \
tigervnc xorg-server \
openbox xfce4 xfce4-terminal \
aterm dbus
# VNC setup
mkdir -p ~/.vnc
echo "→ Set VNC password:"
vncpasswd || true
cat > ~/start-vnc.sh << 'VNCEOF'
#!/bin/bash
export DISPLAY=:1
vncserver :1 -geometry 1920x1080 -depth 24 -localhost no
# Start XFCE desktop
export PULSE_SERVER=127.0.0.1
dbus-launch --exit-with-session startxfce4 &
echo "VNC running on port 5901"
VNCEOF
chmod +x ~/start-vnc.sh
cat > ~/stop-vnc.sh << 'EOF'
#!/bin/bash
vncserver -kill :1 2>/dev/null
echo "VNC stopped"
EOF
chmod +x ~/stop-vnc.sh
# ── Code Server (VS Code in Browser) ──
pkg install -y nodejs-lts yarn
npm install -g code-server@latest || {
echo "code-server npm install failed, trying binary..."
curl -fsSL https://code-server.dev/install.sh | sh
}
mkdir -p ~/.config/code-server
cat > ~/.config/code-server/config.yaml << 'CSEOF'
bind-addr: 0.0.0.0:8080
auth: password
password: changeme123
cert: false
CSEOF
echo "→ Start code-server with: code-server"
echo "→ Access at http://<tablet-ip>:8080"
# ── Editors & Dev Tools ──
pkg install -y \
neovim nano micro \
tmux screen \
htop bottom \
jq yq fzf fd ripgrep bat exa \
direnv
# Tmux config for remote work
cat > ~/.tmux.conf << 'TMUXEOF'
set -g mouse on
set -g history-limit 50000
set -g default-terminal "tmux-256color"
set -ga terminal-overrides ",*256col*:Tc"
set -g base-index 1
setw -g pane-base-index 1
set -g status-style 'bg=#333333 fg=#ffffff'
set -g status-right '#H | %Y-%m-%d %H:%M'
set -g escape-time 10
# Better prefix
unbind C-b
set -g prefix C-a
bind C-a send-prefix
# Easy splits
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
TMUXEOF
# Neovim basic config
mkdir -p ~/.config/nvim
cat > ~/.config/nvim/init.lua << 'NVIMEOF'
vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.expandtab = true
vim.opt.shiftwidth = 2
vim.opt.tabstop = 2
vim.opt.clipboard = "unnamedplus"
vim.opt.termguicolors = true
vim.opt.mouse = "a"
vim.opt.signcolumn = "yes"
NVIMEOF
# ── Languages & Runtimes ──
pkg install -y \
python python-pip \
rust \
golang \
clang make cmake \
ruby
# Python essentials
pip install --upgrade pip
pip install ipython httpie
# ── Networking & Tunneling ──
pkg install -y \
nmap net-tools iproute2 dnsutils \
cloudflared
# Cloudflare tunnel script (expose without port forwarding)
cat > ~/start-tunnel.sh << 'TUNEOF'
#!/bin/bash
# Expose code-server publicly via Cloudflare tunnel
echo "Starting Cloudflare tunnel for code-server on :8080..."
cloudflared tunnel --url http://localhost:8080
TUNEOF
chmod +x ~/start-tunnel.sh
# ── File Sharing ──
pkg install -y rsync
# Simple HTTP file server alias
cat >> ~/.bashrc << 'BASHEOF'
# ── Aliases ──
alias ll='exa -la --icons 2>/dev/null || ls -la'
alias cat='bat --paging=never 2>/dev/null || cat'
alias serve='python -m http.server 8888'
alias myip='curl -s ifconfig.me && echo'
alias sshstart='sshd -p 8022 && echo "SSH running on port 8022"'
alias vncstart='~/start-vnc.sh'
alias vncstop='~/stop-vnc.sh'
alias codestart='code-server &'
alias tunnel='~/start-tunnel.sh'
# ── Environment ──
export EDITOR=nvim
export VISUAL=nvim
export GPG_TTY=$(tty)
BASHEOF
# ── Git Config ──
git config --global init.defaultBranch main
git config --global pull.rebase true
git config --global core.editor nvim
# ── Summary ──
echo ""
echo "============================================"
echo " ✅ Termux Remote Dev Environment Ready!"
echo "============================================"
echo ""
echo " REMOTE ACCESS OPTIONS:"
echo " ─────────────────────"
echo " SSH: sshstart → connect on port 8022"
echo " VS Code: codestart → browser at :8080"
echo " VNC Desktop: vncstart → VNC client at :5901"
echo " Tunnel: tunnel → public URL via Cloudflare"
echo ""
echo " QUICK COMMANDS:"
echo " ─────────────"
echo " tmux → terminal multiplexer"
echo " nvim → editor"
echo " serve → HTTP file server on :8888"
echo " myip → show public IP"
echo ""
echo " ⚠️ Change code-server password in:"
echo " ~/.config/code-server/config.yaml"
echo ""
echo " Run: source ~/.bashrc"
echo "============================================"